A screencast showing how to install GitMon in 5 minutes on a Mac.
2010-11-21
GitMon Quick Start Screencast
2010-11-06
GitMon 0.3 - Easy Install!
Since the last post GitMon has got many improvements, including the easy_install support (GitMon is hosted at Python Package Index), so to install it, simply do:
sudo easy_install gitmonThen run
gitmon from terminal and it will create a default configuration file for you (~/.gitmon.conf). Edit it and you're good to go!Mac OS X users who have Growl installed can get it all working in 3 minutes. It will involve some additional configuration twiddling for Linux and Windows guys, but that will be improved in future releases.
2010-10-16
GitMon - the git repository monitor
Dozens of git repositories? Want to know what's happening?
If you are actively using git (which you should, because it's awesome), you may have looked for a way to get those nice popup notifications when something is pushed to remote origin. When you have dozens of repositories to work with, it may get annoying to go through all of them and check for updates. I haven't found anything mature and worth using, so I decided to get my hands dirty...
And finally, after many joyful hours of coding... Meet GitMon - an open source git monitoring tool. Here's how it looks like:
GitMon Features (0.1.6):
• Configurable notifications via command-line tools (growlnotify, notify-send, ...)
• Scheduling via standard tools (like crontab)
• Support for multiple git repositories
• Possibility to give repositories custom names
• Possibility to notify about new branches
• Possibility to notify about new tags
• Configurable limit of new commits in notification
• Configurable limit of file details in notification
• Possibility to perform 'git pull' automatically
• Variables in configuration file
• Recursive file system scanning for repositories (configurable roots)
Installing GitMon
If you're willing to try it, there is no "next", "next", "finish" installation so far, so you will have to do this (shouldn't be too difficult to do for any developer):
1. Clone the repo:
Fire up the terminal and go where you want 'gitmon' dir to appear. Then do:
git clone git://github.com/spajus/gitmon.git
2. Add gitmon to path:
You may want to put this in your ~/.profile:
export PATH="$PATH:/path/to/gitmon"
3. Make sure you have growlnotify (Mac) or notify-send (Linux).
You can install notify-send command easily:
apt-get install libnotify-bin
4. Set up the configuration:
cp gitmon.conf.example ~/.gitmon.confThen edit ~/.gitmon.conf to suit your needs.
5. Make sure you have Python 2.6+ and GitPython:
python --version easy_install gitpython
6. Test if your gitmon.conf works:
gitmon -vA good output may look something like this:
GitMon v0.1.5 Loading configuration from /Users/tomasv/.gitmon.conf Tracking repo: "GitMon Repo" at ~/Development/python/gitmon Checking repo: GitMon Repo
7. Configure crontab:
crontab -eExample:
#git must be in cron's path! PATH=/usr/local/bin:/usr/bin:/bin #check for repo updates every 5 minutes */5 * * * * gitmon
That's it. Now just wait for those notifications!
Roadmap
There is a small roadmap for future releases:
• Installation bundles for major operating systems
• Menubar / system tray icon
• GUI for configuration
• Integration with diff tools
Update!
I have just found Gitifier. Here's how GitMon and Gitifier notifications about same commit look next to each other:
2010-08-15
XML Zen 0.2
After a long break a new version of XML Zen was finally released. It has several bug fixes along with some new features. The changelog:
Changes in version 0.2.0 (2010-08-15)
- Fixed a bug which prevented getting attribute values in some cases (Issue #11)
- Added a possibility to set some defaults for XmlBuilder (Issue #10)
- Added XmlBuilderOutput interface with String and OutputStream implementations (Issue #8)
- XmlBuilder builds formatted XML with declaration (if charset is provided) (Issue #9)
- File support in XmlBuilder (through XmlBuilderStreamOutput) and XmlSlicer (Issue #7)
2010-03-11
Compiling Java applications to native Windows executables
Being a Java developer really sucks when it comes to making end-user desktop applications. You want these applications to be light, fast and easily redistributable. Packaging a bunch of jars along with startup script is the worst thing you can do. It may work quite well in various Linux distributions, where you can make a .deb or .rpm which automatically installs JRE, puts startup script to /usr/local/bin and creates a nice launcher with icon in the applications menu. In Mac OS you can use that outdated JRE that comes by default and then easily bundle all scripts and jars into an .app. But in Windows it does not work that way. You can use JSmooth to make .exe out of .jar and use NSIS to create a nice installer, but there still is a problem. User may not have a compatible JRE, or he/she may choose not to have one just because Java sucks for running on it's bloated memory hogging virtual machine. I have to agree here. As a user, I have no faith in desktop applications that are written in Java.
So what is the solution? Compile to native executable and forget JRE. It is possible, but it will not be a walk in the park. First, you will have to get familiar with GNU Compiler Collection and particularly with GCJ.
Let's compile a Hello World application like this one:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello native world!");
}
}
- Get the patched GCJ here: http://www.thisiscool.com/gcc_mingw.htm (120 MB)
- Extract it somewhere and add thisiscool-gcc/gcc-ejc/bin to your PATH
- Compile Hello.java as Hello.exe:
gcj --main=Hello -o Hello Hello.java - Enjoy your statically linked Hello.exe which prints Hello native world! and runs without JRE.
Anyway, when you compile native binaries, your Java code cannot be decompiled, so you have better protection than by using obfuscators. And the best thing is that end users won't complain that "it's crap because it's Java". They just wouldn't know.
I wish Sun (I just can't say Oracle when referring to Java, it makes me sick, sorry) could create an official AOT Java compiler so developers would not have to go through hellfire to make native executables.
2009-11-15
Making Windows a better place to be
Setting up Cygwin and PuttyCyg
Getting Cygwin
Introducing Cygwin to your Windows
- ~/.bashrc
- ~/.bash_profile
- ~/.inputrc
Getting PuttyCyg
Configuring PuttyCyg to access local cygwin
2009-09-29
XML processing in Java
<?xml version="1.0" encoding="UTF-8"?>
<data>
<entry id="1">entry number one</entry>
<entry id="2">entry number two</entry>
</data>
public class Entry {
private int id;
private String content;
//the usual setters and getters here
}
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new File("data.xml"));
NodeList nl = doc.getElementsByTagName("entry");
for (int i = 0; i < nl.getLength(); i++) {
Entry entry = new Entry();
entry.setId(Integer.parseInt(nl.item(i).getAttributes()
.getNamedItem("id").getNodeValue()));
entry.setContent(nl.item(i).getTextContent());
System.out.println(entry);
//do real stuff
}
}
catch (final Exception e) {
System.out.println("Failed parsing: " + e);
//do real handling
}
Entry:{id: 1; content: entry number one}
Entry:{id: 2; content: entry number two}
DocumentBuilderFactory.newInstance() will usually return an instance of this implementation: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl for (Node n : doc.getElementsByTagName("entry") { ... }).
for (XmlSlicer piece : XmlSlicer.cut(data).getTags("entry")) {
//each piece is: <entry id="...">...</entry>
Entry entry = new Entry();
entry.setId(Integer.parseInt(piece.getTagAttribute("entry", "id")));
entry.setContent(piece.get("entry").toString());
System.out.println(entry);
//do real stuff
}
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2</url>
</repository>
<!-- other repositories -->
</repositories>
<dependency>
<groupId>com.googlecode.xmlzen<groupId>
<artifactId>xmlzen</artifactId>
<version>0.1.1</version>
</dependency>
2009-06-17
A tool for unpacking multiple archives and other ramblings
I've always wondered why torrents are packed into multiple archives, sometimes even archives inside other archives. Anyway, I've got fed up with all the unpacking routines, especially after downloading several seasons of something that has each episode in an individual folder containing 20 rar or zip files. So, after one evening of coding this nightmare is now over.
Here is the screenshot of the stupidly named tool (click to visit project page):
It was also a good reason to try out new version of NetBeans. I still hate GUI builders, however for small "write and forget" kind of projects like Multi Unpacker it's a fairly good choice. However NetBeans is still slow and unresponsive in comparison with Eclipse.
So far Multi Unpacker is for Windows only, however it's a spare evening away from becoming cross-platform (and you are welcome to join the project). Too bad my MacBook broke down completely, so Macs will most probably not get any special treatment... This is also bad news for Hawkscope, unless someone is willing to donate me an old Mac? :)
2009-06-07
Cheatsheet: Unicode characters for buttons and GUI elements
Before drawing your own graphics for various GUI buttons, you could try finding a Unicode character that represents the thing you want to do. For instance, up/down arrows can be made with 25B2 (▲) and 25BC (▼).
Here are some pictures with Unicode characters that you can use to build GUIs. First a quick guide to using these: 
Now, the cheatsheets:




These were captured from a tool named Korais.
You can download these images in a single PDF file: unicode.gui.cheatsheet.pdf
2009-04-27
Symbolic links in Windows
Surprisingly, all the good Windows features are hidden, undocumented and hard to find. It took me nearly a decade to accidentally find out that Windows has symbolic links. They are called NTFS Junction Points. However their support is limited to directory links, and the usage is a bit weird.
Oh, and you have to install Windows Resource Kit to get the functionality. You can download it from any of these locations:
- http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en
- http://www.petri.co.il/download_windows_xp_reskit_tools.htm
The command you want is linkd. Let's take it for a spin.
The sandbox contains a directory named
original with text.txt inside.To create a symbolic link named
symlinked that points to original, the command is linkd symlinked original. In POSIX it would be ln -s original symlinked.When calling
dir, symlinked shows as "junction". The other behavior is like a plain folder. In explorer you cannot tell the difference between the two.To delete the symlink use
rmdir, because del will attempt to remove the files from original directory.
2009-03-21
Gmail4J - Gmail API for Java

Seems that Google has no Gmail API available, so I made a small Java library called Gmail4J. The library is designed to be extensible, allowing various implementations. Currently the only available implementation allows getting new unread messages from their RSS feed. That's not much, but it's a start.
Here is the example code (updated to conform with Gmail4J 0.2):
GmailClient client = new RssGmailClient();
GmailConnection connection = new HttpGmailConnection("user", "pass".toCharArray());
client.setConnection(connection);
final List<GmailMessage> messages = client.getUnreadMessages();
for (GmailMessage message : messages) {
System.out.println(message);
}
Next implementation will probably be based on JavaMail IMAP functionality. It should be able to do more than getting unread messages.
2009-03-15
JAD Java Decompiler download mirror
As http://www.kpdus.com is no longer accessible, JAD Java Decompiler download is extremely hard to find. I've put up a mirror where you can get jad executable for Windows, Linux and Mac OS X: http://www.varaneckas.com/jad
Hope this helps those who are having a hard time finding a working JAD download.
2009-02-28
Hawkscope: Twitter plugin
The new release of Hawkscope has a Twitter plugin. Here's how you can install and use it:
Installing
First, go to Hawkscope Settings
Then go to Plugins tab and click Get Plugins
Hawkscope Plugins page will open in your Browser, click on twitter-1.0.jar to download it
Go to your download folder to find the plugin
Then go back to Hawkscope Settings Plugins tab and click Open in Plugin Location
A new Finder (or another file navigator) window will open. You will have to drag and drop twitter-1.0.jar from your downloads to Hawkscope plugins folder 

Then, in Hawkscope Settings Plugins tab click Reload Plugins. You should see Twitter plugin in Available Plugins list
Close Hawkscope Settings window (click OK). Then if you open Hawkscope menu you will see a sad Twitter item. It's sad because there is no configuration.
Configuring
Go to Settings again. Your settings now has a Twitter tab
Enter your Twitter username and password. You can choose what elements to display. I chose not to see my own tweets. Click OK to apply your settings.
Your Twitter Hawkscope menu item is now enabled
Using
Click Tweet! to add a new Twitter status message
And you can also see more tweets or visit them in browser by clicking
Enjoy! And by the way, this plugin works on all operating systems that Hawkscope supports - Windows, Linux (Gnome) and Mac.


