Skip to content

Instantly share code, notes, and snippets.

@joinr
joinr / changes.clj
Last active July 2, 2020 16:25
Disabled GIL checks with debugging
;;added libpython-clj.python.logging require to libpython-clj.jna.base
(defmacro def-pylib-fn
[fn-name docstring rettype & argpairs]
`(defn ~fn-name
~docstring
~(mapv first argpairs)
(log-info (str [:skipping-GIL-check!
{:name ~fn-name
:thread (current-thread-id)
:gil-thread (.get ^AtomicLong gil-thread-id)}]))
@joinr
joinr / cljgol.clj
Last active May 4, 2020 14:11
cljgol
(ns cljgol.core
(:use [seesaw core color graphics]))
(set! *unchecked-math* true)
(set! *warn-on-reflection* true)
(def wCells 100)
(def hCells 100)
(def cellSize 5)
(def cellColor (color 0 255 0))
@joinr
joinr / bigdeps.edn
Created April 8, 2020 11:52
big dependencies
(["opencv-4.0.1-1.4.4-windows-x86_64.jar" 22.809813]
["opencv-4.0.1-1.4.4-macosx-x86_64.jar" 20.628443]
["opencv-4.0.1-1.4.4-linux-x86_64.jar" 19.319284]
["ffmpeg-4.1-1.4.4-windows-x86_64.jar" 18.106366]
["ffmpeg-4.1-1.4.4-linux-x86_64.jar" 15.769268]
["ffmpeg-4.1-1.4.4-macosx-x86_64.jar" 15.304522]
["google-closure-library-0.0-20170809-b9c14c6b.jar" 6.151731]
["javafx-graphics-13-win.jar" 5.981489]
["clojurescript-1.10.339.jar" 4.548788]
["closure-compiler-unshaded-v20180610.jar" 4.519195]
@joinr
joinr / freed.clj
Last active March 11, 2020 11:34
An alternate implementation that respect's the 1x-only reader principle, and instead uses filthy mutation to attempt to not hold on to the head of the iterator-seq
(defn csv->columns
[input & {:keys [header-row? parser-fn
parser-scan-len]
:or {header-row? true
parser-scan-len 100}}]
(let [uncache! (fn [atm]
(let [res @atm
_ (reset! atm nil)]
res))
rows (raw-row-iterable input)
@joinr
joinr / altparser.clj
Last active March 9, 2020 18:42
No-seq parsing implementation
;;exctracted from original function, refined to
;;work with iterables via eduction.
(defn derive-parsers
[headers parser-fn parser-scan-len data]
(let [n-cols (count headers)]
(if-not parser-fn
;;a bunch of default parsers
(repeatedly n-cols default-column-parser)
;;only sample what we need, don't retain any seq head.
(->> data
@joinr
joinr / analyzer.clj
Last active March 28, 2020 21:36
tools.analyzer.r
(ns tools.analyzer.r
(:require [clojure.tools.analyzer.passes
[emit-form :as default]
[uniquify :refer [uniquify-locals]]]
[clojure.tools.analyzer.jvm :as ana.jvm]))
;;copied directly....
(defmulti -emit-form (fn [{:keys [op]} _] op))
(defn -emit-form*
@joinr
joinr / deps.edn
Last active January 29, 2020 13:45
A fancy repl setup derived from https://asciinema.org/a/296507 by didibus
{:aliases {:repl {:extra-deps {com.bhauman/rebel-readline {:mvn/version "RELEASE"}
io.aviso/pretty {:mvn/version "RELEASE"}
mvxcvi/puget {:mvn/version "RELEASE"}
org.clojure/clojure {:mvn/version "RELEASE"}
com.gfredericks/user.clj {:mvn/version "RELEASE"}
clj-commons/pomegranate {:mvn/version "RELEASE"}}
:main-opts ["-m" "rebel-readline.main"]}
:fancy {:extra-deps {org.clojure/core.async {:mvn/version "RELEASE"}
org.clojure/core.logic {:mvn/version "RELEASE"}
org.clojure/test.check {:mvn/version "RELEASE"}
@joinr
joinr / dagdemo.clj
Last active January 10, 2020 14:33
Exploration for walking dags in parallel
(ns dagdemo
(:require [spork.cljgraph.core :as g]
[clojure.core.async :as async]))
;; A E
;; / \ |
;; B C <- F
;; \ / |
;; D G
@joinr
joinr / lanternademo.clj
Created December 19, 2019 02:53
lanterna demo
(ns lanternademo.core
(:require [lanterna.screen :as screen]))
;;provides a way to track resources and kill rendering from the outside. we
;;could also use an atom and synchronize on it from the rendering loop. I like
;;using future here though, since it keeps our REPL thread free.
(def renderer (atom nil))
(defn kill-rendering! []
(when @renderer
(future-cancel @renderer)))
@joinr
joinr / pool.clj
Last active April 20, 2020 10:55
A simple implementation of string pooling for clojure.data.csv that nets about 4x compression over the naive implementation.
;; Copyright (c) Jonas Enlund. All rights reserved. The use and
;; distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this
;; distribution. By using this software in any fashion, you are
;; agreeing to be bound by the terms of this license. You must not
;; remove this notice, or any other, from this software.
;;string pool modification fork by joinr
(ns clojure.data.csv.pool