Skip to content

Instantly share code, notes, and snippets.

tgk /
Last active Nov 20, 2022
Plot swap

Plotswap November 2022

This is an attempt at sharing plotting files and try our hands on files from other eager plot enthusiasts out there!

The (suggested) format is pretty simple: below is the list of participants in order. Each participant picks a file from the next name after their own on the list and plots it. The participants are also free to do some of the other plots, but this format ensures that everyone both tries their hand on plotting work by someone else and has one of their own works plotted.

Once a plot is done please post it on Mastodon and tag the other participants. Use the hashtag #plotswap (thanks!)

Each partiticipant can list (up to) three pieces we can pick from under their name. We will stick with SVGs for now as that seems to be the common format we all use.

tgk / anti_patterns.clj
Last active Aug 16, 2021
Some Clojure anti-patterns
View anti_patterns.clj
;; Anti patterns
;; Implicit data manipulation anti-pattern
;; Having nested calls manipulating data, instead of explicitly stating
;; what changes are performed to the data
(def h
;; ...
tgk / swing.clj
Created Oct 8, 2012
A Swing example in Clojure
View swing.clj
(ns swing
(:import [javax.swing JFrame JLabel JButton]
[java.awt.event WindowListener]))
(defn swing []
(let [frame (JFrame. "Fund manager")
label (JLabel. "Exit on close")]
(doto frame
(.add label)
(.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
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 /
Last active Apr 19, 2019
Add and remove nodes

Click to add nodes! Nodes near the cursor will be linked to the new node. Clicking an existing node will remove it.

This is an extension of this example, adding the capability of removing nodes by clicking them. This means that dragging is no longer supported.

View gist:9562a094037361978c6382bd06d405e1
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() {
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)]