Skip to content

Instantly share code, notes, and snippets.

View epoch-voters.js
/* eslint-env mocha */
'use strict'
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
const CRDT = require('../')
const transmit = require('./transmit')
dirkmc / interceptor.js
Last active Jan 20, 2016
Intercept requests from Amazon ELB and proxy them to a back end service depending on the IP indicated by the PROXY protocol
View interceptor.js
// Config looks like this:
proxy: {
port: 5000,
// Indicates if there is a PROXY protocol enabled Load Balancer
// between us and the client
useProxyProtocol: true,
status: {
path: '/status.json',
// How many times can a host fail to respond before it is
View interceptor.js
var _ = require('underscore');
var async = require('async');
var config = require('config');
var request = require('superagent');
var conntrack = require('service-base').net.conntrack;
var logger = require('service-base').logger;
var errorHandler = require('errorhandler');
var httpProxy = require('http-proxy');
var iphash = require('./iphash');
var env = process.env.NODE_ENV || 'development';
dirkmc / gist:1509670
Created Dec 22, 2011 — forked from schacon/gist:1
the meaning of gist
View gist:1509670
This is gist.
There are many like it, but this one is mine.
It is my life.
I must master it as I must master my life.
Without me gist is useless.
Without gist, I am useless.
View scala-list-map.markdown

Use to transform a list of elements into another list:

val fruitPics = List("banana.jpg", "orange.jpg", "strawberry.jpg", "apple.jpg")
val fileSizes = => new, fruit).length)
// fileSizes: List(12321423, 643423, 234233, 2342343)
View scala-list-for-each.markdown

Use foreach to iterate over a list

val fruits = List("banana", "orange", "strawberry", "apple", "pear")
fruits.foreach(fruit => println(fruit))

For simple operations you can just use an underscore instead of naming the argument:

dirkmc / scala-list-example.markdown
Created Dec 22, 2011
Creating Lists with Scala
View scala-list-example.markdown

Scala encourages developers to create data structures that cannot be modified.

To create an immutable list:

val fruits = List("apple", "pear", "orange")

Concatenate two lists:

dirkmc / newgist.markdown
Created Dec 22, 2011
Testing out a new gist
View newgist.markdown

Just testing this out for now.

Here's some explicitly marked java code:

    import java.lang.String;
    public static void main(String args[]) {
        System.out.println("cheese v3.0");
import org.scribe.extractors.UrlParameterExtractor;
// import ...
public class TwitterAuth extends Controller {
public static void signInWithTwitter() throws Exception {
Token requestToken = Twitter.getService().getRequestToken();
Cache.set(requestToken.getToken(), requestToken, "60min");
String authorizationUrl = Twitter.getService()