Skip to content

Instantly share code, notes, and snippets.

Aaron Kromer cupakromer

Block or report user

Report or block cupakromer

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
View gist:8786449
FactoryGirl.define do
factory :user do
email ''
password 'this IS a BAd passowrds1234!!'
trait :confirmed do
confirmed_at { }
confirmation_token nil
cupakromer / gist:8851663
Last active Aug 29, 2015
On Open Classes and Message Passing in Ruby #retroruby
View gist:8851663
"Words" * 2
# => "WordsWords"
2 * "Words"
# TypeError: String can't be coerced into Fixnum
# Oops what just happened?
# In Ruby, virtually everything is a message to another object.
# Above we would say:
View hilong.rb
#!/usr/bin/env ruby
# A simply utility to show character counts for each line of input and
# highlight lines longer than 80 characters.
# Written as an example for
# Examples:
# $ hilong Gemfile
cupakromer / gist:9144881
Created Feb 21, 2014
😧 Mongo BSON dump restore script
View gist:9144881
#!/usr/bin/env ruby
# Little ditty to untar a bunch of mongo bson dumps,
# and then restore them.
# Remembers if something was processed before and doesn't
# process it again. (Though mongo will basically due this
# for you 😬)
# I'm a bad person and I should feel bad for writing this
cupakromer / gist:9149496
Last active Aug 29, 2015
Advanced RSpec Hook Inclusion
View gist:9149496

Check the Metadata

Say you normally use the great database_cleaner gem. Per the README the standard setup is:

RSpec.configure do |config|

  config.before(:suite) do
    DatabaseCleaner.strategy = :transaction
cupakromer / gist:9214777
Last active Aug 29, 2015
Check log script
View gist:9214777
cat_with_name() { for i in $* ; do echo ; echo "=== $i ===" ; cat $i ; done }
cupakromer /
Last active Aug 29, 2015
Patch local binstubs into chruby
for dir in "$PREFIX/opt/rubies" "$HOME/.rubies"; do
[[ -d "$dir" && -n "$(ls -A "$dir")" ]] && RUBIES+=("$dir"/*)
unset dir
function chruby_reset()
cupakromer / flatten_map_bm.rb
Last active Aug 29, 2015
If you may have an array of arrays, `flat_map` is probably the way to go
View flatten_map_bm.rb
require "benchmark"
require "benchmark/ips"
def arr, 1)
def arr_of_arrs{ (1..1000).to_a }
cupakromer / gist:9414554
Created Mar 7, 2014
Command Line Tricks
View gist:9414554

Command Line Tricks

  • !! Repeat Previous Command
  • !-1 Repeat Previous Command
  • !-2 Repeat 2nd Previous Command
  • !ps Execute Previous Command STARTING WITH ps
  • !^ First Argument From Previous Command
  • !:2 2nd Argument From Previous Command
  • !$ Last Argument From Previous Command
  • !!:$ Last Argument From Previous Command
cupakromer / gist:9934026
Created Apr 2, 2014
RelishApp Syntax Formatting Test
View gist:9934026
Feature: Testing Code Blocks
In the feature description.
Only indent to specify code block:
No indent:
/a regex/
a_string = "foo"
You can’t perform that action at this time.