12 April 2011

Post SVN changelist to ReviewBoard (using post-review tool)

Yeah, this will work out of the box only for Unix systems. But I have no worries about that :)
$ svn stat --changelist "changelist name" | tail -n +3 | awk '{print $NF}' | grep -v 'gwt\.xml$' | xargs post-review -o
Here I post for review changelist named "changelist name" excluding GWT module descriptor files (*.gwt.xml), which a not to be commited and opens browser window with newly created review request.
As for locally modified files that are under SVN control, I usually move those that shouldn't be commit to separate changelist (named "no-commit"). Yes, I'm delighted with changelists support in IntelliJ IDEA! :)

21 November 2010

How to restore Linux loader after installing Windows without Live-CD

Often having both Linux and Windows installed on the same PC I face trouble when after reinstalling Windows my Linux loader (GRUB\LILO\whatever) got erased with nasty one from M$. Before I always had to look up some live-CD distro to boot and restore GRUB. Today I was too lazy to do that - I had no suitable CD (or maybe it's time to throw away my CD drive) and after a quick look through the web I've found GRUB4DOS. So what magic does it provide? Here is the trick - GRUB4DOS allows you to install it from withing your running Windows instance, it boots up a GRUB-like stuff where you can select another partition to boot from. Basically you then boot to your broken GRUB record, then boot up your Linux distro and then having complete environment you just restore your broken GRUB MBR record. Easy, ha! To install the GRUB4DOS we don't even need to perform any dangerous manipulations with MBR. You just download grub4dos or grubinst package from http://sourceforge.net/projects/grub4dos/files/, copy grbldr from the package to your system drive root (e.g. C:\grbldr) and add following line to boot.ini:
C:\GRBLDR="GRUB4DOS"
Now you just need to reboot the PC, boot your Linux distro and reinstall GRUB On my ArchLinux I did the following:
$ sudo grub-install --root-directory=/ \(hd0\)
This installed GRUB to the MBR of my first hard drive and put staging files under /boot/grub directory.

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 :)
-Xmx1024m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m

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 shutdown
And add your user to this group:
# gpasswd -a user shutdown
Finally 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