Skip to content

Instantly share code, notes, and snippets.

@jphackworth
jphackworth / gist:9993090
Created April 5, 2014 14:59
crashey admin functions
user=> (pprint (admin-available-functions)) [13/1239]
{:AdminLog_subscribe
{:file {:required 0, :type "String"},
:level {:required 0, :type "String"},
:line {:required 0, :type "Int"}},
:AdminLog_unsubscribe {:streamId {:required 1, :type "String"}},
:Admin_asyncEnabled {},
:Admin_availableFunctions {:page {:required 0, :type "Int"}},
:Allocator_bytesAllocated {},
:Allocator_snapshot {:includeAllocations {:required 0, :type "Int"}},
@jphackworth
jphackworth / gist:9976805
Created April 4, 2014 15:16
Bulk enqueing with lamina (2 second worker interval)
user=> (def b (map #(add-to-queue inc %) (range 5)))
#'user/b
user=> b
(<< … >> << … >> << … >> << … >> << … >>)
user=> b
(<< … >> << … >> << … >> << … >> << … >>)
user=> b
(<< … >> << … >> << … >> << … >> << … >>)
user=> b
(<< … >> << … >> << … >> << … >> << … >>)
@jphackworth
jphackworth / gist:9976727
Last active August 29, 2015 13:58
Lamina queue example
user=> (start-job-consumer)
nil
user=> (reset! worker-interval 2000)
2000
user=> (def a (add-to-queue inc 1))
#'user/a
user=> a
<< … >>
user=> a
<< … >>
@jphackworth
jphackworth / gist:9976671
Last active August 29, 2015 13:58
Basic queuing with Lamina
;;; Lamina queueing
(def job-queue (lamina/channel))
(def worker-interval (atom 250))
(defn consume-jobs []
(let [{:keys [c f args] :as msg}
@(lamina/read-channel job-queue)]
(Thread/sleep @worker-interval)
(lamina/enqueue c (apply f args))))

Keybase proof

I hereby claim:

  • I am jphackworth on github.
  • I am jph (https://keybase.io/jph) on keybase.
  • I have a public key whose fingerprint is A2FC 705E E920 AC46 D190 668C DF1A 4827 7912 DF21

To claim this, I am signing this object:

@jphackworth
jphackworth / normalize-ticker
Created February 28, 2014 07:52
Normalize exchange ticker data example
(defn normalize-ticker [exchange ticker]
(case exchange
:btce {:last (:last ticker)
:buy (:buy ticker)
:sell (:sell ticker)
:high (:high ticker)
:avg (:avg ticker)
:avg_btc_usd (:avg @btc-usd-price)
:low (:low ticker)
:vol (:vol ticker) ; _usd or _btc
@jphackworth
jphackworth / migration.clj
Created January 30, 2014 06:06
Lobos Migration Example
(ns lobos.migrations
(:refer-clojure
:exclude [alter drop bigint boolean char double float time])
(:use (lobos [migration :only [defmigration]] core schema config helpers)))
(defmigration add-accounts-table
(up [] (create
(tbl :accounts
(varchar :username 30 :unique)
(boolean :admin (default 0))
@jphackworth
jphackworth / migration.clj
Created January 30, 2014 06:03
Lobos Example Migration
(ns lobos.migrations
(:refer-clojure
:exclude [alter drop bigint boolean char double float time])
(:use (lobos [migration :only [defmigration]] core schema config helpers)))
(defmigration add-accounts-table
(up [] (create
(tbl :accounts
(varchar :username 30 :unique)
(boolean :admin (default 0))
package main
import (
"encoding/json"
"fmt"
"github.com/kylelemons/godebug/pretty"
"io/ioutil"
"net/http"
"strconv"
)
@jphackworth
jphackworth / test.clj
Created November 30, 2013 19:08 — forked from adambard/test.clj
; Comments start with semicolons.
; Clojure is written in "forms", which are just
; lists of things inside parentheses, separated by whitespace.
;
; The clojure reader assumes that the first thing is a
; function or macro to call, and the rest are arguments.
;
; Here's a function that sets the current namespace:
(ns test)