Skip to content

Instantly share code, notes, and snippets.

View andrewle's full-sized avatar

Andrew Le andrewle

View GitHub Profile
@andrewle
andrewle / custom_plan.rb
Created March 22, 2013 17:22
Zeus fix for to_json error
require 'zeus/rails'
class Fixnum
def to_json(options = nil)
to_s
end
end
class CustomPlan < Zeus::Rails
def test
@andrewle
andrewle / chef-bootstrap.sh
Created July 30, 2012 00:47
Bootstrap chef on a bare Debian/Ubuntu Server
#!/bin/bash
# Bootstrap chef-solo on a server
# Install Ruby
sudo apt-get install ruby ruby-dev libopenssl-ruby rdoc ri irb build-essential wget ssl-cert curl
# Install RubyGems instead of using the system version
cd /tmp
curl -O http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz
tar zxf rubygems-1.8.10.tgz
SALE RECEIPT
Store #11476 eat 01/07/10 16:01:48
Subway Sandwiches & Salads
609 N MILPAS ST
MILPAS CA 93103
805-966-3001
Trans# 137 Clerk 3 RAJVINDERPAL
Dwr1 TRDT 010710 Reg-ID REG-MAIN
Receipt # 0000103913
--- ITEM --- QTY PRICE MEMO PLU
@andrewle
andrewle / gist:2939200
Created June 15, 2012 23:22
Vim rename file
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'))
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
@andrewle
andrewle / commit-msg
Created January 11, 2012 09:11
Automatically append a ticket number reference to git commit messages
#!/bin/bash
NUMLINES=$(cat "$1" |
sed '{
# Ignore the "References #blah" line
/^References \#[0-9]*/d
# Remove blank lines
/^$/d
# Remove lines containing only whitespace
/^[ \t]*$/d
#!/usr/bin/env ruby
require 'rubygems'
require 'chef'
require 'chef/client'
require 'chef/run_context'
Chef::Config[:solo] = true
Chef::Config[:log_level] = :info
Chef::Log.level(:info)
@andrewle
andrewle / output-current
Created February 23, 2011 00:55
[html5-boilerplate] Running `ant build` when optipng is not installed on OSX
# Current
$ ant build
Buildfile: /Users/andrewle/Projects/html5-boilerplate/build/build.xml
build:
[echo] Building a Production Environment...
-rev:
[echo] Increasing the build number...
Buildfile: /Users/andrewle/Projects/html5-boilerplate/build/build.xml
build:
[echo] Building a Production Environment...
-rev:
[echo] Increasing the build number...
[propertyfile] Updating property file: /Users/andrewle/Projects/html5-boilerplate/build/config/buildinfo.properties
[echo] Creating build 0009
" Lifted from http://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim
" and cleaned up alignment for for easy reference. Posted here so I can find
" this easily. //Andrew Le
" Generated from c:/pdsrc/xterm-222/256colres.h by allcolors.pl
" Xterm can display text in 256 colors, but it is hard to determine what all
" those colors are. So below is a list of the approximate names for the 256
" default colors in xterm. You can put it in your vimrc or just use it as a
" reference when in doubt.
@andrewle
andrewle / gist:636574
Created October 20, 2010 14:54
IE/Navigator Flashback
<html>
<script>
function IsNewBrowser()
{
var isIE = navigator.appName.indexOf("Microsoft") != -1;
var isNav = navigator.appName.search(/Netscape/i) != -1;
var ver = parseInt(navigator.appVersion);
if(isIE || (isNav && ver >=5) )
return true ;
return false ;