Skip to content

Instantly share code, notes, and snippets.

View Database Internals
View asd.clj
(let [channel (create)
incremented-values (map* inc channel)
decremented-values (map* dec channel)]
(consume incremented-values (fn [i] (println "Incremented value: " i)))
(consume decremented-values (fn [i] (println "Decremented value: " i)))
(accept channel 1)
(accept channel 2)
(accept channel 3)
(ms/flush channel))
package introspect;
import net.bytebuddy.instrumentation.method.bytecode.bind.annotation.AllArguments;
import net.bytebuddy.instrumentation.method.bytecode.bind.annotation.Origin;
import java.lang.reflect.Method;
public class LogInterceptor {
public static void log(@AllArguments Object[] allArguments,
@Origin Method method) {
View Haskell Simplification 2.hs
import Control.Concurrent.ParallelIO.Global (parallel)
import Control.Arrow (left)
data DbError = DbError
data Input = Input
data Result = Result
someOperation :: Either DbError [Input]
-> (Input -> IO (Either DbError Result))
-> IO (Either DbError [Result])
ifesdjeen / Haskell Simplification 1.hs
Last active Feb 11, 2018
I've got that piece of code that looks extremely overcomplicated to me. Even though every operation by itself is simple, the "sum" of operations is simply insane.
View Haskell Simplification 1.hs
data Query = Query
data SomeObj = SomeObj
data IoOnlyObj = IoOnlyObj
data Err = Err
-- There's a decoder function that makes some object from String
decodeFn :: String -> Either Err SomeObj
decodeFn = undefined
-- There's a query, that runs against DB and returns array of strings
View Haskell Thunk

First of all, sorry for the messy code (it was in a bad condition, and I've been commenting/uncommenting bunch of things to understand what's going on and where, only got time to fix it but not clearnup)

At first, I've started getting

Stack space overflow: current size 8388608 bytes.
View Haskell vs Clojure Order.clj
;; "Normal" operation order
(->> [1 2 3]
(map inc)
(map #(* 2 %)
(reduce +))
View almost=.clj
(defn almost=
"Non-strict equality"
[wat center tolerance]
(and (>= wat (- center tolerance))
(<= wat (+ center tolerance))))
ifesdjeen / Haskell vs Clojure Tail Rec.clj
Last active Aug 29, 2015
Comparison of tailrec+pattern matching between Haskell and Clojure
View Haskell vs Clojure Tail Rec.clj
(defn max-from-list
"Get the maximum from list using recursion"
[[head & tail]]
(if (empty? tail)
(let [max-in-tail (max-from-list tail)]
(if (> head max-in-tail)
ifesdjeen / deploy_jar.rb
Created Oct 17, 2013
If you're deploying 20 Clojure libs a day (and keep forgetting Clojars deploy syntax), you're going to love that script. Maybe there's a leiningen task for that, never tried.
View deploy_jar.rb
res = `lein do pom, jar`
jar = res.split("\n").last.gsub("Created ", "")
puts "Gonna deploy jar: #{jar}"
exec "scp pom.xml #{jar}"