Skip to content

Instantly share code, notes, and snippets.

View jeroenvandijk's full-sized avatar

Jeroen van Dijk jeroenvandijk

View GitHub Profile
@jeroenvandijk
jeroenvandijk / datomic_in_memory_excision_test.clj
Last active November 11, 2021 02:36
Tests the memory usage of in-memory Datomic db when excising data
(require '[datomic.api :as d])
(def db-uri "datomic:mem://hello")
(d/create-database db-uri)
(def conn (atom {}))
(reset! conn (d/connect db-uri))
(def schema [{:db/id (d/tempid :db.part/db)
:db/ident :dummy/content
@jeroenvandijk
jeroenvandijk / sat.clj
Last active August 29, 2015 14:14 — forked from jmgimeno/sat.clj
;Code from http://peteriserins.com/2011/12/23/sat-in-clojure-core-logic.html
;; lein try org.clojure/core.logic "0.8.8"
(require '[clojure.core.logic :refer [conde run* fresh ] :as l])
(declare goalify)
(defn and-rewrite [expr]
`(conde
@jeroenvandijk
jeroenvandijk / failing_mapfn.clj
Created October 21, 2014 12:51
Examples of where mapfn fails
;; All these cases below give the following exception:
;; ...
;; Caused by: java.lang.RuntimeException: Unable to resolve symbol: l in this context
(use 'cascalog.api)
;; clojure.lang.APersistentMap$KeySeq
(let [l (keys {:a 1})]
(?<- (stdout) [?a]
([[1]] ?b)
(use '[datomic.api :only [q db] :as d])
(def uri "datomic:mem://accounts")
;; create database
(d/create-database uri)
;; connect to database
(def conn (d/connect uri))

Docker Cheat Sheet

Why

Why Should I Care (For Developers)

"Docker interests me because it allows simple environment isolation and repeatability. I can create a run-time environment once, package it up, then run it again on any other machine. Furthermore, everything that runs in that environment is isolated from the underlying host (much like a virtual machine). And best of all, everything is fast and simple."

TL;DR, I just want a dev environment

@jeroenvandijk
jeroenvandijk / sky_query.clj
Created February 12, 2014 08:50
Example of a query in a Clojure Skydb clone
; On the dataset from 2012-04-11-15 of http://www.githubarchive.org/
; how many people create a repo after pushing
(run-query database
(when-action
"PushEvent"
(within-step 1
(when-action
"CreateEvent"
(within-step 1
(select-count))))))
;; Ported from Java example in http://stackoverflow.com/questions/47177/how-to-monitor-the-computers-cpu-memory-and-disk-usage-in-java#47199
;; Apparantly, when there is more than 4GB or Ram and on Java 32-bit there is a bug with memory size, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6853676
(import '[java.lang.management ManagementFactory]
'[java.lang.management OperatingSystemMXBean]
'[java.lang.reflect Method]
'[java.lang.reflect Modifier])
(defn print-usage []
(let [operatingSystemMXBean (ManagementFactory/getOperatingSystemMXBean)
@jeroenvandijk
jeroenvandijk / hyperloglog.clj
Last active December 28, 2015 14:29
Alternative Hyperloglog implementation for Cascalog
;; Possibly more performant version due the absence of multimethods of http://screen6.github.io/blog/2013/11/13/hyperloglog-with-cascalog.html
;; Needs to be tested
(defprotocol IHyperLogLogMerge
(hyperloglog-val [this])
(merge [this other])
(merge-with-hyperloglog [this other-hll]))
(extend-protocol IHyperLogLogMerge
nil
(hyperloglog-val [this] nil)
@jeroenvandijk
jeroenvandijk / core.clj
Created September 20, 2013 11:07
Simple example to show warnings cause by prismatic/schema
;; Generated by lein new schema-test
(ns schema-test.core
(:require [schema.core :as s])
(:gen-class))
(defn -main [& args]
(println "hi")
)
;; Example sink function by Nathan https://groups.google.com/forum/#!msg/cascalog-user/d5STyIkO9yA/ynUKwj6HLdEJ
(defn count-stdout [sq]
[(stdout)
(<- [?count]
(sq :>> (get-out-fields sq))
(c/count ?count))] )
(?<- count-stdout
[?person ?age ?gender]
(age ?person ?age)