Skip to content

Instantly share code, notes, and snippets.

View jlfwong's full-sized avatar

Jamie Wong jlfwong

View GitHub Profile
@jlfwong
jlfwong / fluid-sim.js
Created December 12, 2025 17:10
fluid-sim.js
/**
* 2D fluid simulation code for
* http://jamie-wong.com/2016/08/04/webgl-fluid-simulation/
*/
window.FluidSim = function(canvasId, options) {
options = options || {};
options.initVFn = options.initVFn || [
'sin(2.0 * 3.1415 * y)',
'sin(2.0 * 3.1415 * x)'

SSH forwarding for Docker Desktop for Mac which respects $SSH_AUTH_SOCK

This is a quick tutorial on how to get SSH key forwarding working on Docker Desktop for Mac in situations where you want control of which ssh-agent server is being used, rather than the default.

You might want to do this to e.g. forward a specific SSH key into a docker container.

Docker has support for general SSH key forwarding, but this doesn't respect $SSH_AUTH_SOCK.

Background on ssh-agent

// http://bgrins.github.io/devtools-snippets/#console-save
var saveToFile = function(data, filename) {
if (!data) {
console.error('Console.save: No data');
return;
}
if (!filename) {
filename = 'console.json';
}
// Handy for debugging sometimes
function tap(fn) {
return function() {
const result = fn.apply(this, arguments);
console.log(Array.prototype.slice.call(arguments), '->', result);
return result;
}
}
@jlfwong
jlfwong / Makefile
Last active August 29, 2015 13:57
CS444 runtime.s for OS X
.PHONY: run
run: test
./$<
test: test.o runtime.o
gcc -arch i386 $^ -o $@
%.o: %.asm
nasm -f macho $< -o $@
@jlfwong
jlfwong / fbchat-to-markdown-blockquote.js
Last active January 1, 2016 00:29
Format FB chats into markdown for pasting into Day One Dump this into the JS console
// http://bgrins.github.io/devtools-snippets/#console-save
var saveToFile = function(data, filename) {
if (!data) {
console.error('Console.save: No data');
return;
}
if (!filename) {
filename = 'console.json';
}
@jlfwong
jlfwong / foobar.js
Created December 10, 2013 22:08
Automatic Semicolon Insertion - Scala vs JavaScript
var foo = function() { console.log("foo"); };
var bar = function() { console.log("bar"); };
(foo())
(bar())
/*
Ouput:
(bar())
@jlfwong
jlfwong / RequireJSsubprocess.md
Created September 29, 2013 19:24
Require JS Subprocess Rubber Ducky Log

Building the package! RequireJS plugin, I'm getting weird side effect problems.

Requiring a package first:

> require(["package!issues.js"]); null
null
Require Package: issues.js package_loader_plugin.js?bust=1379092758956:96
XHR finished loading: "http://localhost:1234/javascript-packages.json".

jquery.js?bust=1379092758956:8526

@jlfwong
jlfwong / gist:6031820
Last active December 19, 2015 22:59
Changing soft tab size in vim

Changing 4 space indentation into 2 space indentation

:set ts=4 noexpandtab | retab! | set ts=2 expandtab | retab!

Changing 4 space indentation in every CoffeeScript file in your current directory

:args ./**/*.coffee | argdo execute "set ts=4 noexpandtab | retab! | set ts=2 expandtab | retab!" | update

Thanks to bamford on #vim for the :retab! trick

@jlfwong
jlfwong / progdiff.sh
Created October 3, 2012 20:07
Diff the stdout, stderr and return code of two programs with piped input and arguments
#!/bin/bash
sandbox="$(mktemp -d)"
hasstdin=false
if [ ! -t 0 ]; then
cat <&0 > "$sandbox/stdin.txt"
hasstdin=true
fi