Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

ck ck

💭
I may be slow to respond.
View GitHub Profile
@ck
ck / lenses.clj
Created Dec 29, 2020 — forked from ctford/lenses.clj
A Clojure lens implementation based on focus and fmap.
View lenses.clj
(ns shades.lenses)
; We only need three fns that know the structure of a lens.
(defn lens [focus fmap] {:focus focus :fmap fmap})
(defn view [x {:keys [focus]}] (focus x))
(defn update [x {:keys [fmap]} f] (fmap f x))
; The identity lens.
(defn fapply [f x] (f x))
(def id (lens identity fapply))
@ck
ck / gist:09fbf8b6d3e29d33b235835b98932a0a
Created Jul 3, 2018
Datomic ion-starter clj REPL error
View gist:09fbf8b6d3e29d33b235835b98932a0a
$ git clone git@github.com:Datomic/ion-starter.git
Cloning into 'ion-starter'...
remote: Counting objects: 151, done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 151 (delta 59), reused 131 (delta 39), pack-reused 0
Receiving objects: 100% (151/151), 19.73 KiB | 9.86 MiB/s, done.
Resolving deltas: 100% (59/59), done.
$ cd ion-starter
$ git:(master) clj
Error building classpath. Failed to read artifact descriptor for com.datomic:java-io:jar:0.1.12
@ck
ck / JasperReportsinWildFly.md
Last active Feb 22, 2016
JasperReports in WildFly
View JasperReportsinWildFly.md

Running the application (https://github.com/ck/jasper-test) in REPL works as expected, i.e. it generates the report.

When deploying it to WildFly

lein immutant war -o wildfly-10.0.0.Final

and starting WildFly via

@ck
ck / gist:8873154
Created Feb 7, 2014
Immutant Test Failure with Java Class
View gist:8873154
% lein immutant test active/ialab (immutant-and-java-classes ⚡)
Running tests inside Immutant...
Starting JBoss
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/bin/java -Xms64m -Xmx1024m -XX:MaxPermSize=1024m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSClassUnloadingEnabled -Djboss.home.dir=/Users/ck/.immutant/current/jboss -Dlogging.configuration=file:/Users/ck/.immutant/current/jboss/standalone/configuration/logging.properties -Dorg.jboss.boot.log.file=/Users/ck/code/active/ialab/target/isolated-immutant/standalone/log/boot.log -jar /Users/ck/.immutant/current/jboss/jboss-modules.jar -mp /Users/ck/.immutant/current/jboss/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.server.base.dir=/Users/ck/code/active/ialab/target/isolated-immutant/standalone -Djboss.socket.binding.port-offset=67
Deploying /Users/ck/code/active/ialab
@ck
ck / QueueWorker
Created Oct 28, 2013
Reuse connection in worker
View QueueWorker
(defrecord QueueWorker [queue worker-fn]
daemon/Daemon
(start [_]
(reset! done false)
(msg/with-connection {} ; use single connection for receive
(loop []
(when-not @done
;; make sure we re-use the same HornetQ connection
(info "Worker Connection" (:connection ((get-thread-bindings) #'immutant.messaging.core/*options*)))
(when-let [msg (msg/receive queue :timeout 5000)]
View test.clj
; Comments start with semicolons.
; Clojure is written in "forms", which are just
; lists of things inside parentheses, separated by whitespace.
;
; The clojure reader assumes that the first thing is a
; function or macro to call, and the rest are arguments.
;
; Here's a function that sets the current namespace:
(ns test)
@ck
ck / stacktrace.sh
Created Dec 8, 2012
Immutant Stack Trace
View stacktrace.sh
21:16:21,141 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-55) MSC00001: Failed to start service jboss.deployment.unit."stardust.clj".INSTALL: org.jboss.msc.service.StartException in service jboss.dep
loyment.unit."stardust.clj".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "stardust.clj"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:123) [jboss-as-server-7.1.x.incremental.129.jar:7.1.x.incremental.129]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
@ck
ck / gist:3226202
Created Aug 1, 2012 — forked from swannodette/gist:3217582
sudoku_compact.clj
View gist:3226202
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
(defn init [vars hints]
@ck
ck / clojure-nyc-meetup-notes-20120718.md
Created Jul 21, 2012 — forked from noahlz/clojure-nyc-meetup-notes-20120718.md
Rough Notes from the July 18 Clojure NYC Meetup
View clojure-nyc-meetup-notes-20120718.md

Organizing Clojure Projects

Presented by @stuartsierra

Stuart presented using a deck created with org-html-slideshow, a Clojure library for formatting org-mode notes as HTML slides.

General Code Structure / Organization
  1. Be careful not to make function calls across component boundaries.
  2. Protocols should be minimalistic. They should have the fundamental operations of your component.
@ck
ck / gist:2846903
Created May 31, 2012 — forked from stuarthalloway/gist:2002582
Datomic extent query
View gist:2846903
;; Datomic example code
;;
;; The extent of entity ?x is all datoms that are about ?x.
;; Drop this into your rules.
;;
;; Demonstrates
;;
;; 1. recursive query (extent calls itself)
;; 2. disjunction (different extent bodies are ORed)
;; 3. component attributes (e.g. your arm is a component, your brother isn't)