Skip to content

Instantly share code, notes, and snippets.

@biscuitvile
biscuitvile / rename.rake
Created March 9, 2012 12:53 — forked from ebot/rename.rake
A Rails 3 rake task for renaming the application
namespace 'rails' do
desc 'Renames the current app'
task 'rename' do
# Get the new name
new_name = ENV["NEW_NAME"].capitalize || nil
if new_name.nil?
puts "\nYou must pass in a new name"
exit
end
@biscuitvile
biscuitvile / will_paginate.rb
Created March 12, 2012 18:37 — forked from isaacbowen/will_paginate.rb
extends will_paginate to play well with Twitter's Bootstrap
# config/initializers/will_paginate.rb
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
@biscuitvile
biscuitvile / simple_form.rb
Created April 6, 2012 23:36 — forked from seyhunak/simple_form.rb
Using simple_form and integrating Twitter Bootstrap
1. Use latest build
gem 'simple_form', :git => 'git://github.com/plataformatec/simple_form.git'
2. Create an initializer
# /config/initializers/simple_form.rb
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a complete input.
# You can remove any component from the wrapper, change the order or even
@biscuitvile
biscuitvile / rails-backbone-test-setup.md
Created May 1, 2012 15:44 — forked from smakman/rails-backbone-test-setup.md
Setting up a Rails backbone project with Jasmine, RSpec, Capybara, Guard and Spork

Rails backbone test setup

This gist describes how to setup a rails backbone project with testing frameworks.

Gemfile

Example Gemfile to start with.

@biscuitvile
biscuitvile / character_reference.rb
Created May 2, 2012 15:52 — forked from norman/character_reference.rb
HTML entities? We don't need no stinkin' HTML entities.
# coding: utf-8
#
# Encode any codepoint outside the ASCII printable range to an HTML character
# reference (http://bit.ly/KNupLT).
def encode(string)
string.each_codepoint.inject("") do |buffer, cp|
cp = "&#x#{cp.to_s(16)};" unless cp >= 0x20 && cp <= 0x7E
buffer << cp
end
end
@biscuitvile
biscuitvile / gist:2698899
Created May 15, 2012 03:39 — forked from palexander/gist:1375271
Remove a password from Git's history
# Sync with the remote master
git pull
# Force your clone to look like HEAD
git reset --hard
# AGAIN, A WARNING: This can really break stuff!
# Run your filter branch command, replacing all instances of "password" with "your_password"
# The example looks for Ruby files ("*.rb"), you can change this to match your needs
@biscuitvile
biscuitvile / .rspec
Created June 10, 2012 13:45 — forked from coreyhaines/.rspec
Loading just active record
--colour
-I app
@biscuitvile
biscuitvile / bowling.rb
Created June 26, 2012 15:27 — forked from steveklabnik/bowling.rb
Bowling kata
class Game
attr_reader :rolls
def initialize(rolls)
@rolls = rolls
end
def score
frames.inject(0) do |score, frame|
score += FrameScorer.new(frame).score
@biscuitvile
biscuitvile / Guardfile
Created July 27, 2012 01:34 — forked from okonet/Guardfile
Example of a Guardfile
guard 'coffeescript', :input => 'app', :output => 'public/javascripts/app', :cli => ''
guard 'coffeescript', :input => 'spec/coffeescripts', :output => 'spec/javascripts'
guard 'compass' do
watch(/app\/stylesheets\/(.*)\.s[ac]ss/)
end
spec_location = "spec/coffeescripts/%s_spec"
guard 'jasmine-headless-webkit' do
watch(%r{^spec/coffeescripts/(.*)_spec\..*}) { |m| newest_js_file(spec_location % m[1]) }
@biscuitvile
biscuitvile / foo_controller.rb
Created August 6, 2012 13:28 — forked from lloeki/foo_controller.rb
Streaming (CSV) data in Rails 3.2
class FooController
respond_to :csv
def index
@foos = Foo.scoped
if stale?(:last_modified => Foo.something)
respond_with @gta do |format|
format.csv { stream_csv @foo }
end
end