-Xmx1024m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m
17 September 2010
Partial fix for tomcat hot redeploy
Adding the following to CATALINA_OPTS makes tomcat survive across much more redeploy iterations then by default :)
29 June 2010
Setting a single locale for GWT application
One library used to output messages in German when locale was not set explicitly (<extend-property name="locale" values="en"/>).
After we add an English locale to GWT module compilation began to take twice more time than in was before and the count of compilation permutations grew twice time too.
It appeared that we cannot just user . Compilation was just failing with that.
After googling a bit I've found a strange example which was promised to work. And it did worked! :) So, here it is:
<extend-property name='locale' values='en'/> <set-property-fallback name='locale' value='en'/> <set-property name='locale' value='en'/>Though it looks like a hack (and in fact it really is), but it do work! Now our project has single English locale and compiles in 6 permutations.
08 May 2010
Using D-Bus to shutdown the machine
I don't know why I don't like using /sbin/shutdown to switch off the computer :) But that is the fact!
I am not using Gnome\KDE\XFCE\whatever_else_complete_DE. I'm running Archlinux with Openbox and several tools. So I wanted to allow non-privileged user to be able to shutdown the computer by a single click.
Firstly I had to find out, what should I send over D-Bus (and whom to) to make my PC shutdown. Crawling the web I found an utility which allowed me to find what I needed in a few minutes. It's called DBus-Inspector.
So having a message and destination it just remained to send it using dbus-send:
$ dbus-send --system --print-reply --dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
If you will try to execute it, you may receive and error saying that you don't have permissions to send messages to org.freedesktop.Hal.devices.computer interface. If you did, you should open hal.conf from system config directory of D-Bus (mine is /etc/dbus-1/system.d/hal.conf) and add the following policy:
<policy group="shutdown">
<allow send_destination="org.freedesktop.Hal"
send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
</policy>
Now all the members of group shutdown will be able to switch off the computer by D-Bus. You just have to create the group:
# groupadd shutdownAnd add your user to this group:
# gpasswd -a user shutdownFinally you may want to create a script or desktop entry:
[Desktop Entry] Icon=system-shutdown Name=Shutdown Exec=dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
12 April 2010
Google maps: getMaxZoomAtLatLng and error 500
When I had to catch zoom level when 'no images available for this zoom level', I thought I had pretty quickly found the solution. But I was completely disappointed when this one didn't work. After some research I've managed to make it work :)
First of all I needed this in GWT application. We were using GWT Maps (1.0.4 by that time) which lack this function as such. So here is how we can bridge this function using JSNI:
class GoogleMapsJsBridgeSample {
/**
* Wrapper function to native call
*/
public void getMaxZoomAtLatLng(MapType mapType, double lat, double lon) {
getMaxZoomAtLatLng(mapType.getPeer(), lat, lon);
}
private native void getMaxZoomAtLatLng(JavaScriptObject mapTypePeer, double lat, double lon) /*-{
var latLng = new $wnd.GLatLng(lat, lon);
mapTypePeer.getMaxZoomAtLatLng(latLng, function(response) {
if (response && response['status'] == $wnd.G_GEO_SUCCESS) {
this@com.company.my.GoogleMapsJsBridgeSample::doSomethingWithMaxZoomAtLatLng(I)(response['zoom'])-*/;
}
});
}
private void doSomethingWithMaxZoomAtLatLng(int maxZoom) {
getMap().setZoom(maxZoom);
}
}
The point here is is NOT using MapWidget.getCurrentMapType() due a bug in gmaps-api (not GWT specific). According to the comments for the issue, problem appears only for hybrid map type, but for satellite and normal it is ok! So you can use to code above in the following manner in GWT:
GoogleMapsJsBridgeSample jsBridge = new GoogleMapsJsBridgeSample(); // ... jsBridge.getMaxZoomAtLatLng(MapType.getSatelliteMap(), lat, lon); // or use MapType.getNormalMap() for street map view
Such issues are sometimes specific to the version of gmaps-api you are using. You can always make sure what particular version is used in your application by outputting G_API_VERSION JavaScript variable.
Changelogs for each gmaps-api version are available at http://mapki.com/
17 March 2010
Eclipse to IntelliJ IDEA keymap migration cheatsheet
| Eclipse | IntelliJ IDEA | Action |
|---|---|---|
| Ctrl+O | Ctrl+F12 | Go to member popup Eclipse: outline current source IDEA: file structure popup |
| Ctrl+Shift+T | Ctrl+N | Open class by name Eclipse: Open Type IDEA: Go to - Class... |
| Ctrl+Shift+R | Ctrl+Shift+N | Open file by name Eclipse: Jump to file IDEA: Go to - File... |
| ? | F11 | Toggle bookmark |
| ? | Shift+F11 | Eclipse: ? IDEA: Show Bookmarks |
| ? | Ctrl+]\[ | Eclipse: ? IDEA: Move codeblock end\start |
Subscribe to:
Posts (Atom)