Skip to content

Instantly share code, notes, and snippets.

/**
* Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.
*
* This can be used with JS designed for browsers to improve reuse of code and
* allow the use of existing libraries.
*
* Usage: include("XMLHttpRequest.js") and use XMLHttpRequest per W3C specs.
*
* @todo SSL Support
* @author Dan DeFelippi <dan@driverdan.com>
@ericmoritz
ericmoritz / chunk.py
Created April 26, 2012 19:16
Django chunk filter
from django.template import Library
register = Library()
def chunk(l, n):
return (l[i:i+n] for i in range(0, len(l), n))
@ericmoritz
ericmoritz / eam.json
Created January 18, 2019 01:17
QMK Firmware JSON
{
"keyboard": "iris/rev2",
"keymap": "eam",
"layout": "LAYOUT",
"layers": [
[
"KC_ESC",
"KC_LGUI",
"KC_LCTL",
"KC_LSFT",
@ericmoritz
ericmoritz / main.rs
Last active February 19, 2018 17:21
extern crate failure;
#[macro_use]
extern crate failure_derive;
use std::process;
use std::io::{self, Read};
use failure::Error;
#[derive(Debug, Fail)]
@ericmoritz
ericmoritz / counter.py
Created March 22, 2011 21:04
A counter stored in Riak that handles conflict resolutions on read
import logging
import riak
log = logging.getLogger(__name__)
class RiakCounter(object):
def __init__(self, bucket, key):
self.bucket = bucket
self.bucket.set_allow_multiples(True)
self.key = key

Keybase proof

I hereby claim:

  • I am ericmoritz on github.
  • I am ericmoritz (https://keybase.io/ericmoritz) on keybase.
  • I have a public key whose fingerprint is F908 1749 3371 74DB 3811 1AA8 D500 8CCC E761 725F

To claim this, I am signing this object:

@ericmoritz
ericmoritz / keybase.md
Created January 10, 2017 15:00
keybase.md

Keybase proof

I hereby claim:

  • I am ericmoritz on github.
  • I am ericmoritz (https://keybase.io/ericmoritz) on keybase.
  • I have a public key ASBTGiXyjPdJuyILRRS9xtR-TiE7BYf0IhotWf_h5LvimAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am ericmoritz on github.
  • I am ericmoritz (https://keybase.io/ericmoritz) on keybase.
  • I have a public key ASBTGiXyjPdJuyILRRS9xtR-TiE7BYf0IhotWf_h5LvimAo

To claim this, I am signing this object:

@ericmoritz
ericmoritz / rediscluster.js
Created November 11, 2011 05:33
Premature redis cluster support for node.js
var redis = require("redis");
function randrange(stop) {
return Math.floor(Math.random() * stop * 1000 % stop)
}
function Cluster(hosts) {
var that = this;
var hosts = hosts || [];
this.clients = {};