Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am rgarver on github.
  • I am rgarver (https://keybase.io/rgarver) on keybase.
  • I have a public key whose fingerprint is 773F 351C 993B 7C09 B76F 8352 CF75 7556 47E3 0778

To claim this, I am signing this object:

@rgarver
rgarver / gist:1490876
Created December 17, 2011 17:57
Why us SOPA bad? Why us SOPA bad? Why is SOPA bad?
Let's take the ideas in SOPA and apply them to the physical world to make them a bit more "concrete".
To combat robbery of mug makers, a majore problem particularly because the mug maker lobby is very strong, lawmakers have created a bill designed to make mug robbery less profitable. The idea is that if someone tries to use the mug by placing it on a table the mug maker could require that the table maker requisition the table so that the robber is not able to benefit from having a table on which to place the mug. A strong deterrent indeed. Now the mug makers don't need to provide any proof of the mugs illegal origins to anyone before requiring the table makers to jump in to action and remove all the tables of a house. Moreover, the identities of all accused people would need to be sent out to all stores that sell tables and then distributed to their employees to ensure that these accused criminals wouldn't be able to replace their tables.
Now, the table makers are in a pickle here because they can't rea
@rgarver
rgarver / gist:1483253
Created December 15, 2011 22:33
Rails/Haml code for iOS fancy images
= favicon_link_tag "Avalon_Fav_Icon_16.png", :type => "image/png"
= favicon_link_tag "Avalon_Fav_Icon_57.png", :rel => "apple-touch-icon", :type => "image/png"
= favicon_link_tag "Avalon_Fav_Icon_72.png", :rel => "apple-touch-icon", :size => "72x72", :type => "image/png"
= favicon_link_tag "Avalon_Fav_Icon_114.png", :rel => "apple-touch-icon", :size => "114x114", :type => "image/png"
= favicon_link_tag "Avalon_Loading_1024x748.png", :rel => "apple-touch-startup-image", :media => "screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)"
= favicon_link_tag "Avalon_Loading_768x1004.png", :rel => "apple-touch-startup-image", :media => "screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)"
= favicon_link_tag "Avalon_Loading_320x460.png", :rel => "apple-touch-startup-image", :media => "screen and (min-device-width: 200px) and (max-device-width: 320px) and (orientation:portrait)"
@rgarver
rgarver / routes.rb
Created February 4, 2011 17:30
if you constrain on protocol and want to redirect to fix if someone hits http instead of https, use this.
Rails::Application.routes.draw do
...
SecureTheRoute = lambda do |env|
request = ActionDispatch::Request.new(env)
dest = "http#{request.ssl? ? '' : 's'}://" + request.host_with_port + request.fullpath
begin
Profounder::Application.routes.recognize_path(dest)
[301, {'Location' => dest}, ["Redirecting to #{dest}"]]
# When in @javascript mode this will simulate clicking the back button on the browser. Uses capybara.
Then /^(?:|I )click the browser(?:|\'s)? back button$/ do
page.execute_script("history.back()")
end
class Capybara::Driver::RackTest::Node
def disabled?
self['disabled'] =~ /^(1|disabled)$/
end
end
-----> Installing gem curb from http://gemcutter.org, http://gems.rubyforge.org
Building native extensions. This could take a while...
ERROR: Error installing curb:
ERROR: Failed to build gem native extension.
/usr/ruby1.8.7/bin/ruby extconf.rb
"-g -O2 $(cflags)"
checking for curl-config... yes
checking for curlinfo_redirect_time... yes
checking for curlinfo_response_code... yes
/**
IMPORTANT: Requires this version of jquery
until 1.3.3 comes out http://gist.github.com/186325
ALSO: This is very dirty still and has not been
abstracted for use. It is just solving our immediate problems.
Use cases that must pass (and should be tested someday):
* Clicking on links updates layout
* Click around a bit and then use back/forward buttons
require 'json.red'
json = '{a:"a string"}'
o = Object.from_json(json)
o.a # => "a string"
# Paste me into spec_helper.rb, or save me somewhere else and require me in.
class BeValidXhtml
# require 'action_controller/test_process'
# require 'test/unit'
require 'net/http'
require 'md5'
require 'ftools'
def initialize