Skip to content

Instantly share code, notes, and snippets.

View ck's full-sized avatar
💭
I may be slow to respond.

ck ck

💭
I may be slow to respond.
  • United States
  • 23:04 (UTC -04:00)
View GitHub Profile
@ck
ck / lenses.clj
Created December 29, 2020 21:56 — forked from ctford/lenses.clj
A Clojure lens implementation based on focus and fmap.
(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 July 3, 2018 18:03
Datomic ion-starter clj REPL error
$ 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 February 22, 2016 14:10
JasperReports in WildFly

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 February 7, 2014 22:18
Immutant Test Failure with Java Class
% 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 October 28, 2013 20:25
Reuse connection in worker
(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)]
@ck
ck / test.clj
Created June 25, 2013 11:54 — forked from adambard/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 December 8, 2012 02:22
Immutant Stack Trace
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 August 1, 2012 11:54 — forked from swannodette/gist:3217582
sudoku_compact.clj
(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 July 21, 2012 02:41 — forked from noahlz/clojure-nyc-meetup-notes-20120718.md
Rough Notes from the July 18 Clojure NYC Meetup

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 22:42 — forked from stuarthalloway/gist:2002582
Datomic extent query
;; 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)