methodhead's posterous http://blog.methodhead.com Most recent posts at methodhead's posterous posterous.com Thu, 12 May 2011 18:57:25 -0700 Excon: a sane alternative to Net::HTTP http://blog.methodhead.com/52857831 http://blog.methodhead.com/52857831

Here’s how I use Net::HTTP:

# It rubs the lotion on its skin. It does this whenever it's told.
url = URI.parse('http://www.google.com/')

# It rubs the lotion on its skin or else it gets the hose again.
# Ruff! Yes it will, precious, it will get the hose.
File.open('result.txt', 'w') {|f|

  # It places the lotion in the basket.
  res = Net::HTTP.start(url.host, url.port) {|http|

    # Now it places the lotion in the basket.
    http.get('/') do |str|

      # PUT THE FUCKING LOTION IN THE BASKET!
      f.write str
    end
  }
}

Excon is a pleasant alternative to Net::HTTP written by Wesley Beary (@geemus). It has a simple API:

# get
Excon.get("http://localhost:4567/").body

# get with headers
Excon.get(
  "http://localhost:4567/",
  :headers => {"User-Agent", "Excon"})

# get chunked
Excon.get("http://localhost:4567/") do |chuck|
  puts chunk
end

# keep-alive
@connection = Excon.new("http://localhost:4567")
@connection.request(:method => "GET", :path => "/foo")
@connection.request(:method => "GET", :path => "/bar")

Mocking is built in:

Excon.mock = true

# any request returns Hello
Excon.stub({}, {:body => "Hello"})

# be more specific about the request
Excon.stub({:path => "/foo"}, {:body => "Foo"})

Though it doesn’t support posting form data from a simple hash or multipart file uploads:

puts Excon.post("http://localhost:4567/", :body => "foo=bar&wam=bam")

I haven’t benchmarked anything, but it has performed well for me. Also, it’s compatible with Windows out of the box, an issue with curb.

Give it a try.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Sat, 02 Apr 2011 18:10:00 -0700 RubyNation Recap http://blog.methodhead.com/rubynation-recap http://blog.methodhead.com/rubynation-recap

I enjoyed RubyNation this year. The small size makes it easier to get to know both local developers and bigger names in the Ruby community.

A highlight for me was @geemus’s talk on Fog, a high level API for deploying to a good number of cloud services like Amazon and Rackspace. I’m super late to the cloud game, but it seems we could take some pain out of managing our QA and stage environments at Razoo by deploying them to the cloud. Phrases like “deploying to the cloud” are grinding my nerves though.

Another highlight was the Ruby for Kids session. 10 kids joined volunteers from the conference, including yours truly, to hack on a game they’ve been building with gosu. These kids are 10 to 14 years old and using Macs, TextMate, Terminal, Git, and Ruby! If we can avoid destroying the planet, the future is certainly bright.

shooter

As with every conference, I was inspired by the creative energy. I’m going to update my illustrious croc gem, which is useless now that RVM is standard operating procedure.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Sat, 05 Feb 2011 22:24:00 -0800 Making RVM work with Zsh and Vim http://blog.methodhead.com/42129584 http://blog.methodhead.com/42129584

I’m not going to say how long it took me to figure this out. I wanted RVM to work with Zsh and Vim. But when I ran ruby commands with :! or :sh, it would always use the system ruby, not the ruby I had selected with RVM.

Here’s what finally worked:

  1. I added SHELL=/bin/zsh and [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" to ~/.zshrc
  2. I commented out the path_helper stuff in /etc/zshenv

This makes Vim run zsh instead of bash when running shell commands and prevents Apple’s path_helper utility from rearranging PATH when zsh is run.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Sun, 05 Dec 2010 13:31:00 -0800 How I'm Doing Inbox Zero http://blog.methodhead.com/how-im-doing-inbox-zero http://blog.methodhead.com/how-im-doing-inbox-zero

I’m a Gmail user. I used to carefully label any email I wanted to keep, using labels for each project. This kept my inbox clear if I did this frequently throughout the day. But if I got lazy or was returning from a long weekend, messages piled up and labeling became dreadful. Labels were helpful in finding a message if I wasn’t sure what I was looking for, but otherwise provided little value.

I’ve ditched the labels.  As I go through my inbox, I deal with each message this way:

  1. If it’s not worth keeping, I delete it.
  2. If it’s worth keeping, but I don’t need to act on it, I archive it.
  3. If it’s something I need to act on, I label it TODO.

The decision is simple and gets the inbox cleared quickly. I work through the TODO list, moving them to DONE when I’ve finished with them. It works out that when I need to refer to a message, I can find it quickly in TODO or DONE.

If a message sits in TODO for a long time, but I can’t bring myself to archive it, I move it to DEFER. It’s kind of pointless because I typically don’t do anything with these messages and they eventually get archived.

So far so good. I spend less time managing my inbox, I rarely miss important messages and I can find what I’m looking for quickly.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Tue, 30 Nov 2010 09:32:47 -0800 The last century in wealth and health http://blog.methodhead.com/the-last-century-in-wealth-and-health http://blog.methodhead.com/the-last-century-in-wealth-and-health

Via Planet Money

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Sun, 28 Nov 2010 22:04:00 -0800 Switched to posterous http://blog.methodhead.com/switched-to-posterous http://blog.methodhead.com/switched-to-posterous

I like it.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Wed, 28 Jul 2010 07:32:01 -0700 Amusing Ourselves to Death http://blog.methodhead.com/michael/blog/2010/07/amusing-ourselves-to-death http://blog.methodhead.com/michael/blog/2010/07/amusing-ourselves-to-death http://www.acceleratingfuture.com/michael/blog/2010/07/amusing-ourselves-to-d...

I watched the Science Channel series Powering the Future.  The average American consumes twice as much energy as the average European, 5 times as much as the average Chinese.  How much of this energy is for our amusement?

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Thu, 06 May 2010 11:38:05 -0700 Fishing Off Cape Hatteras http://blog.methodhead.com/photos/83256474@N00/sets/72157623862705567 http://blog.methodhead.com/photos/83256474@N00/sets/72157623862705567

I’m the paranoid type.  Friend me on Flickr for the whole set.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Mon, 26 Apr 2010 06:13:00 -0700 The Dangles http://blog.methodhead.com/post/550717756 http://blog.methodhead.com/post/550717756

Tumblr_l1hjelzxuk1qa6gvyo1_400

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Fri, 23 Apr 2010 08:29:00 -0700 Electric Bike http://blog.methodhead.com/post/543305094 http://blog.methodhead.com/post/543305094

Tumblr_l1c5od5bpt1qa6gvyo1_500

Friend of a friend blasts through DC on his electric bike.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Thu, 22 Apr 2010 07:35:00 -0700 Line Drying http://blog.methodhead.com/post/540752897 http://blog.methodhead.com/post/540752897

Tumblr_l1a8jz97rt1qa6gvyo1_500

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Sun, 11 Apr 2010 15:40:00 -0700 Desk Project http://blog.methodhead.com/post/514134793 http://blog.methodhead.com/post/514134793

Tumblr_l0qhojfghy1qa6gvyo1_1280

Desk project, final fit and finish to go

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Sat, 10 Apr 2010 11:56:00 -0700 Relaxing at Lake Anna http://blog.methodhead.com/post/511196580 http://blog.methodhead.com/post/511196580

Tumblr_l0ocnvyiu81qa6gvyo1_1280

Relaxing at Lake Anna

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Wed, 31 Mar 2010 09:55:18 -0700 I Should Really Start Collecting Points Now http://blog.methodhead.com/tech-talk/consumer-electronics/gaming/the-most-disturbing-presentation-of-the-year http://blog.methodhead.com/tech-talk/consumer-electronics/gaming/the-most-disturbing-presentation-of-the-year http://spectrum.ieee.org/tech-talk/consumer-electronics/gaming/the-most-distu...

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Mon, 22 Mar 2010 14:12:54 -0700 HTTP Response Code 418: I'm a teapot http://blog.methodhead.com/wiki/List_of_HTTP_status_codes http://blog.methodhead.com/wiki/List_of_HTTP_status_codes http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

The responding entity MAY be short and stout.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Tue, 09 Mar 2010 13:07:00 -0800 Start Awarding Oscars for Previews? http://blog.methodhead.com/start-awarding-oscars-for-previews http://blog.methodhead.com/start-awarding-oscars-for-previews http://www.program-glitch-esc.net/

A short Tron preview via Daring Fireball.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Fri, 05 Mar 2010 10:44:47 -0800 Cat Mosh Pit http://blog.methodhead.com/2010/03/cat-mosh-pit.html http://blog.methodhead.com/2010/03/cat-mosh-pit.html http://gilesbowkett.blogspot.com/2010/03/cat-mosh-pit.html

Via Giles Bowkett

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Mon, 22 Feb 2010 11:58:40 -0800 I'm Raising These Kids Right! http://blog.methodhead.com/archives/2010/02/raising_the_rea.php http://blog.methodhead.com/archives/2010/02/raising_the_rea.php http://www.roughtype.com/archives/2010/02/raising_the_rea.php

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Thu, 04 Feb 2010 19:21:26 -0800 In a single line: there will be no change until we change Congress. http://blog.methodhead.com/doc/20100222/lessig http://blog.methodhead.com/doc/20100222/lessig http://www.thenation.com/doc/20100222/lessig

A long piece by Lawrence Lessig on how Congress has brought itself to a standstill because of its addiction to campaign money.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead
Wed, 27 Jan 2010 20:03:00 -0800 Jobs, What a Salesman http://blog.methodhead.com/1001q3f8hhr/event/index.html http://blog.methodhead.com/1001q3f8hhr/event/index.html http://events.apple.com.edgesuite.net/1001q3f8hhr/event/index.html

I just sent him the kids’ college fund.  Obama was great too, though.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/4SnxtZQcHvFf methodhead methodhead