Skip to content

Instantly share code, notes, and snippets.

View obohrer's full-sized avatar

Olivier Bohrer obohrer

View GitHub Profile
### Keybase proof
I hereby claim:
* I am obohrer on github.
* I am oliverro (https://keybase.io/oliverro) on keybase.
* I have a public key ASAA6_YvLOeP4WeTz6NQCW2t2U02p0bg2N_9zpGAmWtx6Ao
To claim this, I am signing this object:
@obohrer
obohrer / darwin.clj
Created May 14, 2019 18:13
Snippets to access Darwin feed v16 (Camel + ActiveMQ)
(import 'org.apache.activemq.camel.component.ActiveMQComponent)
...
(defn- ^String activemq-source-path
[{:keys [user password broker-url topic] :as consumer-config}]
(format "activemq:topic:%s?username=%s&password=%s"
topic
user
password))
@obohrer
obohrer / core.clj
Created May 20, 2015 16:12
clj-demo
(ns clj-demo.core
(:require [cheshire.core :as json]))
(foo :toto)
(defn factoriel
[n]
(->> n range (map inc) (reduce *)))
(factoriel 3)
Messages stored in 2.777 secs
Messages stored in 0.693 secs <-- one transaction sqlite3
@obohrer
obohrer / gist:6887093
Last active December 25, 2015 00:19
Infinite loop Netty (SslHandler)
2013-10-08 10:28:39
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.1-b02 mixed mode):
"New I/O worker #9" prio=10 tid=0x000002a9f0180800 nid=0x75ba runnable [0x000002a9bb5a1000]
java.lang.Thread.State: RUNNABLE
at java.lang.StringBuilder.append(StringBuilder.java:119)
at com.sun.net.ssl.internal.ssl.ProtocolVersion.valueOf(ProtocolVersion.java:93)
at com.sun.net.ssl.internal.ssl.ProtocolVersion.valueOf(ProtocolVersion.java:105)
at com.sun.net.ssl.internal.ssl.EngineInputRecord.bytesInCompletePacket(EngineInputRecord.java:89)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:798)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:713)
@obohrer
obohrer / gist:4662995
Created January 29, 2013 09:30
Concurrency test
(require '[clojure.tools.logging :as log])
(import '(java.util.concurrent Executors))
(defn t [f expected nthreads niters]
(let [pool (Executors/newFixedThreadPool nthreads)
tasks (map (fn [t]
(fn []
(dotimes [n niters]
(let [res (f)]
(when (not= res expected)
(log/info "Result is not expected : " res))))))
@obohrer
obohrer / gist:2049698
Created March 16, 2012 11:37
Heap dump with jmap / Stack trace
#Heap dump
jmap -dump:format=b,file=heapdump.b pid
#Just stacktraces
jstack pid
@obohrer
obohrer / gist:1351906
Created November 9, 2011 16:05
Enable JMX remote
Server side :
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1099 -Djava.rmi.server.hostname=127.0.0.1 -Djava.rmi.server.useLocalHostname=true
Client side :
Forward port 1099 ==> ssh -L 1099:localhost:1099 username@serverip
Download this logging properties file : http://blogs.oracle.com/jmxetc/resource/logging.properties
start jconsole using the downloaded properties file :
$ jconsole -debug -J"-Djava.util.logging.config.file=logging.properties" localhost:1099