Skip to content

Instantly share code, notes, and snippets.

(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",
@joinr
joinr / usagedata.txt
Created April 16, 2021 14:57
usage data
dir defmulti defprotocol Type
..\spork 27 170 proto-dominant
..\tech.datatype 21 60 proto-dominant
..\clojure 28 35 proto-dominant
..\faster-multimethods 60 0 multi-dominant
..\dtype-next 2 32 proto-dominant
..\incanter 23 5 multi-dominant
..\clojure2d-examples 0 27 proto-dominant
..\fastmath 15 11 multi-dominant
..\penumbra 11 13 proto-dominant