Skip to content

Instantly share code, notes, and snippets.

View maninak's full-sized avatar
🧐
Scanning for my next big challenge. Hiring? Mail me at 750907f6@opayq.com .

Kostis Maninakis maninak

🧐
Scanning for my next big challenge. Hiring? Mail me at 750907f6@opayq.com .
View GitHub Profile
@lorenzleutgeb
lorenzleutgeb / rad-worktree.sh
Last active May 7, 2024 19:32
rad-worktree
#! /bin/sh
set -eu
jq -V >/dev/null
if [ $# -lt 1 ]
then
printf 'Usage: %s rad:… [name-of-worktree]\n' "$0"
printf 'The worktree will be created in a new directory within the current working directory.'
exit 1
@lorenzleutgeb
lorenzleutgeb / rad-alternate.sh
Last active May 7, 2024 14:14
rad-alternate
#! /bin/sh
set -eu
REMOTE="rad"
ALTERNATES="$(git rev-parse --absolute-git-dir)/objects/info/alternates"
URI=$(git remote get-url "$REMOTE")
if [ "${URI:0:6}" != "rad://" ]
then
echo "URL for remote '$REMOTE' does not have expected prefix 'rad://'. Aborting."
@lorenzleutgeb
lorenzleutgeb / rad-wire.sh
Last active May 7, 2024 14:15
rad-wire
#! /bin/sh
set -eu
JQ="jq --unbuffered --color-output"
JQ_TX="JQ_COLORS='1;30:0;39:0;39:0;39:1;35:1;39:1;39:1;31' $JQ | sed 's/^/>/'"
JQ_RX="JQ_COLORS='0;90:0;37:0;37:0;37:0;32:1;37:1;37:1;34' $JQ | sed 's/^/</'"
SOCKET="${RAD_HOME:-"${HOME}/.radicle"}/node/control.sock"
if [ ! -S "${SOCKET}" ]
@davidgilbertson
davidgilbertson / http2.js
Last active October 9, 2023 06:09
HTTP2 server with compression and caching
const http2 = require('http2');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const brotli = require('brotli'); // npm package
const PORT = 3032;
const BROTLI_QUALITY = 11; // slow, but we're caching so who cares
const STATIC_DIRECTORY = path.resolve(__dirname, '../dist/');
const cache = {};
@makenova
makenova / Difference between debounce and throttle.md
Last active February 22, 2023 03:09
Javascript function debounce and throttle

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle