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
# Created by Nando Vieira | |
# Usage: compound_interest(:amount => 1000, :interest => 0.1, :times => 5) | |
def compound_interest(options={}) | |
options[:amount] * ((1 + options[:interest]) ** options[:times]) | |
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
repeat with theApp in {"iTerm", "TextMate", "Safari"} | |
tell application theApp | |
activate | |
set the bounds of the first window to {0, 540, 960, 1080} | |
end tell | |
end repeat |
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
// Load dependencies | |
var app = require("./lib/server").createServer(), | |
sys = require("sys"); | |
// Start app server | |
app.listen(3002); | |
app.get("/:name", function(req, res){ | |
res.render("Hello " + req.params.name); | |
}); |
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
raise "Check #{__FILE__} and http://bit.ly/9IK52W to see if this hack is still needed." if Rails.version > "3.0.0" | |
class ActionController::Base | |
private | |
alias :_compute_redirect_to_location_original :_compute_redirect_to_location | |
def _compute_redirect_to_location(options) | |
case options | |
when Proc | |
_compute_redirect_to_location instance_eval(&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 Achievement | |
class << self | |
attr_accessor :all | |
end | |
self.all = [] | |
attr_accessor :badge | |
def initialize(badge) | |
@badge = badge |
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
module DatabaseCleaner | |
def self.clean | |
Array.new.tap do |cache| | |
ActiveRecord::Base.descendants.each do |model| | |
next if cache.include?(model.table_name) | |
cache << model.table_name | |
table_name = ActiveRecord::Base.connection.quote_table_name(model.table_name) | |
ActiveRecord::Base.connection.execute "TRUNCATE TABLE #{table_name}" | |
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 Token | |
VOWELS = %w[a e i o u] | |
CONSONANTS = ("a".."z").to_a - VOWELS | |
NUMBERS = (0..9).to_a | |
def self.readable(size = 12) | |
String.new.tap do |s| | |
half = size / 2 | |
1.upto(size) do |i| |
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
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> | |
<script type="text/javascript"> | |
if (typeof jQuery === "undefined") { | |
document.write(unescape("%3Cscript src='<%= compute_public_path("jquery-1.4.4.min.js", "javascripts") %>' type='text/javascript'%3E%3C/script%3E")); | |
}; | |
</script> |
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 String | |
def unindent | |
_, spaces = *match(/^([\t ]+)/) | |
spaces ? gsub(%r[^#{spaces}]ms, "") : self | |
end | |
end | |
html = <<-CODE.unindent | |
THIS IS JUST A TEST | |
AND THIS A TEXT SNIPPET THAT SHOULD |
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 tags = "abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video".split("|"); | |
for (var i = 0, tag; tag = tags[i]; i++) { document.createElement(tag); } | |
})(); |
OlderNewer