Skip to content

Instantly share code, notes, and snippets.

View awesome's full-sized avatar

So Awesome Man awesome

View GitHub Profile
@awesome
awesome / minitest template
Created January 21, 2009 00:25
minitest/unit template
#!/usr/bin/env ruby -w
require 'rubygems'
require 'minitest/unit'
$: << 'lib' << 'test'
require 'awesome'
MiniTest::Unit.autorun
class TestAwesome < MiniTest::Unit::TestCase
end
@awesome
awesome / unit methods
Created January 23, 2009 07:42 — forked from soawesomeman/gist:46666
minitest/unit methods
>> pp MiniTest::Unit::TestCase.instance_methods.sort - Object.methods
["_assertions",
"_assertions=",
"assert",
"assert_block",
"assert_empty",
"assert_equal",
"assert_in_delta",
"assert_in_epsilon",
"assert_includes",
@awesome
awesome / list_attr_accessor
Created January 26, 2009 20:27
list_attr_accessor
class Awesome
def list_attr_accessor
(self.methods - Object.instance_methods).map {|x| x.gsub(/=$/, "") if x =~ /=$/}.compact
end
end
# step 1
$ rake -T sessions
(in /Users/soawesomeman/uw/depot)
rake db:sessions:clear # Clear the sessions table
rake db:sessions:create # Creates a sessions migration for use with CGI::S...
rake tmp:sessions:clear # Clears all files in tmp/sessions
$ rake db:sessions:create
(in /Users/soawesomeman/uw/depot)
create db/migrate
create db/migrate/20090129030520_create_sessions.rb
>> require 'mini/mock'
>> Mini::Mock.instance_methods - Object.instance_methods
=> ["verify", "expect"]
<!-- the following is the output that thing produces, as requested by Eric Meyer here: http://www.tbray.org/ongoing/When/200x/2009/03/25/On-Rack#c1238071590.220874 -->
<html><head><title>Awesome</title></head><body><h2>Awesome</h2><ul><li><p>SERVER_NAME => localhost</p></li><li><p>rack.input => #<StringIO:0x11f32f8></p></li><li><p>rack.run_once => false</p></li><li><p>rack.url_scheme => http</p></li><li><p>HTTP_USER_AGENT => Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1</p></li><li><p>HTTP_ACCEPT_ENCODING => gzip, deflate</p></li><li><p>PATH_INFO => /foo</p></li><li><p>rack.errors => #<IO:0x2f7c4></p></li><li><p>HTTP_CACHE_CONTROL => max-age=0</p></li><li><p>HTTP_ACCEPT_LANGUAGE => en-us</p></li><li><p>HTTP_HOST => localhost:4321</p></li><li><p>SERVER_PROTOCOL => HTTP/1.1</p></li><li><p>SCRIPT_NAME => </p></li><li><p>REQUEST_PATH => /foo</p></li><li><p>SERVER_SOFTWARE => Mongrel 1.1.5</p></li><li><p>REMOTE_ADDR => 127.0.0.1</p
@awesome
awesome / config.ru
Created March 30, 2009 23:59 — forked from mtodd/config.ru
use Rack::Auth::Basic do |login, password|
# Account.find_by_login(login) returns a Hash:
# account = {:login => "dude", :password => "awesome"}
account = Account.find_by_login(login)
account.authenticate(password)
end
run Fuck
# so...
use Rack::Auth::Basic do |login, password|
# hash to query string
$ irb
>> hash = {1=>1,2=>2,3=>3}
=> {1=>1, 2=>2, 3=>3}
>> hash.to_a
=> [[1, 1], [2, 2], [3, 3]]
>> hash.to_a.map {|x| x.join("=")}.join("&")
=> "1=1&2=2&3=3"
# query string to hash
Given /^I visit subdomain (.+)$/ do |sub|
host! "#{sub}.#{TEST_DOMAIN}" #TEST_DOMAIN is defined in test.rb. In my case TEST_DOMAIN = 'example.com'
end

HOWTO: iPhone AT&T Tethering

In 10 steps:

  • Update iTunes to 8.2 via Software Update
  • Update your iPhone to the 3.0 release (out today - June 17th)
  • Download this dmg and mount it: tethering file
  • Enable hidden carrier testing option (in Terminal.app): defaults write com.apple.iTunes carrier-testing -bool TRUE
  • Start up iTunes