Skip to content

Instantly share code, notes, and snippets.

View benhamill's full-sized avatar
💖

Ben Hamill benhamill

💖
View GitHub Profile
MIME-Version: 1.0
Received: by 10.50.16.79 with HTTP; Mon, 28 Jan 2013 08:20:01 -0800 (PST)
Date: Mon, 28 Jan 2013 10:20:01 -0600
Delivered-To: benhamill@otherinbox.com
Message-ID: <CAC3jhfzy+m8u5_hDKMnXCn2A2K9jK1o4Y=NBj0narA4=L7bbjQ@mail.gmail.com>
Subject: Test
From: Ben Hamill <benhamill@otherinbox.com>
To: Ben Hamill <benhamill@otherinbox.com>
Content-Type: multipart/alternative; boundary=e89a8f234cd728710704d45ba6e3
package main
import (
"log"
"flag"
"time"
"net"
"fmt"
"bufio"
)
require 'foo'
class Bar
attr_reader :foo
def make_foo
@foo = Foo.new(self)
end
end
@benhamill
benhamill / option_3.rb
Created November 13, 2012 20:34 — forked from kerinin/gist:4068172
Conditional organization
# Option 1
if eea_exists?
if eea_uses_something?
if eea_ever_used_application?
if eea_currently_uses_application?
recreate_eea; reactivate_application_for_eea; create_session; #13S
else
recreate_eea; reactivate_application_for_eea; create_session; #13S
end
else
describe User do
describe "#serialize_comments" do
before do
subject.stub(:read_comment_count).and_return(3)
subject.stub(:unread_comment_count).and_return(5)
end
it "does something when there are 5 unread comments"
end
end
@benhamill
benhamill / code.rb
Created August 10, 2012 21:11
Define method has helpful stack traces, compared to other meta-programming stuff.
class Foo
%w(bar baz).each do |m|
define_method("say_#{m}") do
raise m.to_s
end
end
end
f = Foo.new
Problem Employee
Servers Bob
Background Jobs Brad
Database Ben
JavaScript Isaac
CSS Andy
Translations Ryan
Bad Smells Marcos
Dumb Words Brian
@benhamill
benhamill / foo.rb
Created March 23, 2012 03:25
How do all those variable-types work in different scopes?
class Foo
def self.bar
@bar ||= :self_bar
end
def self.bar=(b)
@bar = b
end
def bar
OmniAuth.config.on_failure do |env|
exception = env['omniauth.error']
error_type = env['omniauth.error.type']
strategy = env['omniauth.error.strategy']
Rails.logger.error("OmniAuth Error (#{error_type}): #{exception.inspect}")
ErrorNotifier.exception(exception, :strategy => strategy.inspect, :error_type => error_type)
new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{error_type}"
(3/8) upgrading linux [####################################################################################] 100%
>>> Updating module dependencies. Please wait ...
>>> Generating initial ramdisk, using mkinitcpio. Please wait...
==> Building image from preset: 'default'
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
==> Starting build: 3.2.9-1-ARCH
-> Parsing hook: [base]
-> Parsing hook: [udev]
-> Parsing hook: [autodetect]
-> Parsing hook: [pata]