Skip to content

Instantly share code, notes, and snippets.

Paul Stadig pjstadig

Block or report user

Report or block pjstadig

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
@pjstadig
pjstadig / transducers.md
Last active Jun 2, 2019
The secret feature of transducers that no one talks about!
View transducers.md

The Pledge

One thing that always made me a little sad about transducers was how map lost its ability to iterate multiple collections in parallel. This is actually my favorite feature of map. For example:

(map + (range 5) (range 5 10))
=> (5 7 9 11 13)

One somewhat practical use of this is if you want to compare two sequences, pairwise, using a comparator. Though I wish that every? took multiple collections, this is an adequate substitute:

View ambitious projects.md

What is an ambitious project?

According to Jonathan Blow, an ambitious project (or "deep work" as he calls it) is something that changes you.[1] Afterwards you are better at what you do, not in an incremental way, but in a substantial and qualitative way, you become a unique specialist in your field.

Blow spent 3.5 years designing the game Braid, and it taught him small puzzle design. He spent 7 years designing the game The Witness, and learned how to create long arcs of rich, non-verbal communication through puzzles. These were

@pjstadig
pjstadig / core.clj
Created Mar 20, 2017
A little type hint hint
View core.clj
(ns typehint.core)
;; A little type hint hint...
(set! *warn-on-reflection* true)
;; There are two ways to type hint the return value of a function, but one is
;; (technically) wrong:
(defn ^String as-string0
@pjstadig
pjstadig / core.clj
Created Mar 6, 2017
In Clojure you can fetch items from a map three different ways. Which should you use when?
View core.clj
(ns maps.core)
;; In Clojure you can fetch items from a map three different ways. Which should
;; you use when?
(= "bar" ({:foo "bar"} :foo)) ; map as function
(= "bar" (:foo {:foo "bar"})) ; key as function
(= "bar" (get {:foo "bar"} :foo)) ; `get` as function
;; <INCIDENTALLY>
View keybase.md

Keybase proof

I hereby claim:

  • I am pjstadig on github.
  • I am pjstadig (https://keybase.io/pjstadig) on keybase.
  • I have a public key ASC7G0cJXjSWTenyWMi5hn68ilcwYRhqwIw62FMzUNqbhAo

To claim this, I am signing this object:

View nooooo.txt
``````,,,,,' ` ,,,,,,'+:,',.,,,,'``:,,,,,,,:: ` ``,,,,,,,,,,,,,,; ``````````......,,,,.;;;;''''''++++#+#+++++############++#+##########
``````:,,,,;: ,,,,,:; `` :,,,,,'`,,,,,,,,,,,' ` :,,,,,,,,,,,,,,;.``````````......,,,,';;;''''''++++++#+++++#++##########+++##########+
`` ``` :,,,,' ``` ,,,,,';` ` :,,,,:,,,,,,,,,,,,,+ `,,,,,,,:,,,,,,,,;``````````.....,,,,;:,,,,;'''++++++++++'+###+####+#####@;'+###+######
` `` ,,,,,', .:,,,,:, :,,,,;. ``,,,,:,,,,,,,,,,,,,::.,,,,,;;;.::,,,,,'```````.......,,,:,,,,,,,,,;'+++++++#+#++##+++##########+;'+#####+###
`:; ````:,,,,+ `:,,,,.,,,;,:,,,,'`` :,,,:,,,,,,,,,,,,,,':,,,,,;,```.,,,,,;.`````.......,,,:,,,,,,,,,,,;++++++#'+#;;################;:'++++++##+
,,,' ;,,,,'`` :,,,,,,,,,,,;,,,,'` `..,,,,,,,,,::,,,,,,:;,,,,;' ````:,,,,;:````.......,,,;,,,,,,,,,,,,.;+++'#'+#+##+################.;'''++###+
,,,.'.` `:,,,:' `.,,,,,,,,,,,,;,,,,;. :,:,,,,,;;:.:;,,,,,:,,,,;.`````,,,,,:;````.....,,,,',,,,,,,,,,,,,,:'#'++++
View gist:73ca10f1dc004e1f16c7
Clojure 1.7.0
user=> (require 'clojure.string)
nil
user=> (clojure.string/lower-case "TRUE")
"true"
user=> (clojure.string/lower-case true)
"true"
user=> (clojure.string/lower-case 1)
"1"
user=> (clojure.string/lower-case {:FOO "BAR"})
View core.clj
(ns direct-linking.core)
(defn say-hello
([name]
(say-hello name 0))
([name n]
(println "Hello," name n)))
View gist:bade0e5eb130c255669f
(ns java2dot.core)
(def srcpath "/Users/paul/src/clojure/src/jvm/clojure/lang/")
(defn system [cmd writedata]
(let [proc (.. java.lang.Runtime (getRuntime) (exec (into-array cmd)))
isr (new java.io.InputStreamReader
(. proc (getInputStream)) "ISO-8859-1")
osr (new java.io.OutputStreamWriter (. proc (getOutputStream)))
baos (new java.io.ByteArrayOutputStream)]
@pjstadig
pjstadig / gist:3215c5febf4861341c05
Created Jul 9, 2015
MultiFn does not implement java.util.Comparator
View gist:3215c5febf4861341c05
Clojure 1.6.0
user=> (defmulti cmp (fn [a b] [(class a) (class b)]))
#'user/cmp
user=> (defmethod cmp :default [a b] (compare a b))
#<MultiFn clojure.lang.MultiFn@1da5688d>
user=> (sort cmp [:b :a])
ClassCastException clojure.lang.MultiFn cannot be cast to java.util.Comparator clojure.core/sort (core.clj:2829)
user=> (sort (fn [a b] (cmp a b)) [:b :a])
(:a :b)
You can’t perform that action at this time.