Skip to content

Instantly share code, notes, and snippets.

View jeremyheiler's full-sized avatar

Jeremy Heiler jeremyheiler

View GitHub Profile
@hiredman
hiredman / scratch.clj
Created March 9, 2013 02:02
parallel require
(alter-var-root #'require
(fn [o-require]
(fn [& args]
(let [{opts true nses false} (group-by keyword? args)]
(doall
(map #(.join %)
(doall
(for [ns nses]
(doto (Thread. #(apply o-require ns opts))
.start)))))))))
@qtrfeast
qtrfeast / Editing Clojure with Emacs
Last active July 5, 2022 13:32
Get started editing Clojure in Emacs with this basic config.
Check out README.md to get started editing Clojure with Emacs.
@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)]
;; 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)))]
# 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
@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
@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.

@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:
(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]))