Skip to content

Instantly share code, notes, and snippets.

View steveklabnik's full-sized avatar
🦀
Rustacean

Steve Klabnik steveklabnik

🦀
Rustacean
View GitHub Profile
@steveklabnik
steveklabnik / gist:3933232
Created October 22, 2012 18:30
Link_to trickiness
%li.search-business
= link_to(searches_path(:t => "1")) do
%i.icon-star
Business
@steveklabnik
steveklabnik / reading.md
Last active August 16, 2024 08:03
intro to continental philosophy reading list (french post-structuralism, etc)
@steveklabnik
steveklabnik / pair
Created November 9, 2012 13:09
A ruby script to change pairs
#!/usr/bin/env ruby
def usage
puts "./pair [name]: pair two people"
puts "./pair : switch to just steve"
exit
end
def set_config(name, email)
`git config user.name "#{name}"`
@steveklabnik
steveklabnik / template.rb
Created November 17, 2012 05:51
rails app template yo
run "rm public/index.html"
run "sed '3d' Gemfile > Gemfile" # remove rails line
gem "rails", :github => "rails/rails", :branch => "master"
# git :init
# git :add => "."
# git :commit => %Q{ -m 'Initial commit' }
@steveklabnik
steveklabnik / britruby.md
Created November 23, 2012 01:42
BritRuby history

since they took it down, from http://webcache.googleusercontent.com/search?q=cache%3Ahttp%3A%2F%2F2013.britruby.com%2F&rlz=1C1CHFA_enUS484US486&oq=cache%3Ahttp%3A%2F%2F2013.britruby.com%2F&aqs=chrome.0.57j58j61.1127&sugexp=chrome,mod=15&sourceid=chrome&ie=UTF-8

Personal statement from the founder of BritRuby

The last 48hrs has been a whirlwind of discussions and speculations as to why I decided to retract BritRuby. It seems that the point has been missed and I’d like to take the opportunity to put the record straight.

At BritRuby our mission statement was clear. We wanted to run a conference like no other before on British soil to enhance and inspire developers within the Ruby community. We wanted to have fun, exchange ideas, boost jobs, network and we hoped to inspire students to join the industry. So what went wrong?

Firstly, I would like to categorically state that none of our sponsors had officially pulled out of the conference. Running a conference of this magnitude takes time, effort and money.

iff --git a/actionpack/lib/action_dispatch/middleware/remote_ip.rb b/actionpack/lib/action_dispatch/middleware/remote_ip.rb
index 5abf8f2..8d986e8 100644
--- a/actionpack/lib/action_dispatch/middleware/remote_ip.rb
+++ b/actionpack/lib/action_dispatch/middleware/remote_ip.rb
@@ -95,7 +95,7 @@ module ActionDispatch
client_ips.first
else
# If there is no client ip we can return first valid proxy ip from REMOTE_ADDR
- remote_addrs.find { |ip| valid_ip? ip }
+ [remote_addrs, client_ip, forwarded_ip].flatten.find { |ip| valid_ip? ip }
@steveklabnik
steveklabnik / pair.rb
Created December 1, 2012 04:37
pair stuffs yo
#!/usr/bin/env ruby
def usage
puts "./pair [name]: pair two people"
puts "./pair : switch to just steve"
exit
end
def set_config(name, email)
`git config user.name "#{name}"`
@steveklabnik
steveklabnik / event_manager.rb
Created December 2, 2012 15:16 — forked from jjwanat/event_manager.rb
Problem with "clean_number" refactor
def print_numbers
@file.each do |line|
number = clean_number([:homephone])
puts number
end
end
def clean_number(original)
number = number.delete(".").delete("-").delete(" ").delete("(").delete(")")
#There must be a shorter way to deal with this..?
@steveklabnik
steveklabnik / stub_getch_print.rb
Created December 9, 2012 02:36
Stubbing getch/print in minitest
STDIN.stub :getch, "a" do
STDOUT.stub :print, nil do
c = STDIN.getch
print "c is #{c}"
STDOUT.print c
end
end
@steveklabnik
steveklabnik / some_test.rb
Created December 9, 2012 02:58
Ugly, but works.
# ugly, but works
def test_eval_display_node
mock = MiniTest::Mock.new.expect(:print, nil, ["H"])
redefine_constant("STDOUT", mock) do
ast = 72.times.collect { Mojikun::ThumbsUpNode.new }
ast << Mojikun::DisplayNode.new