I hereby claim:
- I am johnnyshields on github.
- I am johnnyshields (https://keybase.io/johnnyshields) on keybase.
- I have a public key whose fingerprint is D34E ABFC C9A0 B183 E266 0112 DCB7 FDD4 0E86 6A5B
To claim this, I am signing this object:
| #!/bin/env ruby | |
| # encoding: utf-8 | |
| ############################################ | |
| # NOTE: THIS CLASS EXTENDS PRAWN::DOCUMENT # | |
| ############################################ | |
| class ErrorDoc < ::Prawn::Document | |
| def initialize |
| # Monkey patch to instrument Moped 1.x same as 2.x. | |
| # Can be removed after upgrading to Mongoid 4. | |
| module Moped | |
| module Instrumentable | |
| class Noop | |
| class << self | |
| # Do not instrument anything. |
I hereby claim:
To claim this, I am signing this object:
| Stack trace | |
| javax.servlet.ServletException: com.amazonaws.AmazonClientException: Unable to load AWS credentials from any provider in the chain | |
| at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:796) | |
| at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) | |
| at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:233) | |
| at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) | |
| at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) | |
| at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) | |
| at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649) |
| def current_path_for_locale(loc = I18n.locale, is_link = true) | |
| return 'javascript: void(0);' if is_link && I18n.locale == loc | |
| url_regex = /\A\/(?:(#{I18n.available_locales.join('|')})\/)?/ | |
| current_page.url.gsub(url_regex, '').blank? ? | |
| home_for_locale(loc) : | |
| current_page.url.gsub(url_regex, root_for_locale(loc)) | |
| end |
There is opportunity to simplify Mongoid's relation definitions, increase intuitiveness, and at the same time make them more powerful.
One particular issue I'm facing is over-usage of has_and_belongs_to_many ... inverse_of: nil. The problem with this is that the inverse side of the relationship doesn't trigger any callbacks, which leads to out-of-sync data. It would be more natural to express this as belongs_to_many and has_many as per below.
Given two models, each can have the one of the following verbs to define a relation, so long as at least one side is belongs:
| require 'benchmark' | |
| a = 1 | |
| b = 2 | |
| c = 3 | |
| Benchmark.bm do |bm| | |
| bm.report do | |
| 10_000_000.times do |a| | |
| [a, b, c] |