Skip to content

Instantly share code, notes, and snippets.

Tom joinr

Block or report user

Report or block joinr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
joinr / splice.clj
Created Sep 24, 2019
a demonstration of how trivial it is to splice things in clojure
View splice.clj
`[~(range 10) ~[:this :vector :is] ~{:brought "to" :you "by"} ~@[:splicing :vectors]
~#{:sets} :and ~@'(:lists :together) :somewhat :trivially
~@{:even {:nested [:vectors]} :and [:maps :of :stuff] :are :easy} #{~@[:so :are :sets]}
~(eval `[:its :even [:easy ~@[:to :splice :quoted :forms]
~{:of :varying :levels #{:of-depth}}]])]
[(0 1 2 3 4 5 6 7 8 9)
[:this :vector :is]
{:brought "to", :you "by"}
joinr / pubsubcategories.clj
Created Sep 19, 2019
A simple core.async example of splitting up processing flows using pub/sub and pipeline-blocking
View pubsubcategories.clj
(ns workdist
(:require [clojure.core.async :as a :refer [chan >!! <!! <! >! go go-loop]]))
;;define some simple workloads
(def payloads
{:red (vec "red")
:green (vec "green")
:blue (vec "blue")})
;;Generate 100 messages of :red :green :blue categories
View par.clj
(ns par
(:require [clojure.core.async :as a]))
(def my-data-log (atom []))
(defn fetch-data! [n]
(Thread/sleep 1e3)
(swap! my-data-log conj (str "Fetched record: " n))
joinr / numberdemo.clj
Created Jun 26, 2019
a simple exploration of different ways to print monetarily formatted strings of numbers
View numberdemo.clj
(ns numberdemo
(:require [clojure.pprint :as pprint]))
;;from Craig
;;doesn't handle decimals.
(defn commarize
"given the string representation of a number, insert a comma after
every three digits."
;;reverse the string since the first comma starts from the right
joinr / faster.clj
Created Jun 20, 2019
messing with clojure to see if any more performance can squeeze out for
View faster.clj
(ns perfect.reader.faster
[perfect.reader.generics :as generics]
[clojure.spec.alpha :as s]
[net.danielcompton.defn-spec-alpha :as ds])
(org.dhatim.fastexcel.reader ReadableWorkbook
joinr / shim.clj
Last active Jun 20, 2019
example of a main shim namespace for clojure to avoid AOT'ing everything and allow fast starts
View shim.clj
;;Shim class for running app without
;;aot compilation issues.
;;entrypoint for some gui.
(ns blah.main
(:gen-class :main true))
;;This is the main entry point for the app.
;;It's a good example of a shim-class, and
;;requires some arcane features to get things
;;working to avoid aot compilation of dependent
joinr / spectraining.clj
Created Jun 4, 2019
spec experiment with org
View spectraining.clj
;;A port of an awk script that munges
;;code to .org mode documentation,
;;let's do it with spec!
(ns spectraining.doc
(:require [clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as gen]
[clojure.spec.test.alpha :as stest]
[clojure.string :as str]))
joinr / ordering.clj
Created May 28, 2019
examples of composeable ordering functions
View ordering.clj
(ns ordering)
;;We want to pack some information along with
;;our functions so that when our interpreter picks them
;;up, we can determine if the function should be applied
;;directly as a comparator, or if we need to "lift"
;;it into the comparator domain.
(defn ordering? [x] (get (meta x) :ordering))
;;convenience macro to help us create functions with
;;ordering specified in meta
joinr / bt.hs
Last active Aug 28, 2019
bridge and torch
View bt.hs
-- This is a worked solution to a logic problem pointed out by BFW.
-- Four people come to a river in the night.
-- There is a narrow bridge, but it can only hold two people at a time.
-- They have one torch and, because it's night, the torch has to be used when
-- crossing the bridge.
-- Person A can cross the bridge in one minute, B in two minutes, C in five
-- minutes, and D in eight minutes.
-- When two people cross the bridge together, they must move at the slower
-- person's pace.
View gen_class_javadoc.clj
;;updated example from the old clojure 1.0
(ns documentation
(:require [ :as io]
[ :as shell]
[clojure [string :as s]]))
(def +sep+ (System/getProperty "file.separator"))
(defn- convert-fn-meta-into-javadoc
You can’t perform that action at this time.