- Jim Weirich: The Building Blocks of Modularity – http://goo.gl/g4Nk
- Jim Weirich: SOLID Ruby – http://goo.gl/z3jd
- Sandi Metz: SOLID Object-Oriented Design – http://goo.gl/PDn6T
- Sandi Metz: Less – The Path to Better Design – http://goo.gl/VuTl4
- Demeter is for Encapsulation – http://is.gd/eeyLx
- Opinionated Modular Code – http://is.gd/eeyXm
- Scaling to Hundreds of Millions of Requests – http://vimeo.com/12814529
- Confident Code – http://goo.gl/VFLX
- Destroy All Software Screencasts – https://www.destroyallsoftware.com/screencasts
- Corey Haines: Fast Rails Tests – http://goo.gl/Va2gb
| /*------------------------------------------ | |
| Responsive Grid Media Queries - 1280, 1024, 768, 480 | |
| 1280-1024 - desktop (default grid) | |
| 1024-768 - tablet landscape | |
| 768-480 - tablet | |
| 480-less - phone landscape & smaller | |
| --------------------------------------------*/ | |
| @media all and (min-width: 1024px) and (max-width: 1280px) { } | |
| @media all and (min-width: 768px) and (max-width: 1024px) { } |
This is a collection of links, examples and rants about Presenters/Decorators in Rails.
The "Decorator" pattern slowly started gaining popularity in Rails several years ago. It is not part of core Rails, and there's many different interpretations about how it should work in practice.
Jay Fields wrote about it in 2007 (before he switched back to Java and then Clojure): http://blog.jayfields.com/2007/03/rails-presenter-pattern.html
A class should have only a single responsibility.
Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.
Software entities should be open for extension, but closed for modification.
| Plugboard = Hash[*('A'..'Z').to_a.sample(20)] | |
| Plugboard.merge!(Plugboard.invert) | |
| Plugboard.default_proc = proc { |_, key| key } | |
| def build_a_rotor | |
| Hash[('A'..'Z').zip(('A'..'Z').to_a.shuffle)] | |
| end | |
| ROTOR_1, ROTOR_2, ROTOR_3 = build_a_rotor, build_a_rotor, build_a_rotor |
| aba_check_digit = (t) -> | |
| 7 * (t[0] + t[3] + t[6]) + | |
| 3 * (t[1] + t[4] + t[7]) + | |
| 9 * (t[2] + t[5]) | |
| aba_check_sum = (t) -> | |
| 3 * (t[0] + t[3] + t[6]) + | |
| 7 * (t[1] + t[4] + t[7]) + | |
| 1 * (t[2] + t[5] + t[8]) |
| module JsonSerializer | |
| module_function | |
| # | |
| # Usage: | |
| # JsonSerializer.find_by_id(User, 1, only: [:id, :email, :address], except: [:address]) | |
| # | |
| def find_by_id(klass, id, options = {}) | |
| sql = "SELECT row_to_json(results) FROM ( | |
| SELECT #{selected_attributes(klass, options)} |
| #!/usr/bin/env bash | |
| # https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/ | |
| # https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c | |
| # https://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver | |
| # https://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception | |
| # https://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal | |
| # https://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04 | |
| # Versions | |
| CHROME_DRIVER_VERSION=`curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE` |
| # gem install multi_json json yajl-ruby oj benchmark-memory | |
| require 'multi_json' | |
| require 'json' | |
| require 'yajl' | |
| require 'oj' | |
| require 'benchmark' | |
| require 'benchmark-memory' | |
| hash1 = { |
| # frozen_string_literal: true | |
| require "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
| gem "rails", github: "rails/rails" |