Skip to content

Instantly share code, notes, and snippets.

@joinr
joinr / demo.clj
Created October 20, 2022 06:38
Fancy derive types for clojure
(ns demo
(:require [fancyclass :as fancy :refer [derives?]]))
(defprotocol SomeParentType)
(fancy/derived-type CustomMap [SomeParentType :base/map :arbitrary/tag])
;; demo> (def m (->CustomMap :name "Bilbo" :occupation "Burglar"))
;; #'demo/m
;; demo> m
;; {:occupation "Burglar", :name "Bilbo"}
(ns util
(:refer-clojure :exclude [pmap])
(:require [clojure.core.async :as async]))
(defn chan? [x]
(instance? clojure.core.async.impl.channels.ManyToManyChannel x))
(defn guess-physical-cores
"Hueristic used to account for likely prevalent
hyperthreading influencing the supposed available
@joinr
joinr / hexspeakfast.clj
Last active September 27, 2022 19:39
Exploring improvements on the relatively slow HexSpeak demo from https://github.com/ttsiodras/HexSpeak
;;performance opts by joinr
;;running openjdk 1.8 because reasons, bumped clojure dep to 1.11.1
(ns thanassis.hexspeakfast
(:gen-class))
(set! *warn-on-reflection* true)
(set! *unchecked-math* :warn-on-boxed)
(defn slength ^long [^String x] (.length x))
@joinr
joinr / req.edn
Created June 13, 2022 06:13
a sample request map
{:reitit.core/match
#reitit.core.Match{:template "/test2", :data {:handler #function[rental.routes.home/home-routes/fn--30830]},
:result
#reitit.ring.Methods{:get #reitit.ring.Endpoint{:data {:handler #function[rental.routes.home/home-routes/fn--30830]},
:handler #function[rental.routes.home/home-routes/fn--30830],
:path "/test2", :method :get, :middleware []},
:head #reitit.ring.Endpoint{:data {:handler #function[rental.routes.home/home-routes/fn--30830]},
:handler #function[rental.routes.home/home-routes/fn--30830],
:path "/test2", :method :head, :middleware []},
:post #reitit.ring.Endpoint{:data {:handler #function[r
@joinr
joinr / setup.org
Last active May 4, 2022 17:58
A setup guide for getting spacemacs and cider and lein working from a bare environment. We also turn on CUA mode to avoid dodgy emacs bindings.

Clojure Setup With SpaceMacs + Clojure Layer (Ubuntu)

We will use spacemacs as our editor here, although I choose to follow the emacs route for setup (spacemacs offers an alternative vim mode that many people like. We also set things up with leiningen. For an alternate guide that goes more in depth with tooling, and follows the vim/spacemacs conventions see practicalli spacemacs.

update

sudo apt-get update
@joinr
joinr / intcasts.clj
Last active March 20, 2022 21:28
an exploration of int casting and long reads in clojure
(require '[clj-java-decompiler.core :refer [decompile disassemble]])
(require '[primitive-math])
(set! *warn-on-reflection* true)
(set! *unchecked-math* :warn-on-boxed)
(decompile
(fn []
(let [xs (int-array 10)
idx 0]
(aset xs idx 0))))
@joinr
joinr / Profiler.diff
Last active March 12, 2022 19:48
minor changes
diff --git a/gamedata/lua/lua/sim/Profiler.lua b/gamedata/lua/lua/sim/Profiler.lua
index 89ef924..d3d106d 100644
--- a/gamedata/lua/lua/sim/Profiler.lua
+++ b/gamedata/lua/lua/sim/Profiler.lua
@@ -22,12 +22,25 @@ local thread = false
--- Data that we send over to the UI
local data = CreateEmptyProfilerTable()
+-- change:
+
@joinr
joinr / platoon.org
Created August 20, 2021 17:30
SCFA Explorations

lua/platoon.lua

Exploring coarse pathfinding code.

PlatoonGenerateSafePathToLOUD

Many internally lifted (e.g. local) functions here designed to leverage cached information from navgraphs and previous static path computations to prevent submitting path requests to the engine.

@joinr
joinr / transducerdataset.clj
Last active October 14, 2021 17:43
exploring datasets and transducers in tech.ml.dataset
(ns transducertest
(:require [tech.v3.dataset :as ds]
[clojure.core.reducers :as r]))
(def d (ds/->dataset {:a [1 2 3] :b [:foo :bar :baz]}))
(defprotocol ITransposable
(-row-major [obj])
(-column-major [obj]))
@joinr
joinr / bmxyz.qgs
Last active May 17, 2021 10:10
qgis tile maker
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="3.18.2-Zürich" projectname="" saveUser="tom" saveDateTime="2021-05-17T05:05:20" saveUserFull="tom">
<homePath path=""/>
<title></title>
<autotransaction active="0"/>
<evaluateDefaultValues active="0"/>
<trust active="0"/>
<projectCrs>
<spatialrefsys>
<wkt>PROJCRS["WGS 84 / Pseudo-Mercator",BASEGEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]],CONVERSION["Popular Visualisation Pseudo-Mercator",METHOD["Popular Visualisation Pseudo Mercator",ID["EPSG",1024]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",