Skip to content

Instantly share code, notes, and snippets.

View sql.clj
;; virtual fields map to multimethods that implement helpers
(sql/load :rental_ads 42 :car :user :picture_url)
;; => "https://..."
;; multimethods can look at meta information for maps
(meta rental-ad)
;; => {:table :rental_ads}
tgk / sql.clj
Created Jun 26, 2020
Alternative to load-object
View sql.clj
;; alternative strategy for navigating maps
(def rental-ad {:id 42, :car_id 56, :name_and_model "Peugeot 208"})
(follow rental-ad :name_and_model)
;; => "Peugeot 208"
(follow rental-ad :car)
;; => {:user_id 3, :car_type_id 5}
tgk / aarhus_0001.clj
Created Jan 9, 2017
Notes from the first aarhus.clj meetup and dojo
View aarhus_0001.clj
;; Purpose of aarhus.clj and these meetups
;;; To get better
;;; To meet other Clojure peeps in Aarhus/East Jutland
;; Intro round
;;; Name, interests, experience with Clojure?
;; Agenda
;; Me talking (< 30m)
tgk / pruttemaskine.ino
Created Oct 23, 2016
Fart machine for Rosalina - source
View pruttemaskine.ino
void fart(int pitch) {
int duration = random(300, 1000);
tone(8, pitch, duration);
int fartPitch() {
View gist:9562a094037361978c6382bd06d405e1
tgk / spec_test.clj
Created Sep 12, 2016
A very small script for running spec tests. I have a lein alias for running the main function and that works quite well.
View spec_test.clj
(ns spec-test
(:require [clojure.pprint]
[ :refer (refresh)]))
(defn run-analysis
(let [results (clojure.spec.test/check)
failures (remove (comp true? :result :clojure.spec.test.check/ret) results)]
View gist:ff513c551981cff34dcaa0e833fcb62a
## Tilfældigheder
## Vi kan printe ting ud til skærmen med "puts"
# puts "Hejsa"
## Det kan vi bruge til at undersøge funktioner
## "rand" giver os et tilfældigt kommatal mellem 0 og 1:
# puts rand
tgk / data.tsv
Created Jul 21, 2014
Adapted line chart
View data.tsv
date close
1-May-12 0.114
27-Apr-12 0.12
tgk / quilt_proposal.edn
Created May 14, 2014
An attempt at understanding Quilt
View quilt_proposal.edn
;; These notes describe the snapshots of a shared state between
;; pariticipants in a system co-ordinated using CRDT methods, hopefully
;; matching the Quilt notes from @cemerick at
;; The ambition is to built systems where network failures, replays
;; etc. can be safely ignored (instead of just being ignored).
;; Maintaining the "timestamps" for the append only database is the only
;; thing I feel I don't grok. There are some notes at the end of the
;; gist. Hoping for feedback or pointers!
View user.clj
(ns user
(:require [schema.core :as s]
[schema.utils :as s-utils]))
(defn filter-walker
"Creates a walker which replaces sub-trees in values of maps with nil
if they do not conform to schema."
(fn [schema]