A Pen by Dinesh Vasudevan on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module I18n | |
| module Backend | |
| class SimpleMock < Simple | |
| def translate(locale, key, options = {}) | |
| key_with_interpolations = key.to_s + "#{options.map(&:to_s).join(",")}" | |
| case super(:en_dev, key, options) | |
| when String | |
| key_with_interpolations | |
| when Array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load Gem.bin_path('rspec-core', 'rspec') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sidekiq::Testing.inline! # Run async worker jobs synchronous |
Forked from Hugo Giraudel's Pen Demo Flexbox 1.
A Pen by Dinesh Vasudevan on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'net/http' | |
| require 'xmlsimple' | |
| url = "http://www.user-agents.org/allagents.xml" | |
| xml_data = Net::HTTP.get_response(URI.parse(url)).body | |
| data = XmlSimple.xml_in(xml_data) | |
| agents = data['user-agent'].select{|agent| type = agent["Type"].first; type.include?("R") || type.include?("S")} | |
| agent_names = agents.collect {|agent| agent["String"].first} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # mds is the spotlight index worker | |
| # you could see what it indexes using this command | |
| # http://blog.bm5k.com/2012/05/02/dont-index-your-database/ | |
| sudo fs_usage -w -f filesys mdworker | egrep "open" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var module = { | |
| exports: {} | |
| }; | |
| // If you require a module, it's basically wrapped in a function | |
| (function(module, exports) { | |
| exports = function (n) { return n * 1000 }; | |
| }(module, module.exports)) | |
| console.log(module.exports); // it's still an empty object :( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Object.create = function(o) { | |
| function F() {}; | |
| F.prototype = o; | |
| return new F(); | |
| }; | |
| var inheritP = function(child, parent) { | |
| parentDup = Object.create(parent.prototype); | |
| parentDup.constructor = child; | |
| child.prototype = parentDup; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function t1(a, b, c) { | |
| console.log(a, b, c); | |
| } | |
| t1(1, 2, 3); // 1 2 3 | |
| t2 = t1.bind(undefined, 10); | |
| t2(2, 3); // 10 2 3 | |
| t3 = t2.bind(undefined, 20); // t3 = t1.bind(undefined, 10, 20); |