Skip to content

Instantly share code, notes, and snippets.

View laurentpetit's full-sized avatar

Laurent Petit laurentpetit

View GitHub Profile
Exception in thread "Thread-4" java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:340)
at clojure.lang.RT.classForName(RT.java:2154)
at clojure.lang.RT.classForName(RT.java:2163)
at clojure.lang.RT.loadClassForName(RT.java:2182)
at clojure.lang.RT.load(RT.java:436)
at clojure.lang.RT.load(RT.java:412)
at clojure.core$load$fn__5445.invoke(core.clj:5862)
at clojure.core$load.doInvoke(core.clj:5861)
classloader: #object[sun.misc.Launcher$ExtClassLoader 0x654d12c2 sun.misc.Launcher$ExtClassLoader@654d12c2]
url: #object[java.net.URL 0x1fb03ff9 file:/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/lib/tools.jar]
Exception in thread "Thread-4" java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:340)
at clojure.lang.RT.classForName(RT.java:2154)
at clojure.lang.RT.classForName(RT.java:2163)
at clojure.lang.RT.loadClassForName(RT.java:2182)
at clojure.lang.RT.load(RT.java:436)
at clojure.lang.RT.load(RT.java:412)
sample [master●] % tree -a
.
├── .gitignore
├── project.clj
└── src
└── sample
└── core.clj
2 directories, 3 files
sample [master●] % cat project.clj
------
STATUS
------
pluginId org.eclipse.ui
pluginVersion 3.107.0.v20150423-1329
code 0
severity 4
message Unhandled event loop exception
fingerprint 7dd19923
;;;;;;;;;;;;;;;;;;;;;
;; nrepl request when :pprint "true"
{:op "eval", :code "(defn somefn [] (prn \"something\"))", :ns "user", :pprint "true", :right-margin 20}
;; nrepl responses:
{:id a625ffc0-06f2-4fd5-a037-91b265e917b9, :pprint-out #<Var@758d0fe8:
#object[user$somefn 0x1929eceb "user$somefn@1929eceb"]>
, :session fe8e50cf-a399-47c4-8548-860cf540ae80}
{:id a625ffc0-06f2-4fd5-a037-91b265e917b9, :pprint-sentinel {}, :session fe8e50cf-a399-47c4-8548-860cf540ae80}
=> (use 'clojure.pprint)
nil
=> (print #'pprint)
#'clojure.pprint/pprint
nil
=> (pprint #'pprint)
#<Var@309f74bd: #<pprint$pprint clojure.pprint$pprint@56b9af2a>>
nil
@laurentpetit
laurentpetit / api-flavor.clj
Last active August 29, 2015 14:25
working on the API part of CCW. First, facilities to have code executed on the UI thread, asynchronously and non blocking, or blocking (synchronously or asynchronously)
;; Which solution would be preferred as an API over SWT Display.syncExec Display.asyncExec ?
;; In java you do this:
;; Display.syncExec( -> ...)
;; Display.asyncExec( -> ...)
(require '[ccw.swt :as swt])
;; O
(swt/sync-exec
@laurentpetit
laurentpetit / simplest_completion_proposal.clj
Last active August 30, 2015 15:07
Simplest example of providing a custom completion proposal provider for CCW
(use 'ccw.api.content-assist)
(register-completion-proposal-provider!
{:label "Available namespaces"
:provider (constantly ["clojure.core" "clojure.set" "clojure.repl" "clojure.java.io"])})
================
clojure/core.clj -
================
version originale (avec map):
1:4 paredit.parser=> (dotimes [_ 10] (time (do (-> "/home/lpetit/projects/clojure/src/clj/clojure/core.clj" slurp sexp) nil)))
"Elapsed time: 5391.817183 msecs"
"Elapsed time: 4978.254708 msecs"
"Elapsed time: 4365.472075 msecs"
"Elapsed time: 4478.291098 msecs"
"Elapsed time: 4496.73974 msecs"
@laurentpetit
laurentpetit / gist:759364
Created December 30, 2010 02:03
Dining philosophers solution
;;; Dining philosophers. Solution using Clojure STM.
;;; This is sort of an implementation of the "Use monitor" solution:
;;; http://en.wikipedia.org/wiki/Dining_philosophers_problem#Monitor_solution
;;; What are our identities?
;;; The problem talks about forks, and philosophers.
;;; Conceptually, forks have a "taken-by" property which can have one
;;; of three values: :left-philosopher, :righ-philosopher, :nobody.
;;; Conceptually, philosophers have a "state" property which can be
;;; :eating or :thinking.
;;; Note that with an approach using STM for getting both forks at once