Skip to content

Instantly share code, notes, and snippets.

View leonadler's full-sized avatar

Leon Adler leonadler

View GitHub Profile
@leonadler
leonadler / Tmux JSON format.md
Last active November 18, 2025 05:00
Tmux JSON format

Tmux JSON formatter

Because when all you have is a JSON hammer, everything looks like a JSON nail.

How to use

$ json=$(tmux display-message -p $(<tmux-json-format.txt));
$ your-program-that-needs-json <<<"$json"
@rpavlik
rpavlik / settings.json
Last active March 30, 2026 23:33
Go away copilot and other slop machines (in vscode)
{
// go away copilot and other ai slop machines
"accessibility.verboseChatProgressUpdates": false,
"accessibility.verbosity.inlineChat": false,
"accessibility.verbosity.panelChat": false,
"accessibility.verbosity.terminalChatOutput": false,
"ansible.lightspeed.suggestions.waitWindow": 360000,
"chat.agent.codeBlockProgress": false,
"chat.agent.enabled": false,
"chat.agent.maxRequests": 0,
@leonadler
leonadler / useMemoizedCallback.tsx
Last active October 20, 2021 09:02 — forked from Alx-l/index.tsx
React useMemoizedCallback hook
import * as React from "react";
// see: https://stackoverflow.com/questions/55045566/react-hooks-usecallback-causes-child-to-re-render/55047178
/**
* Useful when you when to pass a function that depends on a piece of state,
* as a prop, without triggering a re-render everytime.
*
* @example
*
@sindresorhus
sindresorhus / esm-package.md
Last active May 5, 2026 02:50
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@leonadler
leonadler / unindent.ts
Last active January 15, 2020 19:33
Tagged template unindent helper
export function unindent(template: TemplateStringsArray, ...args: any[]): string {
let numSpaces = 999;
for (const part of template) {
for (const indentation of part.match(/\n +/g) || []) {
numSpaces = Math.min(numSpaces, indentation.length - 1);
}
}
const spaces = new RegExp('\n' + ' '.repeat(numSpaces < 999 ? numSpaces : 0), 'g');
return template

Windows 10 - Using Git Bash With TMUX

Why Not Use WSL?

I tried the WSL and it isn't quite seamless enough for me. I ran in to problems when editing in VSCode and having watchers on my files (ng serve, dotnet watch run, etc.). In addition, I kept running in to problems that only manifest themselves when running in WSL. For example, this issue with doing production builds and the terser plugin has made many a developer rage-quit on using WSL. Just figuring out that it was an issue with the WSL took a lot of time.

That terser plugin issue was never resolved and I ended up having to keep a git bash window open in addition to my WSL console window so I could do production builds. To make matters worse, my npm packages were platform-dependent so I couldn't use the same project folder. So, my procedure was: commit whatever changes to test branch, push to repo, git pull on my "windows" project folder, and do a production build there

@Alx-l
Alx-l / index.tsx
Last active October 18, 2021 12:23
React useMemoizedCallback hook
import * as React from 'react'
// see: https://stackoverflow.com/questions/55045566/react-hooks-usecallback-causes-child-to-re-render/55047178
/**
* Useful when you when to pass a function that depends on a piece of state,
* as a prop, without triggering a re-render everytime.
*
* @example
*
import { useRef, useCallback, useEffect } from 'react';
// A callback that always closes over the latest data but keeps the same
// identity and will not be called after component unmounts
const useStableCallback = callback => {
const callbackRef = useRef();
const memoCallback = useCallback(
(...args) => callbackRef.current && callbackRef.current(...args),
[],
@troyane
troyane / mp42gif.sh
Last active May 22, 2024 17:20
See script and documentation here: https://github.com/troyane/StackOverflow-pro/tree/master/mp42gif Script to convert MP4 file to GIF (via ffmpeg). It creates intermediate custom color palette out of input video file and use it for resulting GIF for better picture quality. For more info see https://superuser.com/a/556031
#!/bin/bash
#
# Script to convert MP4 video to GIF with generation of custom color palette.
#
#=== Do not touch code below
# Inner variables
input_file=""
input_fps="20"
input_height="512"
@Asjas
Asjas / nginx.conf
Last active November 1, 2025 22:19
Nginx sample config. Includes CSP headers, caching headers, gzip and brotli compression
user www-data;
worker_processes auto;
worker_rlimit_nofile 8192;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 8000;
}