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
# original found at http://pastie.textmate.org/143799 | |
#RUBYISMS | |
a = b.foo | |
if a.empty? | |
a = b.bar | |
else | |
a.reverse! | |
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 Comment < ActiveRecord::Base | |
belongs_to :post | |
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
#!/usr/bin/env ruby | |
# Complete rake tasks script for bash | |
# Save it somewhere and then add | |
# complete -C path/to/script -o default rake | |
# to your ~/.bashrc | |
# Xavier Shay (http://rhnh.net), combining work from | |
# Francis Hwang ( http://fhwang.net/ ) - http://fhwang.net/rb/rake-complete.rb | |
# Nicholas Seckar <[email protected]> - http://www.webtypes.com/2006/03/31/rake-completion-script-that-handles-namespaces | |
# Saimon Moore <[email protected]> |
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
<%= javascript_include_tag 'jquery', 'jquery-ui' %> | |
<% if protect_against_forgery? %> | |
<script type='text/javascript'> | |
//<![CDATA[ | |
window._auth_token_name = "#{request_forgery_protection_token}"; | |
window._auth_token = "#{form_authenticity_token}"; | |
//]]> | |
</script> | |
<% 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
# Run rake db:size to get a print of your database size in bytes. | |
# Run rake db:tables:size to get the sizes for individual tables | |
# Works for MySQL and PostgreSQL. Not tested elsewhere. | |
namespace :db do | |
desc 'Print data size for entire database' | |
task :size => :environment do | |
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database] | |
adapter = ActiveRecord::Base.connection.adapter_name.downcase |
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
# include at least one source and the rails gem | |
source :gemcutter | |
gem "rails", "~> 2.3.5", :require => nil | |
gem "sqlite3-ruby", :require => "sqlite3" | |
# Devise 1.0.2 is not a valid gem plugin for Rails, so use git until 1.0.3 | |
# gem "devise", :git => "git://github.com/plataformatec/devise.git", :ref => "v1.0" | |
group :development do | |
# bundler requires these gems in development |
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
require 'rubygems' | |
# http://github.com/archiloque/rest-client | |
require 'rest_client' | |
# STARTED | |
# set game with hash_code 'game_hash123' as started | |
RestClient.post "http://localhost:3000/games/game_hash123/started", { '_method' => 'put', 'user_credentials' => 'xH31MpM8xSff3em8LwGJ' }, :content_type => :json, :accept => :json | |
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
require 'cgi' | |
def html2text html | |
text = html. | |
gsub(/( |\n|\s)+/im, ' ').squeeze(' ').strip. | |
gsub(/<([^\s]+)[^>]*(src|href)=\s*(.?)([^>\s]*)\3[^>]*>\4<\/\1>/i, | |
'\4') | |
links = [] | |
linkregex = /<[^>]*(src|href)=\s*(.?)([^>\s]*)\2[^>]*>\s*/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
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
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
Failures: | |
1) ThemeAsset attaching a file file is a picture should process picture | |
Failure/Error: @asset.source = FixturedAsset.open('5k.png') | |
NameError: | |
uninitialized constant Magick | |
# ./lib/locomotive/carrierwave/asset.rb:56:in `set_width_and_height' | |
# ./spec/models/theme_asset_spec.rb:17 | |
2) ThemeAsset attaching a file file is a picture should get width and height from the image |
OlderNewer