Skip to content

Instantly share code, notes, and snippets.

accept a required header param [OLD] x 110,222 ops/sec ±2.40% (84 runs sampled)
accept a required header param [NEW] x 5,673,283 ops/sec ±0.92% (87 runs sampled)
=> fastest is accept a required header param [NEW]
accept a required path param [OLD] x 111,359 ops/sec ±1.77% (87 runs sampled)
accept a required path param [NEW] x 67,758,969 ops/sec ±0.48% (92 runs sampled)
=> fastest is accept a required path param [NEW]
accept a required query param [OLD] x 112,662 ops/sec ±1.70% (91 runs sampled)
accept a required query param [NEW] x 29,308,949 ops/sec ±0.76% (93 runs sampled)
=> fastest is accept a required query param [NEW]
accept an optional header param [OLD] x 118,339 ops/sec ±1.96% (89 runs sampled)
2016/01/26 20:46:49 Recovered: runtime error: index out of range
2016/01/26 20:46:49 Message was: type:MsgApp to:2 from:1 term:2 logTerm:2 index:46734 entries:<Type:EntryNormal Term:2 Index:46735 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46736 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46737 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46738 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46739 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46740 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46741 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46742 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46743 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46744 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46745 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46746 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46747 Data:"\"foo\"" > entries:<Type:EntryNormal Term:2 Index:46748 Data:"\"foo\"" > entri
use std::boxed::Box;
use std::option::Option;
use std::result::Result;
pub trait Functor<'a, A, B, F: Fn(&'a A) -> B> {
type Output;
fn fmap(&'a self, f: F) -> Self::Output;
}
pub fn fmap<'a, A, B, X: Functor<'a, A, B, F>, F: Fn(&'a A) -> B>(x: &'a X, f: F) -> X::Output {
@srijs
srijs / AnIntro.md
Last active August 29, 2015 14:09 — forked from chrisdone/AnIntro.md

Basic unit type:

λ> replTy "()"
() :: ()

Basic functions:

Keybase proof

I hereby claim:

  • I am srijs on github.
  • I am srijs (https://keybase.io/srijs) on keybase.
  • I have a public key whose fingerprint is EC2D 944E 44AE E874 239D FBB9 1298 304B E658 60ED

To claim this, I am signing this object:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
-->
<!-- Title: /usr/local/bin/docker; 157.2 MB Pages: 1 -->
<svg width="100%" height="100%"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<script type="text/ecmascript"><![CDATA[
// SVGPan
@srijs
srijs / attemptq.js
Last active August 29, 2015 14:01
Using Q with node-retry
module.exports = function attemptQ (f) {
var d = require('q').defer();
this.attempt(function (i) {
f(i).then(d.resolve.bind(d), function (e) {
this.retry(e) || d.reject(this.mainError());
}.bind(this));
});
return d.promise;
};
@srijs
srijs / gist:b5b21638280875415216
Created May 9, 2014 19:53
Dockerode Timeout + Buffer.limit
var Stream = require('stream'),
Docker = require('dockerode');
var docker = new Docker({socketPath: '/var/run/docker.sock'});
function StreamBuffer () {
Stream.call(this);
this.arr = [];
@srijs
srijs / couchdb_internal_map.js
Last active December 14, 2015 04:49
Debugging CouchDB...
var buf = [];
for (var i = 0; i < State.funs.length; i++) {
map_results = [];
try {
State.funs[i](doc);
buf.push(Couch.toJSON(map_results));
} catch (err) {
handleViewError(err, doc);
// If the error is not fatal, we treat the doc as if it
// did not emit anything, by buffering an empty array.