This file contains hidden or 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
#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) |
This file contains hidden or 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 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)) |
This file contains hidden or 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
(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])) |
This file contains hidden or 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
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: |
-
Client makes authenticated connection to the user stream endpoint.
Authentication in headers or query string.
Endpoint:
wss://stream-channel.app.net/stream/user
(WebSocket) orhttps://stream-channel.app.net/stream/user
(streaming HTTP).If authentication fails, etc., client will be disconnected immediately with the appropriate HTTP error code.
This file contains hidden or 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
- 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 |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
;; 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)))] |
This file contains hidden or 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
; 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)] |