Skip to content

Instantly share code, notes, and snippets.

View laurentpetit's full-sized avatar

Laurent Petit laurentpetit

View GitHub Profile
@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"])})
@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
=> (use 'clojure.pprint)
nil
=> (print #'pprint)
#'clojure.pprint/pprint
nil
=> (pprint #'pprint)
#<Var@309f74bd: #<pprint$pprint clojure.pprint$pprint@56b9af2a>>
nil
;;;;;;;;;;;;;;;;;;;;;
;; 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}
------
STATUS
------
pluginId org.eclipse.ui
pluginVersion 3.107.0.v20150423-1329
code 0
severity 4
message Unhandled event loop exception
fingerprint 7dd19923
sample [master●] % tree -a
.
├── .gitignore
├── project.clj
└── src
└── sample
└── core.clj
2 directories, 3 files
sample [master●] % cat project.clj
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)
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)
@laurentpetit
laurentpetit / gist:fb86ea923dfb02e673da
Created May 9, 2015 18:54
Execution times for Counterclockwise dependencies. Execution times are written down depth-first.
Execution time: 32ms for LOADING "core_proxy"
Execution time: 130ms for LOADING "core_print"
Execution time: 37ms for LOADING "genclass"
Execution time: 65ms for LOADING "core_deftype"
Execution time: 73ms for LOADING "core/protocols"
Execution time: 41ms for LOADING "gvec"
Execution time: 59ms for LOADING "instant"
Execution time: 21ms for LOADING "uuid"
Execution time: 45ms for LOADING "/clojure/string"
Execution time: 160ms for LOADING "/clojure/java/io"
> // Field descriptor #9 Ljava/lang/Class;
> private static java.lang.Class __cached_class__0;
>
15c18
< 1 invokespecial clojure.lang.AFunction() [10]
---
> 1 invokespecial clojure.lang.AFunction() [12]
20c23
< // Method descriptor #12 (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
---