Navigation Menu

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
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use postgresql as the database for Active Record
gem 'pg'
# Use Haml for templates
gem 'haml-rails'
@rizwanreza
rizwanreza / gh_repo_stats.rb
Created June 24, 2013 20:59
Assuming all files are in the same folder, you can run the command like this: ./gh_repo_stats.rb --after 2012-11-01T13:00:00Z --before 2012-11-01T16:12:14Z --event PushEvent --count 42
#!/usr/bin/env ruby
# encoding: utf-8
require_relative 'github_archive'
require 'optparse'
# gh_repo_stats --after 2012-11-01T13:00:00Z --before 2012-11-02T03:12:14-03:00 --event PushEvent --count 42
options = {}
OptionParser.new do |opts|
#!/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 / 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 / gist:1669832
Created January 24, 2012 12:02
debugger
require 'ruby-debug'; Debugger.start; Debugger.settings[:autoeval] = 1; Debugger.settings[:autolist] = 1; debugger
@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