ror, scala, jetty, erlang, thrift, mongrel, comet server, my-sql, memchached, varnish, kestrel(mq), starling, gizzard, cassandra, hadoop, vertica, munin, nagios, awstats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn bfc | |
[program] | |
(let [allowed #{\+ \- \< \> \[ \] \.} | |
src (->> program (filter allowed) | |
(interpose \space) (apply str)) | |
fns (zipmap '(- + < > . ?) (repeatedly gensym))] | |
(letfn [(bfc* [s] | |
(if (vector? s) | |
`(while (not (~(fns '?))) ~@(map bfc* s)) | |
`(~(fns s))))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns potato.core | |
(:use [slingshot.slingshot :only [throw+ try+]]) | |
(:use [clojure.string :only [trim split]])) | |
;; use this provide template values at write time (i.e. not compile time). | |
;; "name" will be the name of the template variable. "context", when not nil, | |
;; will be the value previously returned by *template-value* for the enclosing | |
;; section. | |
(defn ^:dynamic *template-value* [name context]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns example.storm.clj.spout.kafka-spout | |
(:import ; [example.storm.spout UnreliableKafkaSpout] | |
[storm.kafka HostPort KafkaSpout SpoutConfig StringScheme])) | |
(def ^:dynamic *kafka-hosts* ["kafka-1.example.net" | |
"kafka-2.example.net" | |
"kafka-3.example.net"]) | |
(def ^:dynamic *kafka-ports* [9093 | |
9094 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defbolt split-category ["category" "event"] | |
[tuple collector] | |
(let [event (.getString tuple 0) | |
category "testing_category2"] | |
(comment | |
(emit-bolt! collector [category event] :anchor tuple) | |
) | |
(emit-bolt! collector [category event] :anchor tuple :stream "3") | |
(ack! collector tuple))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(barber). | |
-export([run/2, barber/1, clients/1, simulator/2]). | |
-define(CUT_DUTAION, 20). | |
run(RoomSize, Duration) -> | |
% create barber | |
BPid = spawn(?MODULE, barber, [?CUT_DUTAION]), | |
% run simulartor with barber PID | |
SPid = spawn(?MODULE, simulator, [BPid, RoomSize]), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val wc = Wildcard | |
val x = Variable "x" | |
val y = Variable "y" | |
val z = Variable "z" | |
fun tpl vs = Tuple vs | |
fun pair (a,b) = Tuple [a,b] | |
fun tp ps = TupleP ps | |
fun pp (a,b) = TupleP [a,b] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nltk | |
import pandas as pd | |
import re | |
import pprint | |
import operator | |
import csv | |
import logging | |
from stop_words import get_stop_words | |
from collections import defaultdict | |
from gensim import corpora |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_allocations(self, date, quantity, cap): | |
"""Figure out ideal allocations for a given date""" | |
# { | |
# coin_name: (percent_allocation, data) | |
# } | |
top_market = self.get_top_market(date, quantity) | |
total_cap = sum([coin.market_cap for coin in top_market]) | |
allocations = [{ |