This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# _ _ | |
# __| |_ _ _(_)_ __ ___ | |
# (_-< _| '_| | '_ \/ -_) | |
# /__/\__|_| |_| .__/\___| | |
# |_| | |
# __ _ _ __| |_ ___ _ __ ___ _ _ | |
# / _| || (_-< _/ _ \ ' \/ -_) '_| | |
# \__|\_,_/__/\__\___/_|_|_\___|_| | |
# | |
# (c) 2013 stephan.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ _ ___ _ _ | |
/ _ __ ___| |_ _| _ (_)__| |_____ _ _ | |
/ | '_ \/ _ \ | || | _/ / _| / / -_) '_| | |
/ | .__/\___/_|\_, |_| |_\__|_\_\___|_| | |
/ |_| |__/ s.c14 | |
/ This partial is meant to allow for picking an object of polymorphic type, returning both a type and id | |
/ It is comprised of two select elements, the first of which controls the available choices in the second | |
/ It relies on the poly_picker.js.coffee script on the front end | |
/ It expects to find these locals: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# (c) 2007 stephan.com | |
# A program to impress Grace | |
# Finds five words of five letters using all unique letters | |
Goodwords = [] | |
CompareMatrix = {} | |
# returns true if any letters are shared between two strings | |
def has_common_letters?(a, b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# by: _ _ | |
# __| |_ ___ _ __| |_ __ _ _ _ __ ___ _ __ | |
# (_-< _/ -_) '_ \ ' \/ _` | ' \ _/ _/ _ \ ' \ | |
# /__/\__\___| .__/_||_\__,_|_||_(_)__\___/_|_|_| | |
# |_| stephan@stephan.com | |
# Unobtrusive txtRotate | |
# http://codepen.io/stephancom/details/pgXypp/ | |
# applies to all elements with data-rotate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# by: _ _ | |
# __| |_ ___ _ __| |_ __ _ _ _ __ ___ _ __ | |
# (_-< _/ -_) '_ \ ' \/ _` | ' \ _/ _/ _ \ ' \ | |
# /__/\__\___| .__/_||_\__,_|_||_(_)__\___/_|_|_| | |
# |_| stephan@stephan.com | |
# unobtrusive preloader | |
# applies to all elements with data-preload | |
# expects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@resource.aasm.events.each do |event| | |
member_action event.name, method: :post do | |
resource.send(event) if resource.aasm.may_fire_event?(event.name) | |
end | |
action_item event, only: :show, if: -> { resource.aasm.may_fire_event?(event.name) } do | |
link_to event.name.capitalize, action: event.name, controller: :ties, method: :post | |
end | |
batch_action event.name do |ids| | |
klass = controller_name.classify.constantize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fizzbuzz benchmark - comparing different versions of the classic | |
# stephan.com | |
require 'rspec' | |
require 'benchmark' | |
require 'formatador' | |
# suppress output | |
def no_stdout | |
ostd = $stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns keys from a hash recursively when that hash can contain hashes | |
# Handy for use with StrongParameters | |
recurse_keys = lambda do |h| h.inject([]) { |a, (k, v)| a << (v.is_a?(Hash) ? { k => recurse_keys.call(v) } : k) } rescue [] end | |
# Example | |
parms = {:foo=>:bar, :baz=>{:a=>:b, :c=>:d, :e=>:f}} | |
recurse_keys.call(parms) | |
# returns [:foo, {baz: [:a, :b, :c]}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
describe '${1:model_name} collection' do | |
${2:pending 'needs tests'} | |
end | |
describe 'CRUD ${1:model_name}' do | |
describe 'create' do | |
${3:pending 'needs tests'} | |
end | |
describe 'read' do |