Skip to content

Instantly share code, notes, and snippets.

@atdt
atdt / diffbranches
Created September 12, 2016 19:33
Diff JavaScript (or any other type of file) across two production branches
#!/usr/bin/env bash
file_pattern='*.js' # Which files to consider
v1="php-1.28.0-wmf.18" # Base branch
v2="php-1.28.0-wmf.17" # Target branch
while IFS= read -r a; do
b="${a/$v1/$v2}"
diff -u "$a" "$b" # Change '-u' to '-q' if you only want
# to list which files have changed.
done < <(find "/srv/mediawiki/${v1}" -name "$file_pattern")
@Rich-Harris
Rich-Harris / module-ordering.md
Last active March 23, 2022 19:22
Non-deterministic module ordering is an even bigger footgun

Non-deterministic module ordering is an even bigger footgun

Update – in the comments below, @bmeck clarifies that statically imported modules do evaluate in a deterministic sequential order, contra the Hacker News comments that prompted this gist.

Another follow-up to Top-level await is a footgun. On the Hacker News comments, Domenic says this:

(The argument also seems to be predicated on some fundamental misunderstandings, in that it thinks everything would have to be sequentialized. See my other replies throughout this thread.)

In other words, if you have an app like this...

@PaulKinlan
PaulKinlan / monitorEvents.js
Created October 14, 2016 07:38
monitorEvents.js
function monitorEvents(element) {
var log = function(e) { console.log(e);};
var events = [];
for(var i in element) {
if(i.startsWith("on")) events.push(i.substr(2));
}
events.forEach(function(eventName) {
element.addEventListener(eventName, log);
});
// This is my solution to the "Little JavaScript Problem" from http://lisperator.net/blog/a-little-javascript-problem/
// Apparently this means Mihai Bazon will hire me... Woo!
var pair = (head, tail) => (f => f(head, tail))
var car = (pair) => pair((head, tail) => head)
var cdr = (pair) => pair((head, tail) => tail)
var range = (min, max) => pair(min, min == max ? null : range(min + 1, max))
var map = (list, func) => pair(func(car(list)), cdr(list) === null ? null : map(cdr(list), func))
var reverse = (list, newList=null) => list === null ? newList : reverse(cdr(list),pair(car(list), newList))
var foreach = (list, func) => list === null ? null : (func(car(list)), foreach(cdr(list), func))
@aryzhov
aryzhov / example.yaml
Last active January 26, 2024 11:44
YAML array extention in Python
CoreTeam: &CoreTeam
Characters:
- Mario
- Luigi
ExtendedTeam: &ExtendedTeam
<<: *CoreTeam
Characters+:
- Princess Peach
- Yoshi
@chrisveness
chrisveness / crypto-aes-gcm.js
Last active January 8, 2026 19:38
Uses the SubtleCrypto interface of the Web Cryptography API to encrypt and decrypt text using AES-GCM (AES Galois counter mode).
/**
* Encrypts plaintext using AES-GCM with supplied password, for decryption with aesGcmDecrypt().
* (c) Chris Veness MIT Licence
*
* @param {String} plaintext - Plaintext to be encrypted.
* @param {String} password - Password to use to encrypt plaintext.
* @returns {String} Encrypted ciphertext.
*
* @example
* const ciphertext = await aesGcmEncrypt('my secret text', 'pw');
@potatoqualitee
potatoqualitee / no-bright-blue-github.css
Last active March 2, 2017 02:04
Stylebot CSS for the good ol' gentle blue colors of GitHub
h1.public strong a {
color: #4078C0;
}
a.subnav-item.js-subnav-item.selected {
background-color: #4078C0;
}
svg.octicon.octicon-file-directory path {
color: #4078C0;
@libitte
libitte / gist:cbde168d26bc5faf9bf9fef648091b42
Last active October 23, 2024 17:09
FIX warning: ignoring broken ref refs/remotes/origin/HEAD

warning: ignoring broken ref refs/remotes/origin/HEAD


➜   ✗ g symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/develop
➜   ✗ g fetch --prune
➜   ✗ g gc

@tomtorggler
tomtorggler / api-posts.html
Created March 31, 2017 15:56
Create JSON objects for all posts on a Jekyll site
---
# Requires Front Matter
---
{"items":[{% for post in site.posts %}{
"title": {{post.title | jsonify}},
"url": {{ post.url | prepend: site.baseurl | prepend: site.url | jsonify }},
"date": {{ post.date | date: '%B %-d, %Y' | jsonify }},
"category": {{ post.category | jsonify }},
"tags": {{ post.tags | jsonify }},
"author": {{ post.author | jsonify }},
#!/bin/bash
## Setup a delay
sudo dnctl -q flush
sudo dnctl -q pipe flush
sudo dnctl pipe 1 config delay 0ms noerror
sudo dnctl pipe 2 config delay 0ms noerror
sudo pfctl -f pfctl.rules
sudo dnctl pipe 1 config bw 780Kbit/s delay 100ms
sudo dnctl pipe 2 config bw 330Kbit/s delay 100ms