Sunday, August 11, 2013
Tuesday, May 28, 2013
Expressiveness (2)
Transposing a matrix in Clojure:
(from http://stackoverflow.com/a/10347404/1144274)
(defn transpose [m]
(apply mapv vector m))
(from http://stackoverflow.com/a/10347404/1144274)
Tuesday, April 9, 2013
Remote VisualVM
In my current project at work, I need to do some profiling on a Java app that runs on a server. Hooking it up to my local VisualVM (awesome tool, btw) was not immediately obvious to me, so here's the steps:
Prepare application on remote server
jstatd needs some security settings explained in [1]. Open vim, enter
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
and save as jstatd.all.policy.
Now start jstatd in the same directory, let in run in the background:
jstatd -J-Djava.security.policy=jstatd.all.policy &
Next, start the app (assuming $MY_APP is the main class) as described in [2]:
java \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=$JMX_PORT \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Djava.rmi.server.hostname=$EXTERNAL_IP \
$MY_APP
$JMX_PORT can be any available TCP port. $EXTERNAL_IP is the server's external IP address.
Make sure that the server's firewall allows incoming connections on both TCP 1099 (jstatd) and the port you chose as $JMX_PORT.
Connect VisualVM
Start VisualVM, double click on remote. Enter the server's external IP address:
Right-click on the new connection and add a JMX connection:
Enter $EXTERNAL_IP:$JMX_PORT from above, in my case 192.168.0.160:
This should add a connection to the running app:
Double-click on it, start profiling, enjoy.
References
Sunday, February 24, 2013
Tool Time
In this post I'll collect little things that make life easier.
Shell
https://github.com/robbyrussell/oh-my-zshThursday, October 11, 2012
Squeak & Pharo on Raspian
Raspian (Debian for the Raspberry Pi) comes with a fairly recent version of the Squeak virtual machine (CogVM). Here's what the Pharo One-Click image looks like on the Pi:
It's still painfully slow. The good news is that Lars keeps working on the JIT compiler for ARM even though GSoC is over. Yay!
Tuesday, August 7, 2012
Monday, July 16, 2012
Dynamic bindings vs. laziness in Clojure
Now here's a thing that cost me quite a while to figure out: dynamic variables easily get in your way when accessed from lazy expressions. What happened to me is that a lazy expression using a dynamic var wouldn't remember the value of the dynamic var after leaving its binding form before the lazy expression was actually evaluated. It is only a slight relief that people more skilled than I have run into that problem, too.
So I guess a bunch of things in the language are not exactly simple.
So I guess a bunch of things in the language are not exactly simple.
Subscribe to:
Posts (Atom)





