Codes:
- L: Likes
- D: Dislikes
- M: Meh.
Depending on the persona for successful negotiation you need either 2 Like answers or 1 Like + 1 Meh.
| class MyClass | |
| def static_yield(*) | |
| yield if block_given? | |
| end | |
| define_method :dynamic_yield do |*| | |
| yield if block_given? | |
| end | |
| define_method :dynamic_yield_fix do |*, &block| |
Codes:
Depending on the persona for successful negotiation you need either 2 Like answers or 1 Like + 1 Meh.
| my_string.scan(/[a-z\d]+/).each_with_object(Hash.new(0)){ |e, a| a[e] += 1 } |
| def run_with_elapsed_time | |
| time_at_start = Time.now | |
| exception = nil | |
| result = yield | |
| rescue => e | |
| exception = e | |
| ensure | |
| return [ result, exception, Time.now - time_at_start ] | |
| end |
| // look ma, no jquery | |
| // assuming that you have | |
| // <a data-komments-permalink="/foobar">comments count goes here</a> | |
| // somewhere in your HTML | |
| function _kmtsLoaded(){ | |
| var links = [].slice.apply(document.querySelectorAll("a[data-komments-permalink]")); | |
| links.forEach(function(link){ |
Let's call it AdequateForm for now.
class SignUpForm < AdequateForm
attribute :first_name
attribute :last_name
attribute :birthdate, :date
validates :first_name, :birthdate, presence: true
end| # config/initializers/lol_json.rb | |
| module ActiveSupport | |
| module JSON | |
| module Encoding | |
| class JSONGemEncoder | |
| BYPASS_JSONIFY = Set.new | |
| alias_method :original_jsonify, :jsonify | |
| class MyHash < Hash | |
| undef_method :fetch | |
| def fetch(*) | |
| # your code goes here | |
| end | |
| end | |
| require "rspec/autorun" |
| require "benchmark/ips" | |
| require "set" | |
| OLD_CODE = ->(n){ | |
| mod10 = n % 10 | |
| mod100 = n % 100 | |
| if mod10 == 1 && mod100 != 11 | |
| :one | |
| elsif [2, 3, 4].include?(mod10) && ![12, 13, 14].include?(mod100) |
| /var/folders/50/nmb34mx94js1fd1z_s5fl8pr0000gn/T/ruby-build.20131124231727.32309 ~ | |
| HTTP/1.1 200 OK | |
| Content-Type: binary/octet-stream | |
| Content-Length: 13572794 | |
| Connection: keep-alive | |
| Date: Sat, 23 Nov 2013 04:24:40 GMT | |
| Last-Modified: Fri, 22 Nov 2013 05:12:40 GMT | |
| ETag: "78282433fb697dd3613613ff55d734c1" | |
| Accept-Ranges: bytes | |
| Server: AmazonS3 |