Skip to content

Instantly share code, notes, and snippets.

@jstaffans
jstaffans / clojutre2015.md
Last active September 11, 2015 14:25
ClojuTRE 2015

Hoplon and Javelin

  • Your framework needs a target. Hoplon's target is SPAs, large applications with long lifetimes. Optimized for total cost of ownership.
  • Three state machines in one:
    • persistent (business) state
    • transient/app: what can the user do next? workflow
  • Hoplon app coordinates the different states
  • Javelin is the app part (the spreadsheet of your application)
  • provides formula cells (output) and functions (input).
@jstaffans
jstaffans / gist:678f402e58da5b9497db
Created September 10, 2015 17:48
Nested schema check
(defrecord ScalarSchema [name type]
Schema
(spec [this] (schema.spec.leaf/leaf-spec
(schema.spec.core/precondition this
#(nil? (s/check type %))
#(list 's/check type %))))
(explain [this] "Some explanation")
)
@jstaffans
jstaffans / gist:0164be9a5cc9f77655ab
Last active September 8, 2015 18:13
Introspection
{
__schema {
types {
name
kind
fields {
name
type {name, kind, ofType {name, kind} }
}
}
@jstaffans
jstaffans / musings.clj
Last active September 1, 2015 06:49
Nested data sources with muse
;; Trying to traverse an AST whose root is a list
(defrecord ParentDS []
muse/DataSource
(fetch [_]
(async/go [{:id 1 :name "Parent 1"} {:id 2 :name "Parent 2"}]))
muse/LabeledSource
(resource-id [_]
:some-label))
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 19 columns, instead of 9 in line 8.
1, att, den, ett, där, fin, han, hon, jag, kan, men, min, oss, och, sin, skall, som, till, om
2, mitt, in, kom, dem, mig, dig, ditt, hade, hos, man, sig, sitt, vill, dit, från, upp, bra, i dag
3, henne, honom, liten, vem, klass, bara, efter, barn, alla, stor, därför, skulle, läsa, rolig, tack, över, finns, flicka
4, går, fanns, kväll, kommer, eller, fick, hemma, vacker, ensam, fest, alltid, aldrig, bästa, fått, gång, också, lov, någon
5, något, blomma, först, ingen, bättre, kunna, gammal, genom, under, igen, hjälp, ingenting, jorden, kanske, göra, mycket, ledsen, ofta
6, tycker, lätt, morgon, många, pojke, regn, vilket, själv, snälla, sommar, sova, säga, än, tänka, allting, gjorde, vinter, visst
7, vän, ändå, ännu, överallt, rädd, cykel, riktig, viktig, strax, person, adjö, berätta, natur, sist, farlig, känna, svensk, ge
8, ledsen, Finland, hej, leva, precis, plötsligt, älska, hälsa, lilla, timme, män, människor, trött, ung, ungefär, lång, omkring, värld
9, länge, igenom, även, lärare, vacker, ordning, varje,
@jstaffans
jstaffans / assoc-time.clj
Created May 11, 2015 14:26
assoc-time macro
(defmacro assoc-time
"Evaluates expr and assocs the time it took in msecs with the result of expr."
[expr]
`(let [start# (System/currentTimeMillis)
ret# ~expr]
(assoc ret# :time (- (System/currentTimeMillis) start#))))
@jstaffans
jstaffans / clojured_2015.md
Last active August 29, 2015 14:14
ClojureD notes

Notes from ClojureD 24.1.2015

Albrecht Schmidt: "Start your engine: My Clojure Bot in the Hello World Open 2014"

  • Hello World Open: programming contest organised by Reaktor and Supercell with ~2500 teams, worldwide distribution
    • Client-server car race, cards driven with some parameters such as decelerate/accelerate, change lanes
    • Organisers provided test server with simple testing UI
  • Parameters for car are quite simple: current angle, position etc
  • Clojure works well for processing simple data structures like this - analysis, storing, examining
  • Used Incanter to plot bot data during test (throttles vs. angles)
# seed: -162143530
53
56 33
33 81 35
98 5 86 71
64 6 8 33 91
60 8 60 55 3 25
97 50 20 33 72 47 5
63 82 57 1 29 32 26 80
66 16 83 1 37 15 73 30 58
@jstaffans
jstaffans / Git config aliases
Created May 22, 2014 12:00
.gitconfig alias section
[alias]
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
dl = "!git ll -1"
dlc = diff --cached HEAD^
cp = cherry-pick
st = status -s
cl = clone
@jstaffans
jstaffans / tmux.conf
Last active August 29, 2015 13:58 — forked from shinzui/tmux.conf
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
# URLs to read:
#