Skip to content

Instantly share code, notes, and snippets.

View elliot's full-sized avatar

Elliot Anderson elliot

View GitHub Profile
@elliot
elliot / .bashrc
Created August 17, 2009 02:13 — forked from justintv/.bashrc
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer!
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty!
# ~/code/web:beta_directory$ git checkout master
# Switched to branch "master"
# ~/code/web:master$ git checkout beta_directory
# Switched to branch "beta_directory"
const PKSupportsTouches = ("createTouch" in document);
const PKStartEvent = PKSupportsTouches ? "touchstart" : "mousedown";
const PKMoveEvent = PKSupportsTouches ? "touchmove" : "mousemove";
const PKEndEvent = PKSupportsTouches ? "touchend" : "mouseup";
function PKUtils() {}
PKUtils.assetsPath = "";
PKUtils.t = function (b, a) {
return "translate3d(" + b + "px, " + a + "px, 0)"
};
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
window.addEventListener "DOMContentLoaded", ->
body = $ "body"
canvas = $ "#canvas"
chalkboard = $ "#chalkboard"
close = $ "#close"
ledge = $ "#ledge"
lightswitch = $ "#lightswitch"
output = $ "#output"
shade = $ "#shade"
share = $ "#share"
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/)
// Then, use underscore's mixin method to extend it with all your other utility methods
// like so:
_.mixin({
escapeHtml: function () {
return this.replace(/&/g,'&amp;')
.replace(/>/g,'&gt;')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');
@elliot
elliot / RedirectRoute.yml
Created February 21, 2011 23:00
Using the redirect controller
default:
pattern: /
defaults: { _controller: FrameworkBundle:Redirect:redirect, route: frontend_index }
@elliot
elliot / gist:854614
Created March 4, 2011 13:30
Setting up TextMate for Twig syntax highlighting

Twig and Jinja share a common syntax, so to get syntax highlighting going in TextMate we are going to borrow one of the bundles already made for it.

Open up terminal and run the following:

mkdir -p ~/Library/Application\ Support/TextMate/Bundles
cd ~/Library/Application\ Support/TextMate/Bundles
git clone http://github.com/ozan/textmate-jinja-templates.git "Jinja Templates.tmbundle"
osascript -e 'tell app "TextMate" to reload bundles'

Next, jump into TextMate Bundle Editor (Ctrl+Opt+Cmd+B) and go to the Jinja Templates bundle, open the "HTML (Jinja Templates)" language and change the following line from

@elliot
elliot / Luhn.coffee
Created August 23, 2011 07:24
Luhn Algorithm in CoffeeScript
validateLuhn = (number) ->
odd = true
sum = _(number.split '').reduceRight (total, digit) ->
digit = parseInt(digit)
digit *= 2 if (odd = !odd)
digit -= 9 if digit > 9
total + digit
, 0
@elliot
elliot / fabfile.py
Created September 26, 2011 02:05 — forked from igorw/fabfile.py
from fabric.api import *
from fabric.utils import abort
from fabric.contrib.project import rsync_project
from fabric.contrib.files import exists
env.hosts = ['igor@igor.io']
target_dir = '/var/www/igor.io'
backup_dir = target_dir+'-backup'
staging_dir = target_dir+'-staging'