Skip to content

Instantly share code, notes, and snippets.

View hashrocketeer's full-sized avatar

Hashrocket Employees hashrocketeer

View GitHub Profile
// Generated by CoffeeScript 1.6.3
var constraint, material, mesh, wheel_geometry;
material = Physijs.createMaterial(new THREE.MeshLambertMaterial({
map: THREE.ImageUtils.loadTexture('images/checker.gif')
}), .8, .5);
wheel_geometry = new THREE.CylinderGeometry(5, 5, 2, 16);
mesh = new Physijs.CylinderMesh(wheel_geometry, material, 16);
# credit @rwz
When /^I follow "([^"]+"(?: then "[^"]+")*)$/ do |links|
links.chomp(?").split('" then "').each do |link_text|
click_link link_text
end
end
# Example usage:
# When I follow "thing1" then "thing2" then "thing3"
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db('testing')
end
class User
include Mongoid::Document
collection.remove
end
class FuzzyHash
attr_reader :attrs
def initialize(attrs)
@attrs = attrs
end
def blank?
attrs.nil?
end
--regex-ruby=/(^|[:;])[ \t]*([A-Z][[:alnum:]_]+) *=/\2/c,class,constant/
--regex-ruby=/(^|;)[ \t]*(has_many|belongs_to|has_one|has_and_belongs_to_many)\(? *:([[:alnum:]_]+)/\3/f,function,association/
--regex-ruby=/(^|;)[ \t]*(named_)?scope\(? *:([[:alnum:]_]+)/\3/f,function,named_scope/
--regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2/f,function,aasm_event/
--regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2!/f,function,aasm_event/
--regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2?/f,function,aasm_event/
@hashrocketeer
hashrocketeer / candidate_spec.rb
Created October 11, 2011 13:30 — forked from knwang/candidate_spec.rb
Proofing_oven: Candidate Spec with search
require 'spec_helper'
describe Candidate do
subject { Fabricate(:candidate, first_name: "Joe", last_name: "Doe") }
describe "#full_name" do
its(:full_name) { should == "Joe Doe" }
end
describe "#search" do
NoMethodError: undefined method `read_nonblock' for #<OpenSSL::SSL::SSLSocket:0x44cdf872>
rbuf_fill at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/1.9/net/protocol.rb:135
readuntil at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/1.9/net/protocol.rb:116
readline at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/1.9/net/protocol.rb:126
read_status_line at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/1.9/net/http.rb:2219
read_new at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/1.9/net/http.rb:2208
transport_request at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/1.9/net/http.rb:1191
request at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/1.9/net/http.rb:1177
request at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/1.9/net/http.rb:1170
start at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/1.9/net/http.rb:627
source 'http://rubygems.org'
gem 'rails', '3.1.1'
platforms :jruby do
gem 'jruby-openssl'
gem 'trinidad'
gem 'activerecord-jdbcpostgresql-adapter'
gem 'activerecord-jdbc-adapter'
gem 'jdbc-postgres', :require => false
@hashrocketeer
hashrocketeer / gist:3209188
Created July 30, 2012 19:01
base64 string to image
# http://stackoverflow.com/questions/1160741/how-to-save-a-base64-string-as-an-image-using-ruby
File.open('shipping_label.gif', 'wb') do|f|
f.write(Base64.decode64(base_64_encoded_data))
end
(ns hackerfews.core
2 (:require [net.cgrand.enlive-html :as html]))
3
4 (def url (java.net.URI. "http://news.ycombinator.com/"))
5
6 (defn titles
7 [docx] (flatten (map :content (html/select docx [:td.title :a]))))
8
9 (defn numbers-in-nodes
10 [docx selector] (let [x (flatten (map :content (html/select docx selector)))]