Skip to content

Instantly share code, notes, and snippets.

View laurentpetit's full-sized avatar

Laurent Petit laurentpetit

View GitHub Profile
@laurentpetit
laurentpetit / mutabots.clj
Last active May 12, 2021 23:21 — forked from cgrand/mutabots.clj
Reimplementation of transducers, in terms of processing functions instead of reducing functions. WIP.
(ns mutabots
"Reimplementation of transducers, in terms of processing functions instead
of reducing functions.
tl;dr: reducing-fn based transducers are a special case, influenced by reducers,
of processing-fn based transducers.
In Clojure 1.7.0-alpha2, transducers are expressed in terms of the existing
concept of reducing functions.
To sum it up, a transducer has currently the signature :
; constraint inside componenents
{:type :composite
:children [ {:type :label
:id :project-label
:text "Project name:"}
{:type :text
:id :project-name
:text ""
:form-data {:left {:control :project-label}}}
(defn create-control [parent]
(let [c (composite parent
::project-name-group create-project-name-group
::create-in-group create-in-group
::lein-template-group create-lein-template-group)
$ (partial $ c)]
(config! ($ ::create-in-group)
:form-data {:top {:control ::project-name-group}
:left {:pct 0}
:right {:pct 100}})
nrepl exception while doing code completion:
Exception in thread "nREPL-worker-2" java.lang.IllegalArgumentException: No implementation of method: :send of protocol: #'clojure.tools.nrepl.transport/Transport found for class: clojure.tools.nrepl.middleware.pr_values$pr_values$fn$reify__1283
at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:541)
at clojure.tools.nrepl.transport$eval7291$fn__7292$G__7280__7299.invoke(transport.clj:16)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__7726$fn__7739.invoke(interruptible_eval.clj:75)
at clojure.main$repl$fn__6597.invoke(main.clj:279)
at clojure.main$repl.doInvoke(main.clj:277)
at clojure.lang.RestFn.invoke(RestFn.java:1096)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__7726.invoke(interruptible_eval.clj:56)
@laurentpetit
laurentpetit / nrepl_events.clj
Created December 19, 2013 14:26
Adds 2 launch event listeners that spit the created nrepl server port into ~/.nrepl and <project-dir>/.nrepl files
(ns nrepl-events
(:require [ccw.core.launch :as l]
[clojure.java.io :as io]
[ccw.eclipse :as e]))
(defn spit-globally
"global ~/.nrepl file"
[{:keys [event-type port project]}]
(when (= :creation event-type)
(spit (io/file (java.lang.System/getProperty "user.home") ".nrepl")
;; What do you prefer?
(def options {:option-1 SomeClass/OPTION_1})
(defn foo [ option ]
(if (keyword? option)
(options option)
option))
;; Or
@laurentpetit
laurentpetit / plugin_additions.clj
Last active December 31, 2015 02:59
A Counterclockwise User Plugin adding a Command for reloading User Plugins from the ~/.ccw directory ( Alt+U S ) . How cool / meta is that, heh ? :-)
(ns plugin-additions
(:require [clojure.java.io :as io]
[ccw.e4.dsl :refer :all]
[ccw.e4.model :as m]
[ccw.eclipse :as e]
[ccw.file :as f]
[ccw.core.user-plugins :as p]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@laurentpetit
laurentpetit / lein_popup.clj
Created December 11, 2013 12:41
Place this file inside ~/.ccw/, or clone the gist inside ~/.ccw/lein-popup, and start/restart your Eclipse.
(ns lein-popup
(:require [ccw.e4.dsl :refer :all]
[ccw.leiningen.generic-launch :refer (generic-launch)]))
(defn launch [context] (generic-launch nil))
(defcommand launch-lein-generic "Launch generic leiningen popup")
(defhandler launch-lein-generic launch)
(defkeybinding launch-lein-generic "Alt+L G")
(ns hello-world
(:require [ccw.eclipse :as e]
[ccw.e4.dsl :refer :all]))
(defn greet [context]
(e/info-dialog
"Hello world" "This popup provided to you from a user script"))
(defcommand greeter "Hello from CCW")
(defhandler greeter greet)
(ns lein-script-test
(:require [ccw.util.e4.dsl :refer :all]
[ccw.util.eclipse :as e]
[ccw.leiningen.generic-launch :as l]))
(defn greet [context]
(e/info-dialog "Hello world" "This popup provided to you from a user script"))
(defn launch [context] (l/generic-launch nil))