Skip to content

Instantly share code, notes, and snippets.

@bnoordhuis
bnoordhuis / count-promises.js
Created September 28, 2023 19:13
[node.js] count active promises via the V8 inspector
"use strict"
const inspector = require("node:inspector/promises")
const session = new inspector.Session()
session.connect()
countPromises(session).then(console.log)
async function countPromises(session) {
// resource management: put all results in an object group
const objectGroup = crypto.randomUUID()
@SergeyMiracle
SergeyMiracle / nginx_auto_start.sh
Created January 13, 2017 04:42 — forked from aymanosman/nginx_auto_start.sh
Nginx: Start nginx on boot on Mac
# brew install nginx
sudo ln -s /usr/local/opt/nginx/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/
sudo chown root:wheel /usr/local/opt/nginx/homebrew.mxcl.nginx.plist
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
# Why do you need sudo?
# If you want nginx to be able to bind to port 80, it will need superuser privileges
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active April 6, 2025 15:12
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@XoseLluis
XoseLluis / es6ProxiesAndGetTrap.js
Last active December 13, 2021 10:10
ES6 proxies and method interception, 2 different ways of setting your get trap
// http://deploytonenyures.blogspot.fr/2015/11/es6-proxies-part-ii.html
//to run it in node.js 4 it should be just this flag: --harmony_proxies
//but does not seem to work, so run it in Firefox
var cat = {
name: "Kitty",
method1: function(msg){
console.log("cat: " + this.name + ", method1 invoked with msg: " + msg);
this.method2(msg);
},
@jordan-brough
jordan-brough / git-recent
Last active April 1, 2025 15:55
Git: Display a list of recently checked out branches/tags/commits
#!/usr/bin/env bash
# Source: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd
# See also: https://stackoverflow.com/a/25095062/58876
# Download this script as "git-recent" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git recent` from inside any git repo.
# Examples:
@staltz
staltz / introrx.md
Last active April 8, 2025 04:41
The introduction to Reactive Programming you've been missing
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active April 4, 2025 20:57
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@mwhite
mwhite / git-aliases.md
Last active March 23, 2025 00:40
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@paulirish
paulirish / rAF.js
Last active March 5, 2025 08:53
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];