Skip to content

Instantly share code, notes, and snippets.

class SumOfFactors
def initialize(until_num, *divisible_by)
@until_num = until_num
@divisible_by = divisible_by
end
def get_sum
get_range.collect { |num| num if divisible? num }.compact.inject :+
end
@rizwanreza
rizwanreza / chef_solo_bootstrap.sh
Created April 8, 2012 17:11 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
make install
@rizwanreza
rizwanreza / config.ru
Created February 29, 2012 17:49
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
require "rails"
# Let's load only action controller. If you want
# to use active record, just require it as well.
require "action_controller/railtie"
class MyApp < Rails::Application
@rizwanreza
rizwanreza / Gemfile
Created October 11, 2011 15:37 — forked from chriseppstein/readme.md
How to integrate Compass with Rails 3.1 asset pipeline
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
gem 'compass', '~> 0.12.alpha'
# include other compass plugins here. E.g.:
gem 'compass-susy-plugin', :require => 'susy'
end
@rizwanreza
rizwanreza / gist:1015442
Created June 8, 2011 21:25 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@rizwanreza
rizwanreza / cucumber_disable_gc.rb
Created June 1, 2011 01:11 — forked from bru/cucumber_disable_gc.rb
GC tweak to speed up Cucumber tests
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 1.0).to_f
@@last_gc_run = Time.now
Before do
begin_gc_deferment
end
After do
reconsider_gc_deferment
@rizwanreza
rizwanreza / gist:950502
Created May 1, 2011 13:32
This is how I test the pull request
Given you're testing this pull request: https://github.com/rails/rails/pull/338
You'll found out that the commit is from 'smartinez87'
[master][~/Projects/rails] git remote add smartinez87 https://github.com/smartinez87/rails.git
[master][~/Projects/rails] git remote show smartinez87
* remote smartinez87
Fetch URL: https://github.com/smartinez87/rails.git
Push URL: https://github.com/smartinez87/rails.git
HEAD branch: master
Remote branches:

A replacement for "livereload" gem on OS X

This script is a replacement for livereload server component designed for working with Rails. It watches the filesystem with FS Events (Mac OS X) rather than with EventMachine. This is better for large projects for wich EventMachine fails with "too many open files" exception.

Sass is supported; .sass files can also be stored in "app/styles/" directory. Compass is detected if "config/compass.rb" file exists.

Installation:

Download this script to somewhere in your PATH and make it executable. You can name it something different than "livereload" if you want to try this and the official gem executable in parallel.

//** Vertical Rhythm **//
// By Chris Eppstein and Eric Meyer, living here on a temporary basis
// set the default border style for rhythm borders
!default_rhythm_border_style = "solid"
// The IE font ratio is a fact of life. Deal with it.
!ie_font_ratio = 16px / 100%
#!/usr/bin/env ruby
# Written by Kieran P
# http://github.com/KieranP
# http://twitter.com/k776
# http://k776.tumblr.com
#
# Feel free to fork and modify.
# If you do, send me a message on
# Github details changes and I'll