Just install this in your apps like so:
gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'
# Recursively diff two hashes, showing only the differing values. | |
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license. | |
# | |
# Example: | |
# | |
# a = { | |
# "same" => "same", | |
# "diff" => "a", | |
# "only a" => "a", | |
# "nest" => { |
module DeepFetch | |
def deep_fetch(*keys, &fetch_default) | |
throw_fetch_default = fetch_default && lambda {|key, coll| | |
args = [key, coll] | |
# only provide extra block args if requested | |
args = args.slice(0, fetch_default.arity) if fetch_default.arity >= 0 | |
# If we need the default, we need to stop processing the loop immediately | |
throw :df_value, fetch_default.call(*args) | |
} | |
catch(:df_value){ |
def select_from_chosen(item_text, options) | |
field = find_field(options[:from]) | |
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()") | |
page.execute_script("$('##{field[:id]}').val('#{option_value}')") | |
end |
module MyApp | |
class Application < Rails::Application | |
if Rails.env == 'test' | |
require 'diagnostic' | |
config.middleware.use(MyApp::DiagnosticMiddleware) | |
end | |
end | |
end |
Just install this in your apps like so:
gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'
As configured in my dotfiles.
start new:
tmux
start new with session name:
class ActiveRecord::Base | |
mattr_accessor :shared_connection | |
@@shared_connection = nil | |
def self.connection | |
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection } | |
end | |
end | |
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection |
class ArticlesController < ApplicationController | |
def create | |
PublishArticle.publish(current_user, params[:article]) do |result| | |
result.success { |article| redirect_to article_path(article) } | |
result.failure { |article| @article = article; render :new } | |
end | |
end | |
end |
#!/bin/sh | |
### | |
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer) | |
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos | |
### | |
# Alot of these configs have been taken from the various places | |
# on the web, most from here | |
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx |
#!/usr/bin/env sh | |
# Download lists, unpack and filter, write to stdout | |
curl -s https://www.iblocklist.com/lists.php \ | |
| sed -n "s/.*value='\(http:.*=bt_.*\)'.*/\1/p" \ | |
| xargs wget -O - \ | |
| gunzip \ | |
| egrep -v '^#' |