Skip to content

Instantly share code, notes, and snippets.

@srijs
srijs / .vimrc
Last active December 12, 2015 03:28
syntax on
set relativenumber
set sw=2
set tabstop=2
set expandtab
set laststatus=2
set background=dark
bind-key b send-prefix
set -g default-terminal "screen-256color"
set -s escape-time 0
set-option -g set-clipboard on
set -g status-interval 1
@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.
@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 / 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;
};
<?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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

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:

@srijs
srijs / AnIntro.md
Last active August 29, 2015 14:09 — forked from chrisdone/AnIntro.md

Basic unit type:

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

Basic functions:

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 {