This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//sometimes, you just want the copy inside an element. | |
function $T(element) { | |
var t = $(element); | |
return t == null ? t : t.innerHTML.gsub(/<\/?[^>]*>/, ''); | |
} | |
//is fetching the innerHTML bad form? Most of the time, yeah. | |
function $M(element) { | |
var m = $(element); | |
return m == null ? m : m.innerHTML; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @author jnf http://github.com/jnf | |
* other_select, when attached to a select box, pops a sibling input field with similar | |
* attributes. Use it to record user input that falls outside the options provided in a | |
* select box. | |
*/ | |
$.fn.other_select = function(options) { | |
var defaults = { | |
speed: 'normal', //rate at which the alternate input field appears/disappears | |
nameSuffix: '_other', //suffix appended to the alternate input's name attribute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function($) { | |
var interpolate = function (source, target, shift) { | |
return (source + (target - source) * shift); | |
}; | |
var easing = function (position) { | |
return (-Math.cos(position * Math.PI) / 2) + .5; | |
}; | |
$.scrollBoth = function(XY, duration, easingF) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Story < ActiveRecord::Base | |
... | |
before_save :setColor | |
... | |
private | |
def setColor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
require 'uri' | |
desc "Uses heroku:config for APP to forcefully create ~/.pgpass" | |
task :create_pgpass do | |
app = ENV['APP'] || 'whatever-your-default-app-is' | |
uri = URI(`heroku config:get DATABASE_URL -a #{app}`) | |
entry = "*:5432:#{uri.path.gsub /\//, ''}:#{uri.user}:#{uri.password}" | |
`echo '#{entry}' > ~/.pgpass; chmod 0600 ~/.pgpass` | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
pretty = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative | |
ll = log --stat --abbrev-commit | |
d = diff --color-words | |
s = status | |
[color] | |
ui = auto | |
[color "branch"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//generic tag helpers | |
Handlebars.registerHelper('generic_tag', function(tag, text, options) { | |
var attrs = []; | |
for(var prop in options.hash) { attrs.push(prop + '="' + options.hash[prop] + '"'); } | |
return new Handlebars.SafeString( "<" + tag + " " + attrs.join(" ") + ">" + text + "</" + tag + ">" ); | |
}); | |
Handlebars.registerHelper('generic_selfclosing_tag', function(tag, options) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def play_turn(warrior) | |
@prev_health ||= 20 | |
@warrior = warrior | |
@space = @warrior.feel | |
feel_it_out | |
@prev_health = warrior.health | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
helpers do | |
def icon_tag(icon, copy) | |
tag(:i, class: icon) + ' ' + copy | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def play_turn(warrior) | |
@warrior = warrior | |
@preferred_direction = @warrior.direction_of_stairs | |
wat_do? | |
end | |
protected | |
OlderNewer