Skip to content

Instantly share code, notes, and snippets.

View rmm5t's full-sized avatar
🌐
building itsy bitsy parts of the internet that grow

Ryan McGeary rmm5t

🌐
building itsy bitsy parts of the internet that grow
View GitHub Profile
# Courtesy @zenspider
# http://exercism.io/submissions/b0613bbac84cd95fcad40e6b
class Hamming0
def self.compute s1, s2
length = [s1.length, s2.length].min
length.times.count { |i| s1[i] != s2[i] }
end
end
@rmm5t
rmm5t / Gemfile
Created September 23, 2014 15:33
font-awesome-rails issues #113 support
source 'https://rubygems.org'
ruby '2.1.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
gem 'sqlite3'
## Assets
gem "sprockets-rails", "~> 2.1.3"
# Use SCSS for stylesheets
@rmm5t
rmm5t / 0_README.md
Last active December 19, 2015 03:38 — forked from DanielWright/0_README.md

ruby-1.9.3-p448 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p448 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@rmm5t
rmm5t / euler010.rb
Created April 25, 2013 23:47
Solution to Project Euler #10 http://projecteuler.net/problem=10
#!/usr/bin/env ruby
# http://projecteuler.net/problem=10
require "prime"
max = (ARGV[0] || 2_000_000).to_i
print "Sum of primes below #{max}: "
puts Prime.each(max - 1).inject(&:+)
@rmm5t
rmm5t / perf.md
Last active December 14, 2015 08:28
Slow Rails startup time with ruby 1.9.3-p392

Ruby 1.9.3-p392

$ time script/rails console
Loading development environment (Rails 3.2.12)
>> ^D

real    0m7.363s
user    0m6.352s
sys 0m0.919s
@rmm5t
rmm5t / stop_words.rb
Created September 18, 2012 18:49
stop words
StopWords = %w(a able about above abroad according accordingly across actually
adj after afterwards again against ago ahead ain't all allow allows almost
alone along alongside already also although always am amid amidst among
amongst an and another any anybody anyhow anyone anything anyway anyways
anywhere apart appear appreciate appropriate are aren't around as a's aside
ask asking associated at available away awfully b back backward backwards be
became because become becomes becoming been before beforehand begin behind
being believe below beside besides best better between beyond both brief but
by c came can cannot cant can't caption cause causes certain certainly changes
clearly c'mon co co. com come comes concerning consequently consider
@rmm5t
rmm5t / app_cache.js.coffee
Created February 1, 2012 02:43
Debugging HTML 5 Application Cache
# Application Cache Debugging and Handling
#
# Inspired by Jonathan Stark's Debugging HTML 5 Offline Application Cache
# http://jonathanstark.com/blog/2009/09/27/debugging-html-5-offline-application-cache/
cacheStatusValues = [
"uncached"
"idle"
"checking"
"downloading"
@rmm5t
rmm5t / controllers.rb
Created January 5, 2012 17:13
Custom Shoulda Controller Macros
class ActionController::TestCase
[:get, :post, :put, :delete].each do |method|
class_eval <<-RUBY
def self.on_#{method}(action, options = {}, &block)
on_http_method(#{method.inspect}, action, options, &block)
end
def self.should_404_on_#{method}(action, options = {}, &block)
should_404_on_http_method(#{method.inspect}, action, options, &block)
end
@rmm5t
rmm5t / assets.rake
Created December 7, 2011 15:40
Precompile assets on Heroku with Mongoid
# The premise behind this was borrowed from https://gist.github.com/1239732
namespace :assets do
# Prepend the assets:prepare task to assets:precompile through
# assets:environment
task :environment => :prepare
task :prepare do
# Flag for custom initializers to know we're precompiling assets
ENV["RAILS_ASSETS_PRECOMPILE"] = "true"
@rmm5t
rmm5t / coffeescript.md
Created September 19, 2011 23:40
Brief Intro to CoffeeScript

CoffeeScript

CoffeeScript is a light language that compiles down to JavaScript. Because it is a language that compiles to another language, some might classify it as a "transcompiler" instead of just a compiler. CoffeeScript's syntax is heavily inspired by Python and Ruby. For the most part, statements in CoffeeScript correspond one-to-one with their equivalent in JavaScript.

CoffeeScript was created out of love for the JavaScript language, but also out