Skip to content

Instantly share code, notes, and snippets.

@yuvalkarmi
yuvalkarmi / blockNextNavigation.js
Last active April 30, 2024 13:42
How to block a user from navigating away in NextJS when clicking on Link component
/*
In standard web apps, when users navigate away to a different page or website or attempt to refresh a page,
we can use the window event listener `beforeunload` to help users avoid losing the work.
However, when a user clicks on a native NextJS <Link> component, the navigation is not intercepted
because behind the scenes, no page changes are actually happening.
To intercept user navigation in a NextJS app, we can subscribe to the
router routeChangeError event and throw an error.
Note: we must throw an Error string - not a `new Error()` - which is why in the code below, we have
// eslint-disable-next-line no-throw-literal
@aamiaa
aamiaa / CompleteDiscordQuest.md
Last active April 30, 2024 13:41
Complete Recent Discord Quest

Complete Recent Discord Quest

Note

This no longer works in browser!

Note

This no longer works if you're alone in vc! Somebody else has to join you!

How to use this script:

  1. Accept the quest under User Settings -> Gift Inventory

I've recently joined Amazon Dublin from India and got opportunities to interview with Meta London, Zalando Berlin & some other companies. I extensively researched about companies hiring internationally which support visa & relocation for Tech roles. So sharing list of companies:

Do consider to STAR, if it helped you.

London

@cclloyd
cclloyd / manifest.yml
Last active April 30, 2024 13:39
Paperless deployment on kubernetes
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: paperless
labels:
app: paperless
spec:
replicas: 1
selector:
@buttercutter
buttercutter / mamba.py
Last active April 30, 2024 13:38
Mamba: Linear-Time Sequence Modeling with Selective State Spaces
# [Mamba: Linear-Time Sequence Modeling with Selective State Spaces](https://arxiv.org/abs/2312.00752)
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader, Dataset
from torch.nn import functional as F
from einops import rearrange, repeat
from tqdm import tqdm
@mgaitan
mgaitan / git-sw
Last active April 30, 2024 13:36
git smart switch : Like `git switch` but stashing uncommitted changes and recovering them when you are back.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Git smart switch
Like `git switch` but stashing uncommitted changes and recovering them when you are back.
# Install

A metatable can be defined like

local t = setmetatable({}, {
  __tostring = function() return 'custom tostring behavior!' end
})

Here are the metamethods that you can define, and their behavior

Operators

@JamesTheHacker
JamesTheHacker / Session.js
Last active April 30, 2024 13:33
Log into Facebook using cookies
'use strict'
let Promise = require('bluebird');
let fs = Promise.promisifyAll(require('fs'));
let Cheerio = require('cheerio');
let Request = require('request');
let ToughCookie = require('tough-cookie');
class Session {
@SheldonWangRJT
SheldonWangRJT / Convert .mov or .MP4 to .gif.md
Last active April 30, 2024 13:33
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.