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 / 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() {
@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 / 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 / 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 / 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 / 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: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 / macvim-git-merge.md
Last active October 1, 2023 03:46
Use MacVim to resolve git merge conflicts

When you install MacVim, you have the option of installing command line integration. This basically puts an mvim shell script somewhere in your path, usually /usr/local/bin/mvim. Git has a list of mergetools that it knows about; gvimdiff is in the list, which expects gvim to be in the path.

First, figure out where your mvim script lives, then add a gvim link.

$ which mvim
/usr/local/bin/mvim
$ cd /usr/local/bin
$ ln -s mvim gvim
$ ls -l gvim
@jl
jl / vagrant-centos7-base.md
Last active April 22, 2019 03:22
How to setup a CentOS 7 vagrant base box

Mac OS X

  • install virtualbox
  • install vagrant
  • download CentOS 7 minimal ISO
  • create a new virtualbox instance "centos7base"
    • 512 mb ram
    • VDI, dynamically allocated, 8 gb
    • disable USB and audio controllers
  • insert the centos 7 iso into the virtual drive
@jl
jl / proggymacvim.md
Last active August 29, 2015 14:06
ProggyFont on MacVim

ProggyFont on MacVim

Text looks beautiful on MacBook Retina displays. You can use pretty much any monospace font, anti-aliased, and it will be quite readable for coding on your laptop's screen at 220 ppi. However, if you attach something with less than half that density, for example, the 93 ppi Dell U2414H (23.8" diagonal 1920 x 1200) then you get mushy fonts again.

Below are instructions for installing a pixel-perfect bitmap font which will give you back crisp text on both the external and internal Retina display and greatly reduce eye strain.

Download and install ProggyFont TrueType Font.

" add to ~/.vim/gvimrc