Skip to content

Instantly share code, notes, and snippets.

@joinr
joinr / functional.d
Created January 26, 2015 05:27
Trying D
//automatically converts lines from char[] to strings, presents
//a range of strings, immutable.
auto stringLines(string filename){
auto f = File(filename);
return f.byLine().map!(a => a.idup);
};
//readSet does a bit much, I'd like to pull out what the foreach is doing,
//obviously a reduction. for now, its string->AssocativeMap String String
auto readSet(string path){
(ns sometest
(:require [iota :as iota]
[clojure.core.reducers :as r]))
;;==Synthetic data==
(def fillrecord {:Unit :text
:category :text
:DemandGroup :text
:SRC :text
:FillType :text
@joinr
joinr / stack.clj
Last active June 30, 2016 09:34
Stack trace from glg2d
(import '[java.awt GraphicsEnvironment GraphicsDevice GraphicsConfiguration Transparency])
(import '[java.awt.image BufferedImage])
(defn ^BufferedImage make-imgbuffer
([w h ^Transparency t]
(let [^GraphicsEnvironment ge
(GraphicsEnvironment/getLocalGraphicsEnvironment)
^GraphicsDevice gd (.getDefaultScreenDevice ge)
^GraphicsConfiguration gc (.getDefaultConfiguration gd)]
(.createCompatibleImage gc w h t)))
@joinr
joinr / brokemap.cljs
Last active December 8, 2016 08:55
broken cljs map destructuring
(defn broken
"We should be able to collect the args via destructuring,
implicitly merge them with defaults, and return the resulting
map aliased by m, right? This idiom works in clojure..."
[& {:keys [x y min max] :or
{x 0 y 0 min 0 max 0} :as m}]
m)
;;=>(broken)
@joinr
joinr / profiles.clj
Created March 21, 2017 05:55
An example of a file-repo that mirrors central and clojars so that we don't touch the network, along with comments about weird error messages...
;;Say I don't want to ever touch the internet. Say I've written all my
;;awesome clojure stuff, and I have built up a bunch of libraries in
;;my local .m2 repo. Important caveat: say none of these libraries
;;got there via 'lein install', if they did....we got problems and
;;likely will get wierd errors. Let's say, for now, every lib
;;is downloaded from either clojars or maven central.
;;If we were to copy our .m2 folder to another place....say
;;a network file folder, or just a local file folder like
;;c:/Users/tom/repos/, we can force lein to look there
@joinr
joinr / lazymap.clj
Created April 18, 2017 01:15
A dumb lazy map.
(ns spork.data.lazymap)
(defn mapEquals [^clojure.lang.IPersistentMap m1 obj]
(clojure.lang.APersistentMap/mapEquals m1 obj))
(defmacro with-lazy-map [thunk lm symb & body]
(let [the-map (with-meta symb {:tag 'clojure.lang.IPersistentMap})]
`(do (when (not (realized? ~thunk))
(set! ~lm (force ~thunk)))
(let [~the-map ~lm]
@joinr
joinr / dataset.clj
Created August 30, 2017 10:51
Extending incanter's dataset protocols to a different implementation from spork.util.table
;;Compatibility layer to extend spork.util.table usage
;;into incanter datasets (as of 1.9.1).
;;Since datasets are now based on an API in clojure.core.matrix,
;;we can extend the API to use our table functions. This should
;;eliminate the trouble we've have processing incanter
;;datasets effeciently, since we can parse spork tables
;;using schemas.
(ns proc.dataset
(:require [spork.util [table :as tbl]]
[clojure.core.matrix.protocols :as mp]
@joinr
joinr / crash.txt
Created September 8, 2017 23:48
Nightcode crash cascade
Running with REPL...
Compiling crashtest.core
nREPL server started on port 53636 on host 127.0.0.1 - nrepl://127.0.0.1:53636
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_111-b14
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
@joinr
joinr / nightcode-bootrun.txt
Created September 9, 2017 17:33
error receieved when trying run with repl, after launching nightcode 3.7 using 'boot run' for development purposes
Exception in thread "JavaFX Application Thread" netscape.javascript.JSException: TypeError: undefined is not a function (evaluating 'd.endsWith("\n")')
at com.sun.webkit.dom.JSObject.fwkMakeException(JSObject.java:137)
at com.sun.webkit.dom.JSObject.callImpl(Native Method)
at com.sun.webkit.dom.JSObject.call(JSObject.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
@joinr
joinr / nightcode-bootbuild.txt
Created September 9, 2017 17:42
nightcode build output
$ java -jar project.jar
java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source)
at sun.security.util.SignatureFileVerifier.process(Unknown Source)
at java.util.jar.JarVerifier.processEntry(Unknown Source)
at java.util.jar.JarVerifier.update(Unknown Source)
at java.util.jar.JarFile.initializeVerifier(Unknown Source)
at java.util.jar.JarFile.getInputStream(Unknown Source)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(Unknown Source)
at sun.misc.Resource.cachedInputStream(Unknown Source)