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 / http.rb
Created March 24, 2012 20:27
A Shoes hypermedia client for ALPS microblogging
require 'net/http'
require 'open-uri'
require 'hpricot'
# A simple get request should not require this much boilerplate.
def fetch_data(uri)
uri = URI(uri)
req = Net::HTTP::Get.new(uri.request_uri)
req['Accept'] = "application/xhtml+xml"
Given /^I have rolled the following game:$/ do |table|
@game = Game.new
table.hashes.each do |attributes|
@game.add_frame Frame.new(attributes)
end
end
Then /^I should score (\d+)$/ do |score|
@score.should = score
end
Console.app:
3/27/12 12:32:18.846 PM [0x0-0x6f26f2].org.hackety.shoes: dyld: Library not loaded: @executable_path/libXft.2.dylib
3/27/12 12:32:18.846 PM [0x0-0x6f26f2].org.hackety.shoes: Referenced from: /Users/steve/src/shoes/Shoes.app/Contents/MacOS/./pango-querymodules
3/27/12 12:32:18.846 PM [0x0-0x6f26f2].org.hackety.shoes: Reason: image not found
3/27/12 12:32:18.910 PM [0x0-0x6f26f2].org.hackety.shoes: /Users/steve/src/shoes/Shoes.app/Contents/MacOS/shoes-launch: line 8: 15933 Trace/BPT trap: 5 PANGO_RC_FILE="$APPPATH/pangorc" ./pango-querymodules > pango.modules
3/27/12 12:32:18.916 PM [0x0-0x6f26f2].org.hackety.shoes: dyld: Library not loaded: @executable_path/libxcb.1.dylib
3/27/12 12:32:18.916 PM [0x0-0x6f26f2].org.hackety.shoes: Referenced from: /Users/steve/src/shoes/Shoes.app/Contents/MacOS/libXrender.1.dylib
3/27/12 12:32:18.916 PM [0x0-0x6f26f2].org.hackety.shoes: Reason: image not found
@steveklabnik
steveklabnik / hack.sh
Created March 31, 2012 15:10 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
$ cat ~/.zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="robbyrussell"
ZSH_THEME="prose"
require "minitest/autorun"
require "mocha"
require "watchable"
describe Watchable do
subject do
Object.new.extend Watchable
end
it "has an empty list of watchers by default" do
@steveklabnik
steveklabnik / uhhhh.md
Created April 13, 2012 20:13
Did rails used to do this?

Using rails 3.2.2, btw.

1.9.3-p125 :005 > a = Article.first
 => #<Article id: 1, title: "Sample Article Title", body: "This is the text for my article, woo hoo!", created_at: "2012-04-13 00:16:04", updated_at: "2012-04-13 00:16:04"> 
1.9.3-p125 :006 > a.comments
 => [four comments] 
1.9.3-p125 :007 > c = a.comments.new
 => #<Comment id: nil, article_id: 1, author_name: nil, body: nil, created_at: nil, updated_at: nil> 
1.9.3-p125 :008 &gt; a.comments
@steveklabnik
steveklabnik / tricky.rb
Created May 9, 2012 19:12
Oh rails, you so tricky...
1.9.3p125 :047 > a.class
=> Array
1.9.3p125 :048 > a.ancestors
=> [Album(id: integer, user_id: integer, created_at: datetime, updated_at: datetime),
Draper::ModelSupport, Album::GeneratedFeatureMethods, #<Module:0x007fad2af6dce8>,
ActiveRecord::Base, ActiveRecord::Aggregations, ActiveRecord::Transactions, ActiveRecord::Reflection,
ActiveRecord::Serialization, ActiveModel::Serializers::Xml, ActiveModel::Serializers::JSON,
ActiveModel::Serialization, ActiveRecord::Store, ActiveRecord::AutosaveAssociation,
ActiveRecord::NestedAttributes, ActiveModel::SecurePassword, ActiveRecord::IdentityMap,
ActiveRecord::Associations, ActiveModel::Validations::Callbacks, ActiveRecord::Callbacks,
@steveklabnik
steveklabnik / collection-links.json
Created May 17, 2012 18:42
link to collection in collection+json
@steveklabnik
steveklabnik / shoes_tk.rb
Created May 25, 2012 04:15
Some simple architecture decision options for shoes 4
require 'tk'
class Shoes
module Tk
class App
def initialize
@root = TkRoot.new
end
def button(title, &blk)