Skip to content

Instantly share code, notes, and snippets.

Sam Goldman samwgoldman

Block or report user

Report or block samwgoldman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
samwgoldman / gist:3831925
Created Oct 4, 2012
gary bernhardt challenge
View gist:3831925
x = "some file name.with dots.html.markdown"
x.split(".").reverse.inject([x, []]) do |(file, exts), part|
if part =~ /\s/ || part == file
break [file, exts]
[file.chomp(".#{part}"), exts.push(part)]
View gist:3741978
var http = require("http");
var port = process.env.PORT || 8000;
var listeners = [];
function server(request, response) {
switch (request.method) {
case "GET":
listen(request, response);
samwgoldman / backtrace.txt
Created Sep 14, 2012
IO.popen on jruby issue?
View backtrace.txt
1) HTTPSpec::Clients::CGI issues requests to the app
69 Failure/Error: Unable to find matching line from backtrace
70 Java::JavaLang::NullPointerException:
71 # org.jruby.util.ShellLauncher.getCurrentEnv(
72 # org.jruby.util.ShellLauncher.popenShared(
73 # org.jruby.util.ShellLauncher.popenShared(
74 # org.jruby.util.ShellLauncher.popen(
75 # org.jruby.RubyIO.popen19(
76 # org.jruby.RubyIO$s$0$1$$s$0$1$popen19.gen:65535)
77 #
samwgoldman / capybara_reset_spec.rb
Created Jun 27, 2012
Capybara session reset issue
View capybara_reset_spec.rb
require "rack"
require "capybara/rspec"
App = do
map "/" do
run proc { |env|
request =
response =
if request.cookies["logged_in"]
response.write "Logged in!"
samwgoldman / facebook_test_user.rb
Created Jun 20, 2012
Easily create test users for facebook
View facebook_test_user.rb
require "httparty"
class FacebookTestUser
include HTTParty
base_uri ""
attr_reader :email, :password
def initialize(options)
@email = options["email"]
samwgoldman / html_builder_example.rb
Created May 23, 2012
Using smartlogic/html_builder
View html_builder_example.rb
require "html"
require "html/list"
require "html/map"
module HTML
class Article <
def to_html do |article|
tag(:article, tag(:h2, article.title) + map(:section, article.sections), id:
samwgoldman / test.rb
Created Apr 27, 2012
webmachine-ruby chunked response with rack adapter streaming
View test.rb
require "webmachine"
require "webmachine/adapters/rack"
class TestResource < Webmachine::Resource
def to_html
parts = %w{Hello, World!} do
parts.each do |part|
Fiber.yield part
sleep 0.5
samwgoldman / $stdout
Created Feb 18, 2012
activerecord bug?
View $stdout
active record
role built from a context
should eq #<Context id: 1, type: nil>
role built from a role through context
should eq #<Context id: 2, type: nil> (FAILED - 1)
student built from a program
should eq #<Program id: 3, type: "Program">
View gist:1853955
class Tests
extend Process
def self.passing?
fork do
require "rspec/autorun"
Dir["spec/**/*_spec.rb"].each do |spec|
require_relative spec
samwgoldman / gist:1777846
Created Feb 9, 2012
Helpful macros for rspec controller specs
View gist:1777846
module RackTestHelpers
extend ActiveSupport::Concern
module ClassMethods
def self.define_action(action)
define_method action do |*args, &block|
options = args.extract_options!
options[:http_method] = action
options[:controller_method] = args[0]
args[0] = [action.to_s.upcase, "#" + options[:controller_method].to_s].join(" ")
You can’t perform that action at this time.