Skip to content

Instantly share code, notes, and snippets.

View wlangstroth's full-sized avatar

Will Langstroth wlangstroth

View GitHub Profile
@wlangstroth
wlangstroth / slim-html5-boilerplate
Created July 11, 2012 15:05 — forked from blakehilscher/slim-html5-boilerplate
Slim HTML5 Boilerplate Rails
doctype html
/[if lt IE 7]
html.no-js.lt-ie9.lt-ie8.lt-ie7 lang="en"
/[if IE 7]
html.no-js.lt-ie9.lt-ie8 lang="en"
/[if IE 8]
html.no-js.lt-ie9 lang="en"
| <!--[if (gte IE 8)]<!-->
<html class="no-js" lang="en"> <!--<![endif]-->
head
@wlangstroth
wlangstroth / deploy.rb
Last active September 11, 2021 13:15
Capistrano + Nginx + Unicorn + Sinatra on Ubuntu
require 'bundler/capistrano'
set :application, "net"
set :repository, "git@githost.com:net.git"
set :scm, :git
set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}
@wlangstroth
wlangstroth / shell_games.sh
Created November 21, 2012 13:20
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
@wlangstroth
wlangstroth / Rakefile
Created February 8, 2013 02:06
Mixed Testing: MiniTest Unit and Spec
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << "lib"
t.libs << "test"
t.pattern = "test/*_test.rb"
end
@wlangstroth
wlangstroth / minitest_helper.rb
Created February 8, 2013 04:01
MiniTest helper using mixed formats
# test/minitest_helper.rb
require "turn/autorun"
require "minitest/spec"
require "minitest/autorun"
Turn.config do |c|
c.format = :pretty
end
@wlangstroth
wlangstroth / rule.rb
Created February 8, 2013 04:03
Object under test
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.
end
end
end
@wlangstroth
wlangstroth / rule_test.rb
Created February 8, 2013 04:03
Test of Rule object
require "minitest_helper"
class RuleTest < MiniTest::Unit::TestCase
def setup
end
def teardown
end
def test_stuff
@wlangstroth
wlangstroth / thing_controller.rb
Last active December 28, 2015 16:58
Jack-style controller
class ThingsController < ActiveController
before_action :build_thing, only: [:new, :create]
before_action :load_thing, only: [:show, :edit, :update, :destroy]
def index
@thing = Thing.page(params[:page])
end
def show
render
class Thing < ActiveRecord::Base
# == Constants ==========================================================
CONSTANTS = %w[ thing1 thing2 ]
# == Attributes =========================================================
attr_accessor :attribute
require_relative '../test_helper'
class ThingTest < ActiveSupport::TestCase
def test_fixtures
Thing.all.each do |thing|
assert thing.valid?, thing.errors.inspect
end
end