This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
end | |
class User | |
include Mongoid::Document | |
collection.remove | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FuzzyHash | |
attr_reader :attrs | |
def initialize(attrs) | |
@attrs = attrs | |
end | |
def blank? | |
attrs.nil? | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
pid = `lsof -t -i tcp:3000`.to_i | |
Process.kill 'INT', pid if pid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DEPS="YES" | |
check-dependency() { | |
name=$1 | |
program=${2-"brew list $1"} | |
if ! eval $program &>/dev/null; then | |
echo "This app requires $name to run, but it is not installed." | |
echo " brew install $name" |
OlderNewer