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 'json' | |
require 'ostruct' | |
data = '{"a": {"b": 1}}' | |
result = JSON.parse(data, object_class: OpenStruct) | |
result.a.b # => 1 |
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
# Check if two arrays have exactly the same elements (we don't care about order) | |
keys = [2,1] | |
1. keys.sort == [1, 2] | |
2. Set.new(keys) == [1,2].to_set | |
3. (keys - [1,2]).empty? | |
4. (keys - [1,2,]).size == 0 |
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 'delegate' | |
require 'benchmark' | |
class User | |
end | |
class UserPresenter < SimpleDelegator | |
end | |
N = 10_000 |
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 'dcell' | |
DCell.start :id => "client-node", :addr => "tcp://127.0.0.1:2032" | |
blog = DCell::Global[:blog] | |
post = blog.new_post | |
sleep 3 | |
post.title = "hello dcell" | |
blog.publish_post(post) |
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
// Ember.js - some concerns | |
//a) tightly coupling | |
App.NewGameView = Em.View.extend({ | |
click: function() { | |
App.lobbyController.newGameClicked(); | |
} | |
}) |
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 'bundler/capistrano' | |
set :application, "multicomm" | |
set :repository, "git@XXXX" | |
set :scm, :git | |
set :user, 'multicomm' | |
set :deploy_to, '/var/lib/multicomm' | |
set :use_sudo, false | |
set :git_enable_submodules, 1 |
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 pg = require('pg'); | |
var http = require('http'); | |
var conString = "tcp://node:[email protected]/postgres"; | |
var client = new pg.Client(conString); | |
client.connect(); | |
http.createServer(function(req, res) { |
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 'benchmark' | |
module Foo | |
def bar | |
end | |
def baz | |
end |
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 Foo | |
def bar | |
end | |
def baz | |
end |
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
a = *"Hello" #=> ["Hello"] |
NewerOlder