This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn duotone-filter [^java.awt.image.Raster raster] | |
(let [dest (.createCompatibleWritableRaster raster) | |
bands (.getNumBands dest) | |
dest-pixel (int-array bands) | |
w (.getWidth raster) | |
h (.getHeight raster) | |
] | |
(loop [y 0] | |
(when (< y h) | |
(loop [x 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:db/id #db/id[:db.part/user] | |
:db/ident :reset-position-in-scope | |
:db/doc "Goes through existing positions and sequentializes them" | |
:db/fn #db/fn {:lang "clojure" | |
:params [db scope-id scope-attr retracted-eid sorted-attr] | |
:code (let [children (scope-attr (datomic.api/entity db scope-id)) | |
sorted-children-eids (map :db/id (sort-by sorted-attr children)) | |
without-retracted-eids (filter (partial not= retracted-eid) sorted-children-eids)] | |
(map-indexed | |
(fn [idx entity-id] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns composable-compojure.handler | |
(:use compojure.core) | |
(:require [compojure.handler :as handler] | |
[ring.util.response :refer [response]])) | |
(defn middleware | |
[handler value] | |
(fn [request] | |
(handler (update-in request [:from-middleware] (partial cons value))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns me.andersfurseth.debug | |
(:use [clojure.walk :only [postwalk]])) | |
(defn remove-fn-and-splice [fn-name form] | |
(if (and (list? form) | |
(= fn-name (first form))) | |
(apply concat (rest form)) | |
form)) | |
(defmacro print-form [form] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(run 1 [q] | |
(fresh [S E N D M O R Y SEND MORE MONEY] | |
(infd S E N D M O R Y (interval 0 9)) | |
(distinctfd [S E N D M O R Y]) | |
(eqfd | |
(!= S 0) | |
(!= M 0) | |
(= SEND (+ (* S 1000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro domonad [monad [sym expr & more] & body] | |
(if more | |
`(~monad ~expr | |
(fn [~sym] (domonad ~monad ~more ~@body))) | |
`(~monad ~expr | |
(fn [~sym] ~@body)))) | |
(defn identity-m [v f] (f v)) | |
(defn maybe-m [v f] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn bind [v f] (f v)) | |
(defmacro lett [[sym expr & more] & body] | |
(if more | |
`(bind ~expr | |
(fn [~sym] (lett ~more ~@body))) | |
`(bind ~expr | |
(fn [~sym] ~@body)))) | |
; eksempel |