Skip to content

Instantly share code, notes, and snippets.

View jl's full-sized avatar

Joey Liaw jl

  • San Francisco, California
View GitHub Profile
@jl
jl / gist:8621966
Created January 25, 2014 19:20
git gc all git repositories under current directory
find . -type d -name .git -print -execdir git gc \;
@jl
jl / findbin.sh
Created January 21, 2014 22:03
print signature of executable files; for example pipe to fgrep "Mach-O" or "ELF"
find $1 -type f -executable -not -name '*.js' -exec file {} \;
# non-gnu
# find $1 -type f -perm /111 -not -name '*.js' -exec file {} \;
@jl
jl / gist:8448761
Created January 16, 2014 02:21
force linux clock update
date && sudo service ntp stop && sudo ntpd -gq && sudo service ntp start && date
@jl
jl / fix-git-email
Last active January 3, 2016 04:49
bash script to replace committer email and name in all history
#!/bin/bash
if [[ -z $3 ]]; then
echo "Usage: $(basename $BASH_SOURCE) bad-email good-email good-name"
exit 1
fi
export BAD_EMAIL=$1
export GOOD_EMAIL=$2
export GOOD_NAME=$3
git filter-branch --env-filter '
if [[ $GIT_AUTHOR_EMAIL = $BAD_EMAIL ]]; then
@jl
jl / joey.gitconfig
Last active January 3, 2016 04:49
Collection of useful git aliases.
# Add the following to ~/.gitconfig
# [include]
# path=joey.gitconfig
[alias]
st = status
br = branch
# Show graphical history in terminal.
gr = log --graph --oneline --abbrev-commit --decorate --color
@jl
jl / gcd_notes.md
Last active December 15, 2015 05:48

Notes on Grand Central Dispatch

This document assumes ARC and Obj-C as of iOS 6.1 and Xcode 4.6.

In Obj-C, GCD will automatically retain objects, including self. In C++, you have to do this yourself for EVERY non-copied object referenced by a dispatch_async block.

#include <memory>
class Foo : std::enable_shared_from_this<Foo> {
@jl
jl / MyApp.as
Created October 21, 2011 18:29
Actionscript Hello World (no flex)
// Build: mxmlc MyApp.as
// Generates: MyApp.swf
// You can debug with browser debug player plugin,
// or using the debug player projector standalone app.
package {
import flash.display.Sprite;
import flash.events.Event;
public class MyApp extends Sprite {
public function MyApp() {