Skip to content

Instantly share code, notes, and snippets.

View stephancom's full-sized avatar

stephan.com stephancom

View GitHub Profile
@stephancom
stephancom / ???.sublime-snippet
Created April 24, 2013 08:13
press ???-tab in sublime and get a big questionmark of hash signs, never three on one line, suitable for use in coffeescript
<snippet>
<content><![CDATA[
########
################
######### ##########
##### ######
#### #####
#####
#######
#######
@stephancom
stephancom / balanced_customer.rb
Created December 30, 2013 04:13
Balanced Payments coffee script and rails concern
# _ _ _
# | |__ __ _| |__ _ _ _ __ ___ __| |
# | '_ \/ _` | / _` | ' \/ _/ -_) _` |
# |_.__/\__,_|_\__,_|_||_\__\___\__,_|
# __ _ _ __| |_ ___ _ __ ___ _ _
# / _| || (_-< _/ _ \ ' \/ -_) '_|
# \__|\_,_/__/\__\___/_|_|_\___|_|
#
# (c) 2013 stephan.com
@stephancom
stephancom / txt_rotate.coffee
Last active February 21, 2016 11:51
coffeescript text carousel
# by: _ _
# __| |_ ___ _ __| |_ __ _ _ _ __ ___ _ __
# (_-< _/ -_) '_ \ ' \/ _` | ' \ _/ _/ _ \ ' \
# /__/\__\___| .__/_||_\__,_|_||_(_)__\___/_|_|_|
# |_| stephan@stephan.com
# Unobtrusive txtRotate
# http://codepen.io/stephancom/details/pgXypp/
# applies to all elements with data-rotate
@stephancom
stephancom / preloader.coffee
Last active February 21, 2016 11:52
unobtrusive coffee script preloader
# by: _ _
# __| |_ ___ _ __| |_ __ _ _ _ __ ___ _ __
# (_-< _/ -_) '_ \ ' \/ _` | ' \ _/ _/ _ \ ' \
# /__/\__\___| .__/_||_\__,_|_||_(_)__\___/_|_|_|
# |_| stephan@stephan.com
# unobtrusive preloader
# applies to all elements with data-preload
# expects
@stephancom
stephancom / fizzbench.rb
Created January 4, 2017 06:24
FizzBuzz - generalized, improved, tested, benchmarked
# fizzbuzz benchmark - comparing different versions of the classic
# stephan.com
require 'rspec'
require 'benchmark'
require 'formatador'
# suppress output
def no_stdout
ostd = $stdout
@stephancom
stephancom / recurse_keys.rb
Created March 24, 2017 21:01
recursive hash keys
# 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]}]
@stephancom
stephancom / rspec-crud.sublime-snippet
Last active April 5, 2017 15:25
Sublime snippet for sketching out CRUD+index in rspec
<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
@stephancom
stephancom / active_admin_aasm.rb
Created May 2, 2016 03:38
Automatic admin for AASM
@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
@stephancom
stephancom / zalgo-vue.js
Created November 4, 2017 10:09
z̴̧̢̳͇̣̰͍͉̠͎̤͚̭͓̮̖̦͕̯̰̦̠̼̩̀̐͛̎͋̎ͩ̂͛ͣ̂ͬͬ̕͘ą̯͎̜͇͚̣̖̖̬͚͉̳̗̺̥̒ͨ̈ͥͥ̿̓̀ͣ̀̇͢͢͝͞ͅl̶̖̞͖̪̝̬͇̗̝̠̟̖͇̪͇̥̠̫̺̪̮̠̪̩͍̠̯̙ͮͩ͌̄ͪͩ̅ͭ̆ͅg̡̩͓̰̞̬̘̥͇̻̖̥̻̖̼̠͉͇͙̘̝͕̮͇͉̪̟̩̻̩̤̍͗ͣ͊͋̃ͣ̌̄ͣ͑̋̂͐͛̐̂ͅͅǫ̭̠̰͔̯̝̹͓̲͖͇̺̳͍͉̯̗̘̱̣̱̼̟̰̝̠̬͉ͭ̊̈̇ͥ̇̾͋͒̌ͫ̊̉̑̓ͣ̑̅̀-̢̼̫̠̫͕̦͉̺̌͛̄ͯ̋̍͋ͬ̀̕͘v̢̰̠̱̠̖̲͔̗̠͍͙͉̯̘̲̦̝̣̩͚̳̼͈ͦ̑̈̄̈̑ͣ͟͜ụ̣̙͉̩͔̙̪̘̰͇͕̭͈͎͇̦͓͚̹͑̊̋̅͟͢͠͡e̴̜̙͈͖̯̲̪͙̼͍̰̯̗͆͐̾͊̏ͣ͊ͦ͒
// _
// | |
// ______ _| | __ _ ___ ________ ___ _ ___
// |_ / _` | |/ _` |/ _ \______\ \ / / | | |/ _ \
// / / (_| | | (_| | (_) | \ V /| |_| | __/
// /___\__,_|_|\__, |\___/ \_/ \__,_|\___|
// __/ |
// |___/ by stephan@stephan.com
//
// a vue filter for zalgo text
@stephancom
stephancom / fliptext-vue.js
Created November 4, 2017 10:59
ǝnʌ-ʇxǝʇdıןɟ
// __ _ _ _ _
// / _| (_) | | | |
// | |_| |_ _ __ | |_ _____ _| |_ ________ ___ _ ___
// | _| | | '_ \| __/ _ \ \/ / __|______\ \ / / | | |/ _ \
// | | | | | |_) | || __/> <| |_ \ V /| |_| | __/
// |_| |_|_| .__/ \__\___/_/\_\\__| \_/ \__,_|\___|
// | |
// |_| by stephan@stephan.com
//
// a vue filter for fliptext