Skip to content

Instantly share code, notes, and snippets.

View saml's full-sized avatar

Sam Lee saml

  • New York, NY
View GitHub Profile
@saml
saml / chromium-update.sh
Created December 22, 2010 11:31
automatically downloads and updates chromium nightly
#!/bin/bash
d="$HOME/opt/chromium"
v="$d/VERSION"
u="http://build.chromium.org/f/chromium/snapshots/chromium-rel-linux"
downloads="$HOME/Downloads"
unzipped="$downloads/chrome-linux"
zip_file="$downloads/chrome-linux.zip"
latest="$(curl "$u/LATEST" 2> /dev/null)"
@saml
saml / ftypedef.c
Created January 15, 2011 05:15
function pointer typedef macro
/*
gcc -ansi -pedantic -Wall -Wextra -std=c99 ftypedef.c
*/
#include <stdio.h>
#define FTypedef(ReturnType, Name, ...) typedef ReturnType (*Name)(__VA_ARGS__)
void foo(int i, char *str) {
printf("%d - %s\n", i, str);
@saml
saml / lua.sh
Created February 19, 2011 03:52
#!/bin/bash
LUA_HOME="$HOME/opt/lua"
export LUA_PATH="$LUA_PATH;./?.lua;$LUA_HOME/luamodules/?.lua"
export LUA_CPATH="$LUA_CPATH;./?.so;$LUA_HOME/luamodules/?.so"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/opt/gmp/lib:$LUA_HOME/lib"
"$LUA_HOME/bin/lua" -lreadline -lcomplete -lprelude $*
@saml
saml / ad.as
Created March 16, 2011 14:17
ad.html
package {
import flash.display.Sprite;
import flash.external.ExternalInterface;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFieldAutoSize;
import flash.system.Security;
//advertisement swf doing xhr to their domain
[SWF(width="300",height="300")]
We couldn’t find that file to show.
@saml
saml / ats-rcepl.sh
Created April 12, 2011 11:48
poor man's repl
#!/bin/bash
ATSCC="$ATSHOME/bin/atscc"
TMP_DIR="$(mktemp -d --suffix='.ats-rcepl')"
TMP_DATS="$TMP_DIR/tmp.dats"
TMP_EXE="$TMP_DIR/tmp.exe"
function prompt() {
echo -n "> "
}
@saml
saml / cq-image-upload.sh
Created April 12, 2011 14:16
doesn't really work
#!/bin/bash
if (( $# < 2 ))
then
echo "Usage: $0 file-path url [cred]"
echo " uploads file-path to url"
echo "example, $0 ~/images/foo.jpg http://localhost:4502/content/dam/2010/12/foo.jpg admin:admin"
exit 1
fi
@saml
saml / build.sh
Created April 23, 2011 02:51
nginx build
#!/bin/bash
## Where nginx will be installed
prefix="$HOME/nginx"
## Put path to module source code
modules=(
"$HOME/code/ngx_devel_kit"
"$HOME/code/lua-nginx-module"
)
#!/bin/bash
if (( $# < 2 ))
then
echo "Usage: $0 path-to-activate host:port [dryrun|activate] [username:password]"
exit 1
fi
path="$1"
host="$2"
import base64
import sys
tb_hex_bin = {
0x0: '0000',
0x1: '0001',
0x2: '0010',
0x3: '0011',
0x4: '0100',
0x5: '0101',