Skip to content

Instantly share code, notes, and snippets.

Will Langstroth wlangstroth

Block or report user

Report or block wlangstroth

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

Keybase proof

I hereby claim:

  • I am wlangstroth on github.
  • I am wlangstroth ( on keybase.
  • I have a public key whose fingerprint is E2F2 215B AA83 1547 A87E E85F 69DF E208 FA87 7968

To claim this, I am signing this object:

View things_controller_test.rb
require_relative '../test_helper'
class ThingsControllerTest < ActionController::TestCase
setup do
@thing = things(:default)
def test_index
things = [things(:default)]
View thing_test.rb
require_relative '../test_helper'
class ThingTest < ActiveSupport::TestCase
def test_fixtures
Thing.all.each do |thing|
assert thing.valid?, thing.errors.inspect
View thing_model.rb
class Thing < ActiveRecord::Base
# == Constants ==========================================================
CONSTANTS = %w[ thing1 thing2 ]
# == Attributes =========================================================
attr_accessor :attribute
wlangstroth / thing_controller.rb
Last active Dec 28, 2015
Jack-style controller
View thing_controller.rb
class ThingsController < ActiveController
before_action :build_thing, only: [:new, :create]
before_action :load_thing, only: [:show, :edit, :update, :destroy]
def index
@thing =[:page])
def show
wlangstroth / rule_test.rb
Created Feb 8, 2013
Test of Rule object
View rule_test.rb
require "minitest_helper"
class RuleTest < MiniTest::Unit::TestCase
def setup
def teardown
def test_stuff
wlangstroth / rule.rb
Created Feb 8, 2013
Object under test
View rule.rb
class Rule
def self.setters(*method_names)
method_names.each do |name|
send :define_method, name do |data|
instance_variable_set "@#{name}".to_sym, data.
wlangstroth / minitest_helper.rb
Created Feb 8, 2013
MiniTest helper using mixed formats
View minitest_helper.rb
# test/minitest_helper.rb
require "turn/autorun"
require "minitest/spec"
require "minitest/autorun"
Turn.config do |c|
c.format = :pretty
wlangstroth / Rakefile
Created Feb 8, 2013
Mixed Testing: MiniTest Unit and Spec
View Rakefile
require 'rake/testtask' do |t|
t.libs << "lib"
t.libs << "test"
t.pattern = "test/*_test.rb"
wlangstroth /
Created Nov 21, 2012
Quora thread snippets
cat a b | sort | uniq > c # c is a union b
cat a b | sort | uniq -d > c # c is a intersect b
cat a b b | sort | uniq -u > c # c is set difference a - b
find . -type f -ls
find . -name \*.py | xargs grep some_function
cat hosts | xargs -I{} ssh root@{} hostname
cat access.log | egrep -o 'acct_id=[0-9]+' | cut -d= -f2 | sort | uniq -c | sort -rn
You can’t perform that action at this time.