Skip to content

Instantly share code, notes, and snippets.

View schneems's full-sized avatar

Richard Schneeman schneems

View GitHub Profile
@schneems
schneems / aspen mri 1.8.6
Created March 7, 2012 23:16 — forked from hone/aspen mri 1.8.6
aspen/bamboo gem list
abstract (1.0.0)
actionmailer (2.3.5, 2.3.4, 2.3.3, 2.3.2, 2.2.2, 2.1.2, 2.1.0, 2.0.2)
actionpack (2.3.5, 2.3.4, 2.3.3, 2.3.2, 2.2.2, 2.1.2, 2.1.0, 2.0.2)
activerecord (2.3.5, 2.3.4, 2.3.3, 2.3.2, 2.2.2, 2.1.0, 2.0.2)
activeresource (2.3.5, 2.3.4, 2.3.3, 2.3.2, 2.2.2, 2.1.0, 2.0.2)
activesupport (2.3.5, 2.3.4, 2.3.3, 2.3.2, 2.2.2, 2.1.2, 2.1.0, 2.0.2)
acts_as_ferret (0.4.3)
addressable (2.0.2, 2.0.1)
amqp (0.6.7, 0.6.6)
aws-s3 (0.6.2)
@schneems
schneems / gist:2084471
Created March 18, 2012 23:13
Rack Cache on Cedar Rails 3.1+ Applications

Though slightly more complex, using a CDN is the most performant option for serving static assets. See the [CDN asset host](cdn-asset-host-rails31) article for more details.

Ruby on Rails applications should use Rack::Cache to efficiently serve assets on the Cedar stack. Proper Rack::Cache usage improves response time, decreases load and is important when serving static assets through your application.

This article will summarize the concepts of caching assets using Rack::Cache and walk you through the appropriate configuration of a Rails 3.1 application and the asset pipeline.

Sample code for this article's [reference application](https://github.com/heroku/rack-cache-demo) is available on

@schneems
schneems / gist:2210123
Created March 26, 2012 22:06
Remove File from Git Branch
# If you just want to remove a file called '/test/unit/user_test.rb' from your current branch it would look like this:
# Be wary not to use the --all option if you only want to act on the current branch
$ git checkout master
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch test/unit/user_test.rb' --prune-empty
@schneems
schneems / gist:2388789
Created April 14, 2012 23:58
Facebook page like
<div class="fb-like" data-href="http://www.facebook.com/hourschool"
data-send="false"
data-width="250"
data-show-faces="true"
style="margin-bottom: 20px">
</div>
@schneems
schneems / formatter.rb
Created May 3, 2012 18:47
Formatter Modifications
module Journey
###
# The Formatter class is used for formatting URLs. For example, parameters
# passed to +url_for+ in rails will eventually call Formatter#generate
class Formatter
attr_reader :routes
def initialize routes
@routes = routes
@cache = nil
@schneems
schneems / gist:2885779
Created June 7, 2012 00:46
Railties Test Suite
→ bundle exec rake
/Users/schneems/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby -Itest:lib:/Users/schneems/Documents/projects/rails/railties/../activesupport/lib:/Users/schneems/Documents/projects/rails/railties/../actionpack/lib:/Users/schneems/Documents/projects/rails/railties/../activemodel/lib test/application/asset_debugging_test.rb
Run options: --seed 56477
# Running tests:
/Users/schneems/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby /Users/schneems/.rvm/gems/ruby-1.9.3-rc1@railscore/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
..
Finished tests in 11.377043s, 0.1758 tests/s, 0.0000 assertions/s.
→ bundle exec rake test_sqlite3
/Users/schneems/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby -w -I"lib:test" -I"/Users/schneems/.rvm/gems/ruby-1.9.3-rc1@railscore/gems/rake-0.9.2.2/lib" "/Users/schneems/.rvm/gems/ruby-1.9.3-rc1@railscore/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/cases/adapter_test.rb" "test/cases/adapters/sqlite3/copy_table_test.rb" "test/cases/adapters/sqlite3/explain_test.rb" "test/cases/adapters/sqlite3/quoting_test.rb" "test/cases/adapters/sqlite3/sqlite3_adapter_test.rb" "test/cases/adapters/sqlite3/statement_pool_test.rb" "test/cases/aggregations_test.rb" "test/cases/ar_schema_test.rb" "test/cases/associations/belongs_to_associations_test.rb" "test/cases/associations/callbacks_test.rb" "test/cases/associations/cascaded_eager_loading_test.rb" "test/cases/associations/eager_load_includes_full_sti_class_test.rb" "test/cases/associations/eager_load_nested_include_test.rb" "test/cases/associations/eager_singularization_test.rb" "test/cases/associations/eager_test.rb" "test/cases/associati
@schneems
schneems / gist:2907252
Created June 10, 2012 20:42
Get variable name from variable
foo = 'i ama string'
var_type = defined? foo
variable_list = case var_type
when "local-variable"
local_variables
when "instance-variable"
instance_variables
when "global-variable"
@schneems
schneems / gist:2968840
Created June 21, 2012 22:02
Databases and Rails Recap Quiz for Week 2
## Week 3 Quiz
## 1) What does ORM stand for?
@schneems
schneems / gist:2968916
Created June 21, 2012 22:14
Ruby & Databases Recap Quiz for Week 2 [Solutions]
## Week 3 Quiz
## 1) What does ORM stand for?
Object Relationship Mapper