Skip to content

Instantly share code, notes, and snippets.

View peburrows's full-sized avatar

Phil Burrows peburrows

View GitHub Profile
defmodule Equality do
@tests [
0,
1,
-1,
2,
-2,
10,
-10,
3,
@peburrows
peburrows / commit-msg
Last active August 29, 2015 14:22
Emojify your commit messages!
#!/usr/bin/env ruby
emoji = ["bowtie", "smile", "laughing", "blush", "smiley", "relaxed", "smirk", "heart_eyes",
"kissing_heart", "kissing_closed_eyes", "flushed", "relieved", "satisfied", "grin",
"wink", "stuck_out_tongue_winking_eye", "stuck_out_tongue_closed_eyes", "grinning",
"kissing", "kissing_smiling_eyes", "stuck_out_tongue", "sleeping", "worried", "frowning",
"anguished", "open_mouth", "grimacing", "confused", "hushed", "expressionless", "unamused",
"sweat_smile", "sweat", "disappointed_relieved", "weary", "pensive", "disappointed",
"confounded", "fearful", "cold_sweat", "persevere", "cry", "sob", "joy", "astonished",
"scream", "neckbeard", "tired_face", "angry", "rage", "triumph", "sleepy", "yum", "mask",
table { width: 100%; }
@peburrows
peburrows / index.html
Created October 9, 2012 16:49
Draw on the html5 canvas using text as your medium.
<canvas id='canvas'></canvas>
<span id='info'>Click and drag to draw!<span>
<!--
Drawing with text:
- Click and drag to draw.
- Double click to clear.
Ported from java at http://www.generative-gestaltung.de
@peburrows
peburrows / I18n.js
Created February 21, 2012 17:58
javascript localization library
var i18n = (function(){
// this copy of the i18n object is for the constructor
var i18n = function(){
// privleged vars
var _locales = {};
// public vars
this.locale = 'en';
// priviledged methods that can access local variables;
@peburrows
peburrows / .bashrc
Created November 29, 2011 02:42 — forked from henrik/.bashrc
Git branch and dirty state in Bash prompt.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@peburrows
peburrows / gist:1138773
Created August 11, 2011 02:16 — forked from carolineschnapp/related-products.liquid
Related Products — to add to product.liquid
<!-- Solution brought to you by Caroline Schnapp -->
<!-- See this: http://wiki.shopify.com/Related_Products -->
{% assign number_of_related_products_to_show = 3 %}
{% assign image_size = 'compact' %}
{% assign heading = 'Other fine products' %}
{% capture number_of_related_products_to_fetch %}{{ number_of_related_products_to_show | plus: 1 }}{% endcapture %}
{% if collection == null or collection.handle == 'frontpage' or collection.handle == 'all' %}
@peburrows
peburrows / gist:198583
Created October 1, 2009 00:15
SQL Optimizations Paying Off
>> # Before optimizations (easy to find the log entries, thanks to MongoDB logging):
>> log.find(:action => 'home',
:controller => 'asset',
:request_time => {'$lt' => 20.minutes.ago}
).each{|r| puts "#{r['request_time']} | #{r['runtime']}ms"}
Fri Sep 25 17:04:36 UTC 2009 | 8648 ms
Fri Sep 25 17:04:54 UTC 2009 | 5557 ms
Fri Sep 25 18:01:49 UTC 2009 | 5813 ms
Fri Sep 25 18:07:21 UTC 2009 | 8377 ms
>> db = Mongo::Connection.new.db('golden_child')
=> #<Mongo::DB:0x104f2bed0 @name="golden_child", @host="localhost", @pk_factory=nil, @socket=#<TCPSocket:0x104f2b4f8>, @slave_ok=nil, @port=27017, @nodes=[["localhost", 27017]], @auto_reconnect=nil, @semaphore=#<Object:0x104f2bd90 @mu_locked=false, @mu_waiting=[]>, @strict=nil>
>> coll = db['development.log']
=> #<Mongo::Collection:0x104f252d8 @name="development.log", @db=#<Mongo::DB:0x104f2bed0 @name="golden_child", @host="localhost", @pk_factory=nil, @socket=#<TCPSocket:0x104f2b4f8>, @slave_ok=nil, @port=27017, @nodes=[["localhost", 27017]], @auto_reconnect=nil, @semaphore=#<Object:0x104f2bd90 @mu_locked=false, @mu_waiting=[]>, @strict=nil>, @hint=nil>
>> coll.find(:action => 'show', :controller => 'cart').count
=> 5
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.vitalsource.golden_child.clear_inactive_carts</string>
<key>EnvironmentVariables</key>
<dict>
<key>RAILS_ENV</key>
<string><%= rails_env %></string>