Order Request:
POST /orders HTTP/1.1
Host: api.point101.com
Content-Type: application/json
X-App-ID: simplybuy.it
X-App-Token: deadbeef123
X-HMAC: abc1234567890
// pretty awesome function to get a path to any given element | |
function pathToNode(node) { | |
if (node.id.length > 0) { return "#" + node.id; } | |
var path = []; | |
var parents = $(node).parents().toArray().reverse(); | |
var deferred = $.Deferred(); | |
var self = this; | |
function qualifiers(node) { | |
if (node.id.length > 0) { | |
return "#" + node.id; |
Order Request:
POST /orders HTTP/1.1
Host: api.point101.com
Content-Type: application/json
X-App-ID: simplybuy.it
X-App-Token: deadbeef123
X-HMAC: abc1234567890
In order to make pairing very efficient I always found a code styleguide very helpful to minimize discussions around code style.
The goal is to keep code highly readable under any circumstances. Contributing and adhering to this styleguide will help improve overall code readability.
A good reference to set discussions around unwritten rules: https://github.com/bbatsov/ruby-style-guide
# lets say this is the response we receive | |
response = { | |
"results" => { | |
"total_count" => 15, | |
"per_page" => 100, | |
"companies" => [ | |
{ | |
"company" => { | |
"name" => "Foo Bar Ltd", | |
"registered_address" => { ... }, |
Calculating ------------------------------------- | |
rails 688 i/100ms | |
rails_default 1496 i/100ms | |
manual 1875 i/100ms | |
------------------------------------------------- | |
rails 7165.7 (±1.0%) i/s - 72240 in 10.082247s | |
rails_default 16039.7 (±1.0%) i/s - 161568 in 10.074064s | |
manual 20281.0 (±1.7%) i/s - 204375 in 10.080226s | |
Comparison: |
require "pstore" | |
require "json" | |
class JSON::Store < PStore | |
def dump(table) | |
# use JSON.pretty_generate(table) to make it even more human readable | |
JSON.generate(table) | |
end | |
require "benchmark" | |
require "bigdecimal" | |
require "bigdecimal/util" | |
Benchmark.bm do |x| | |
class Foo | |
VALUE = BigDecimal("1.2") | |
def to_d | |
VALUE |