Skip to content

Instantly share code, notes, and snippets.

View taybenlor's full-sized avatar

Ben Taylor taybenlor

View GitHub Profile
@taybenlor
taybenlor / gist:1136354
Created August 10, 2011 08:14
Too Many Pixies Enemy Update
update: ->
if @converting
this.convert() if ((ticks - @started_converting) > CONVERT_TIME)
else if (ticks - @moved_at) > SPEED[@type]
this.move()
@taybenlor
taybenlor / gist:1156110
Created August 19, 2011 05:22
Sinatra with Heroku
config.ru
------------------------
require './hello'
run Sinatra::Application
Gemfile
------------------------
source "http://rubygems.org"
gem "rack", "~>1.1"
@taybenlor
taybenlor / placeholder.js
Created September 28, 2011 08:07
Placeholder JQuery Thingo for Matt
(function($) {
//This represents a "Placeholder"
var Placeholder = function($element, options){
//set up our placeholder
this.options = options || {};
this.$input = $element;
this.$placeholderText = this.input.attr('placeholder');
this.$placeholder = $('<div class="placeholder">')
.css({
@taybenlor
taybenlor / sort.py
Created November 17, 2011 12:37
Python Golf Sort
def s(l):
if len(l)<2:return l
return [l.pop(l.index(min(l)))] + s(l)
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
BPMS = (60/104) * 1000
HEART_POS = 200
FUDGE = 50
class Game
constructor: (@song, @pane) ->
PS1="\[\033[0;37m\][\@] \[\033[0;32m\]\u@\h\[\033[0;36m\]:\w\$\[\033[0m\] "
alias ls='ls -FG'
alias l='ls -laF'
export LSCOLORS="cxfxcxdxbxegedabagacad"
function fib(n){
if(n < 2) return 1;
if(fib[n]) return fib[n];
return fib[n] = fib(n-1) + fib(n-2);
}
int maxlen = max(a.length, b.length, c.length);
for(int i = 0; i < maxlen; i++){
int ai = max(a.length - i, 0);
int bi = max(b.length - i, 0);
int ci = max(c.length - i, 0);
//dostuff
}
$("#somelink").on("click", function(){
$("#somediv").show();
$("#anotherdiv").hide():
$("#athirddiv").hide();
});
@taybenlor
taybenlor / gist:2011217
Created March 10, 2012 11:45
Wong likes pie
def price
return @price if @price
@price = Money.new(self.cents || 0, self.some_relationship.currency || Money.default_currency)
end
def price=(new_price)
@price = new_price.to_money
self.cents = @price.cents
self.some_relationship.currency = @price.currency_as_string
end