Skip to content

Instantly share code, notes, and snippets.

View andrewle's full-sized avatar

Andrew Le andrewle

View GitHub Profile
define('START_TIME', microtime(true));
function benchmark($class, $function, $line)
{
error_log("dt => {$class}->{$function}:{$line} at: " . (microtime(true) - START_TIME) . " seconds.");
}
//Call by doing:
benchmark(__CLASS__, __FUNCTION__, __LINE__);
#!/usr/bin/env ruby
#
# This tag doesn't work: div.span-3col.column
#
full_line = STDIN.read
raw_tag = if full_line.strip.match(/\s/)
full_line.strip.reverse.match(/^.*?\s/).to_s.reverse.strip
else
full_line.strip.reverse.match(/^.*?\s?$/).to_s.reverse.strip
end
require 'rubygems'
require 'closure-compiler'
desc "Use the Closure Compiler to compress Tumbletag.js"
task :build do
js = File.open('tumbletag.js', 'r')
min = Closure::Compiler.new.compile(js)
File.open('tumbletag.min.js', 'w') {|f| f.write(min) }
end
@andrewle
andrewle / center_window.sh
Created April 19, 2010 06:37
Center the top most window using AppleScript
#!/usr/bin/env bash
# Center the top most window using AppleScript
# I call this up quickly using Quicksilver and run it as a terminal
# script because (surprise!) it's faster than running as native AppleScript
osascript -e "
tell application \"Finder\"
set screenSize to bounds of window of desktop
set screenWidth to item 3 of screenSize
end tell
@andrewle
andrewle / spacescroller.lua
Created April 13, 2010 03:40
Simple spaceship scroller game demo in Lua with the Love game engine
function love.load()
config = {
initial_x = 200,
initial_y = 400,
step = 500,
numStars = 100,
starSpeedFactor = 1
}
spaceship = {
#!/bin/sh
# Textmate command that uses AppleScript to switch to Firefox, reload
# the browser, and then switch back to Textmate
# I have this bound to Ctl-Opt-Command R
#
# Save: Nothing (or Current File is useful too)
# Input: None
# Output: Discard
#
#
# Implementation of Justin.TV's Namespace API for creating and playing application
# channels. In it's current form the application will dynamically allocate new
# Justin.TV channels for the sake of connecting two people together in a chat/date
# format.
# @author WinkVid
# @source http://sourceforge.net/projects/winkvid/
#
from django.views.generic.simple import direct_to_template
# For compiling PHP 5.2.11 on Mac OS X Leopard 10.5.8
#
# Configure PHP
./configure \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--disable-dependency-tracking \
--with-apxs2=/usr/sbin/apxs \
# A rough and dirty baseline Rails app template
# I just discovered this feature and love it
remove_files = [
"public/index.html",
"public/images/rails.png",
"public/javascripts/controls.js",
"public/javascripts/dragdrop.js",
"public/javascripts/effects.js",
"public/javascripts/prototype.js"
#!/usr/bin/env bash
#
# Ignored .svn directories
# Also ignored .DS_Store files from Mac file system
# Add the --dry-run argument if you want to just test it first
DOMAIN="phototourwebsites@phototourwebsites.com"
DIR="/home/phototourwebsites/www/phototoursmls/idx_dev_andrew"
rsync -avz \