Skip to content

Instantly share code, notes, and snippets.

View jeremyheiler's full-sized avatar

Jeremy Heiler jeremyheiler

View GitHub Profile
@mrflip
mrflip / tuning_storm_trident.asciidoc
Last active October 8, 2024 15:18
Notes on Storm+Trident tuning

Tuning Storm+Trident

Tuning a dataflow system is easy:

The First Rule of Dataflow Tuning:
* Ensure each stage is always ready to accept records, and
* Deliver each processed record promptly to its destination
@tonyg
tonyg / mtl2.rkt
Last active December 18, 2015 22:59
From zero to cooperative threads in 15 lines of Racket code (after <http://www.haskellforall.com/2013/06/from-zero-to-cooperative-threads-in-33.html>)
#lang racket/base
(require data/queue)
(provide fork yield done run-threads)
(define current-runqueue (make-parameter #f))
(define (fork thunk)
(enqueue! (current-runqueue) (lambda () (thunk) (done))))
(define (yield)
(defn extraleave
[n coll]
(->> (repeat coll)
(map drop (range n))
(map (partial take-nth n))))
(comment
(->> (interleave [1 2 3] [4 5 6])
(extraleave 2)) ;=> ((1 2 3) (4 5 6))
(require '[paprika.core :as adn])
;; This returns a sequence your of vectors, one for each of the people you follow.
;; Each vector contains the user's username and the date of their last post.
;; The sequence is in ascending order by the date of their last post
;; Careful, though. The lookup is N+1.
(sort-by first
(map (juxt :created-at #(get-in % [:user :username]))
@parkr
parkr / command-line-email-client.txt
Last active December 18, 2015 10:39
command-line-email-client
A command-line email client. We need one. A good one.
Much of the interaction inspiration comes from vim. You have
@i0rek and @dschneider to thank for that.
My ideal flow:
1. Boot client
# launches interactive mail listing, much like nerdtree.
2. Navigate using vim bindings: hjkl. Additionally:
@mthurman
mthurman / user_streams.md
Last active December 18, 2015 05:49
App.net User Streams Spec (BETA)

User Streaming

  1. Client makes authenticated connection to the user stream endpoint.

    Authentication in headers or query string.

    Endpoint: wss://stream-channel.app.net/stream/user (WebSocket) or https://stream-channel.app.net/stream/user (streaming HTTP).

    If authentication fails, etc., client will be disconnected immediately with the appropriate HTTP error code.

@garethrees
garethrees / gist:5591027
Last active October 14, 2020 19:44
Ansible set timezone on Ubuntu host
- name: Group by Distribution
hosts: all
tasks:
- group_by: key=${ansible_distribution}
- name: Set Time Zone
hosts: Ubuntu
gather_facts: False
tasks:
- name: Set timezone variables
# time
# ====
macro time(ex)
quote
local t0 = time_ns()
local val = $(esc(ex))
local t1 = time_ns()
println("elapsed time: ", (t1-t0)/1e9, " seconds")
val
;; factory factories, etc.
(def dbf (doto (DocumentBuilderFactory/newInstance)
(.setNamespaceAware true)))
(def doc-builder (.newDocumentBuilder dbf))
(defn namespace-map
"Returns an implementation of NamespaceContext ... actual usefulness TBD"
[mapping]
(let [prefixes (fn [uri] (map key (filter #(= uri (val %)) mapping)))]
@alandipert
alandipert / piseq.clj
Last active December 14, 2015 23:19
Lazy sequence of the digits of pi
; based on http://bellard.org/pi/pi.c
(defn inv-mod
"Returns the inverse of (mod x y)"
([x y] (inv-mod y x y 1 0))
([y u v c a]
(let [q (long (Math/floor (/ v u)))
c' (- a (* q c))
u' (- v (* q u))]
(if (zero? u')
(let [m (mod c y)]