$
brew install redis
$
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
| CREATE USER postgres WITH PASSWORD 'postgres' SUPERUSER; |
#Faker
Usage is simple; first grab the gem using your gem program:
$sudo gem install faker
Now you can use it in your favorite ruby program or script. For now let's fire up irb and see what we can fake.
require 'rubygems' | # Ruby opposite of array intersection... or maybe the method is missing from my brain bc not enough coffee | |
| # http://twitter.com/soawesomeman/status/8035087261 | |
| def awesome(ar_1, ar_2) | |
| (ar_1 + ar_2) - (ar_1 & ar_2) | |
| end | |
| awesome([1,2,3,4], [3,4,5,6]) # => [1, 2, 5, 6] |
| # better way - from https://gist.github.com/marka2g/1629357/edit | |
| Kernel.class_eval do | |
| alias :old_require :require | |
| def require(*args) | |
| puts args | |
| old_require(*args) | |
| end | |
| end |
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| gempaths = Gem::default_path | |
| puts | |
| puts "Scanning paths in Gem::default_path for RubyGems with native extensions ..." | |
| puts |
| days_array = ["everyday", "school_nights", "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] | |
| def order_days(hashes) | |
| days_indexes = {} | |
| days_array.each_with_index do |item, index| | |
| days_indexes[item] = index | |
| end | |
| hashes.sort_by do |schedule| | |
| days_indexes.fetch(schedule[:day].downcase) | |
| end |
| # autoload concerns | |
| module YourApp | |
| class Application < Rails::Application | |
| config.autoload_paths += %W( | |
| #{config.root}/app/controllers/concerns | |
| #{config.root}/app/models/concerns | |
| ) | |
| end | |
| end |
| const memoize = (fn) => { | |
| let cache = {}, key; | |
| return (...args) => { | |
| key = JSON.stringify(args); | |
| return cache[key] || (cache[key] = fn.call(null, ...args)); | |
| } | |
| }; |