Skip to content

Instantly share code, notes, and snippets.

View matthutchinson's full-sized avatar
🧐
`¯\_(ツ)_/¯`

Matthew Hutchinson matthutchinson

🧐
`¯\_(ツ)_/¯`
View GitHub Profile
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
require "uri"
(URI::REGEXP.constants - ["PATTERN"]).each do |rc|
puts "#{rc}: #{URI::REGEXP.const_get(rc)}"
end
URI::REGEXP::PATTERN.constants.each do |pc|
puts "#{pc}: #{URI::REGEXP::PATTERN.const_get(pc)}"
end
@gruber
gruber / inline2ref.rb
Created September 9, 2011 21:25 — forked from ttscoff/inline2ref.rb
Convert inline Markdown links to references
#!/usr/bin/env ruby
def e_sh(str)
str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/n, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
end
def find_headers(lines)
in_headers = false
lines.each_with_index {|line, i|
if line =~ /^\S[^\:]+\:( .*?)?$/
@schacon
schacon / gist:942899
Created April 26, 2011 19:19
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
@dhrrgn
dhrrgn / pow_port.rb
Created April 8, 2011 21:20
Quickly and easily change the port that Pow is running on. This allows you too run Apache and Pow side-by-side (on different ports of course).
#!/usr/bin/env ruby
# Pow Port
#
# Quickly and easily change the port that Pow is running on. This allows
# you too run Apache and Pow side-by-side (on different ports of course).
#
# WARNING: This will OVERWRITE your ~/.powconfig file. If you have custom
# configurations in there, please back it up first.
#
@mikhailov
mikhailov / ruby_gc.sh
Created March 11, 2011 10:33
Ruby’s GC Configuration
- http://www.coffeepowered.net/2009/06/13/fine-tuning-your-garbage-collector/
- http://snaprails.tumblr.com/post/241746095/rubys-gc-configuration
article’s settings: ("spec spec" took 17-23!sec)
export RUBY_HEAP_MIN_SLOTS=1250000
export RUBY_HEAP_SLOTS_INCREMENT=100000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=30000000
export RUBY_HEAP_FREE_MIN=12500
anonymous
anonymous / oshi.rb
Created July 8, 2010 08:18
require 'rubygems'
require 'eventmachine'
require 'em-websocket'
require 'json'
class Connection
attr_accessor :socket, :user_id
def initialize(socket, user_id)
@socket = socket