Monday, July 2, 2012

Disable super key gnome shell 3.4 (gnome3)

I don't like how gnome-shell uses the super key for the overlay shortcut. This can be disabled by typing the following command in a terminal.
gsettings set org.gnome.mutter overlay-key ''
When changing workspaces only the primary monitor changes. To allow all monitors to change use the following.
gsettings set org.gnome.shell.overrides workspaces-only-on-primary false

Thursday, June 7, 2012

Generate XmlRootElement for jaxb objects

I recently had to add XmlRootElement to a class. After using google for a while, I finally figured out a way to do it. I Updated the pom jaxb plugin to include the annotate plugin and created a mappings file that customizes the jaxb object. pom.xml:
<plugin>
    <groupid>org.jvnet.jaxb2.maven2</groupid>
    <artifactid>maven-jaxb2-plugin</artifactid>
    <configuration>
        <extension>true</extension>
        <strict>false</strict>
        <plugins>
            <plugin>
                <groupid>org/jvnet/jaxb2_commons</groupid>
                <artifactid>annotate</artifactid>
                <version>0.4.1.5</version>
            </plugin>
        </plugins>
    </configuration>
    <executions>
        <execution>
            <id>generate</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <bindingincludes>
                    <include>*.xjb</include>
                </bindingincludes>
                <args>
                    <arg>-Xannotate</arg>
                </args>            
            </configuration>
        </execution>
    </executions>
</plugin>
file.xjb:
<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?-->
<jaxb:bindings version="2.1"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:annox="http://annox.dev.java.net"
jaxb:extensionbindingprefixes="annox">
    <jaxb:bindings schemalocation="filename.xsd" node="/xs:schema">
        <jaxb:bindings node="xs:complexType[@name='ObjectType']">
            <annox:annotate>
                <annox:annotate 
                annox:class="javax.xml.bind.annotation.XmlRootElement"
                name="access">
            </annox:annotate>
        </annox:annotate></jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

Wednesday, May 30, 2012

inotifywait - run scripts on file changes

When working on a project in Java, I often need to stop/start maven whenever I make changes to the source code. I wanted to have maven restart automatically whenever I changed the source code. I ended up using some bash scripts to get the job done. inotifywait will run the script restart.sh whenever a file inside src is saved. This could also be done to automatically run test when source code changes. watch.sh:
#!/bin/bash
while inotifywait -re close_write src; do ./restart.sh; done
restart.sh:
#!/bin/bash
./kill_tomcat.sh
sleep 1
mvn tomcat:run -o &
kill_tomcat.sh:
#!/bin/bash
pkill -kill -f tomcat:run

Tuesday, February 28, 2012

python rfoo rconsole

I ran accross this today. rfoo allows connecting to a remote running session of python and inspect the session's values, modify the data, etc. You can read more about it here Install in ubuntu:
sudo apt-get install python-dev
pip install cython
pip install rfoo
rconsole is a remote Python console with auto completion, which can be used to inspect and modify the namespace of a running script. To invoke in a script do:
from rfoo.utils import rconsole
rconsole.spawn_server()
To attach from a shell do:
rconsole