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
# I hear that aliasing lambda is bad, but this is | |
# much more readable... | |
alias :this_block :lambda | |
this_block{ @this.destroy }.should change(Thing, :count).by(-1) |
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
#!/usr/bin/perl | |
# Present.ly Post-Commit Hook for Git | |
# change your subdomain, username and password, then copy this file as .git/hooks/post-commit | |
# then 'chmod +x .git/hooks/post-commit' | |
# it'll run every time you commit (not push, mind you) | |
$project='Project Name' | |
$subdomain='yoursubdomain' | |
$username='username'; |
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
>> ActionController::UrlWriter.default_url_options | |
=> {:host=>nil} | |
>> ActionController::UrlWriter.default_url_options[:host] = 'abc.com' | |
=> "abc.com" | |
>> ActionController::UrlWriter.default_url_options[:host] | |
=> "abc.com" | |
>> |
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
// ==UserScript== | |
// @name Twitter Search Plus | |
// @namespace intridea | |
// @description Find replies to a tweet in the Twitter Search timeline with the click of a button. | |
// @include http://search.twitter.com/search* | |
// ==/UserScript== | |
// Add jQuery | |
var GM_JQ = document.createElement('script'); | |
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; |
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
jQuery.githubUser = function(username, callback) { | |
jQuery.getJSON("http://github.com/api/v1/json/" + username + "?callback=?", callback); | |
} | |
$.githubUser('mbleigh', function(data) { | |
$('#github-projects').html(''); | |
var repos = data.user.repositories; | |
repos.sort(function(a,b) { | |
return b.watchers - a.watchers; |
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
Autotest.add_hook :initialize do |at| | |
at.add_mapping(/app\/shared\/.*\.rb/) do | |
at.files_matching /^app\/shared\/spec\/(models)\/.*_spec\.rb/ | |
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
app_name = ask("What is your application called?") | |
puts "\nBefore this generator runs you will need to register your Twitter application for OAuth at http://twitter.com/oauth_clients, then enter the consumer key and secret below:\n\n" | |
consumer_key = ask("OAuth Consumer Key:") | |
consumer_secret = ask("OAuth Consumer Secret:") | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "rm README" | |
run "cp config/database.yml config/database.yml.example" |
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 User < TwitterAuth::GenericUser | |
def refresh_twitter_attributes! | |
update_twitter_attributes(twitter.get('/account/verify_credentials')) | |
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
# OptionsProxy creates a proxy object with attribute accessors | |
# and defaults. | |
options = OptionsProxy.new(:fancy, :name, { | |
:fancy => true | |
}) | |
options.fancy # => true | |
options.name # => nil |
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
# Let's say we have this: | |
class User < ActiveRecord::Base | |
has_many :posts | |
end | |
class Post < ActiveRecord::Base | |
belongs_to :user | |
end |
OlderNewer