brew install redis
Set up launchctl to auto start redis
$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
/usr/local/opt/redis/ is a symlink to /usr/local/Cellar/redis/x.y.z (e.g., 2.8.7)
| # inspired by https://gist.github.com/zachrose/7549941 | |
| module ActiveSupport::Inflector | |
| def nice_title(phrase) | |
| return phrase if phrase =~ /^-+$/ | |
| phrase.split('-').map { |part| | |
| if part.chars.count == part.bytes.count | |
| part.titleize | |
| else | |
| part.split(' ').map { |word| word.mb_chars.titleize }.join(' ') |
| require 'set' | |
| module NumberFinder | |
| # Most efficient solution for single number missing from sequence. | |
| def self.method1(arr) | |
| (arr.size+1)*(arr.size+2)/2 - arr.reduce(:+) | |
| end | |
| # Generic solution works with any quantity of missing numbers. |
| module ActiveAdmin | |
| module Views | |
| class ActiveAdminForm | |
| class DeprecatedFormBufferSubstitute | |
| def initialize(form) | |
| @form = form | |
| end | |
| def << (value) | |
| @form.text_node value.html_safe | |
| end |
| context "with inputs twice" do | |
| let :body do | |
| build_form do |f| | |
| f.inputs do |f| | |
| f.input :title | |
| f.input :body | |
| end | |
| f.inputs do |f| | |
| f.input :author | |
| f.input :published_at |
| def prime?(n) | |
| for i in 2 ... n/2 | |
| return false if n % i == 0 | |
| end | |
| true | |
| end | |
| def palindrome? n | |
| s = n.to_s | |
| s.slice( 0, (s.length+1)/2 ) == s.reverse.slice( 0, (s.length+1)/2 ) |
I hereby claim:
To claim this, I am signing this object:
| gem 'active_model_serializers' | |
| gem 'activeadmin' | |
| gem 'jquery-ui-rails' |
| # See https://dondoh-blog.tumblr.com/post/4142258573/formtastic-without-activerecord | |
| # ------------------------------------------------------------------------------- | |
| # Faux model object that plays well with formtastic; this is used for example in | |
| # a contact form which generates a request to salesforce | |
| # ------------------------------------------------------------------------------- | |
| class FormtasticFauxModel | |
| include ActiveModel::Validations | |
| include ActiveModel::Conversion | |
| extend ActiveModel::Naming |
| web: | |
| build: . | |
| volumes: | |
| - .:/opt/myapp | |
| ports: | |
| - '3000:3000' | |
| links: | |
| - db | |
| - redis | |
| - selenium |