levs brainfukking blog

Tagebuch eines Technikers

Tuesday, September 8, 2009

Howto install BibLaTeX with MikTex

I recently found a pointer to BibLaTeX, a reimplementation of the bibliographic capabilities of LaTeX. It is still in beta stage
MikTeX 2.7, BibLaTeX 0.8h
  1. Download BibLaTeX.
  2. Create a folder named local-texmf (or choose a different name, it doesn't matter) somewhere on your hard drive. This folder will be used to install biblatex.
  3. Create a folder named local-texmf/tex/latex/biblatex. Unzip the contents of the latex-subdirectory of biblatex package into this folder.
  4. Create a folder named local-texmf/doc/latex/biblatex/. Unzip the documentation into this folder.
  5. Extract the remaining folders of the zip package into local-texmf.
  6. Open the "Settings"-window of MikTeX and choose add your folder as root. You might need admin rights for this.
  7. Open the "Settings"-window and choose "Refresh FNDB"
That's it. Now you can use BibLaTeX!

Sunday, February 22, 2009

Display result of select in vertical format

Sometimes the default way of displaying query results in tabular format can be quite annoying. Escpecially, when you have to view them i a small CL window. Fortunately, there is a workaroung:

SELECT * FROM USER\G

By replacing the default ; with \G, the result gets displayed in vertical format. Of course, this needs more vertical space in the CL window. On the other hand, you do not have to deal with annoying line wrapping and stuff.
Be sure to use a capital G though, otherwise this will not work and result in the default tabular view instead.

Saturday, February 21, 2009

Many-to-one and tinyblob

I had the weirdest bug the other day. I was creating a data model for a Java application using JPA and Hibernate as provider.

I was implementing a many-to-one-relationship. Even though I'm no pro at JPA, I never experienced big trouble. Until now. Suddenly, my relations did not turn out in the database model I expected. Instead of creating a foreign key, I always had a tinyblob field. The relevant parts of the class were something like:

protected FinanceProfile financeProfile;

// ...

@ManyToOne
public void setFinanceProfile(FinanceProfile financeProfile) {
this.financeProfile = financeProfile;
}

public FinanceProfile getFinanceProfile() {
return financeProfile;
}


I tried to use this class, but always received an error like:
org.hibernate.exception.DataException: could not insert [com.mypackage.model.FinanceAccount][SQL: 0, 22001]
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'finance_profile' at row 1

Now, do you see the error? Because... well, I didn't. Took me several hours to figure it out. The culprit is... tadaa... I had switched the order of the getter/setter-methods. Well, Eclipse did this for me, and I didn't check. After I changed the order of the two methods (and put the annotation above the getter), everything was ok.

I think I should start annotating the members themselves. That way, this won't happen again (at least I hope so).

Friday, September 5, 2008

Wardriving with my new cell

I recently obtained a Nokia N95 8GB. Besides some other things, it includes WLAN and GPS. This makes the cell a nice platform for wardriving, I thought.

And indeed, it does. After some research, I found the application PyNetMoney. It is written in Python and can be used with Nokia's open source project Python for S60. The installation was quite a pain, since I had to sign every packet I needed by myself. Besides this annoyance, I could successfully install the application. I found a manual on how to avoid signing issues (in German) later on.

I tested the application on two consecutive days. On the first day, I started the application in Graz, Austria, when I went from Dietrichsteinpark to Parkhouse with a friend. During this walk, I kept the cell's slider open and held the cell in my hand. According to the phone's manual, this is the preferred way if you are using GPS services.
On the second day, I started the application while taking a walk with my girlfriend. This time, I kept the cell in a pocket of my jacket, with the slider closed and bottom up -- I figured that I will get a better GPS connection this way, since the GPS receiver is on the bottom of the phone. I don't know if this is correct though.

I exported the results in KML format. They can be imported in Google Earth by using the File > Open from the menu. By checking the appropriate boxes, they can be viewed in the map. I suggest to activate street names as well, because the satellite resolution in this region of Austria is pretty bad, you won't recognize anything if you are not very familiar with the region.

I am pretty amazed of the accuracy of the results. Of some of the WLANs found, I either know the exact location or can give a good estimation of it. Using this information as a criteria, the resulting coordinates seem to be quite accurate, just off by a few meters. When I'll be eating my next Kebap in Graz, I'm pretty shure I'll be able to access the Internet over an open WLAN.

Meanwhile, I'll continue to gather more data on open WLANs in my surroundings. If you are interested in this data (mainly of the upper parts of Styria and Graz), just give me a shout.

Sunday, June 15, 2008

Setting up the TC environment to debug remotely

Since it is quite inconvenient to use Eclipse in the VM, I use Eclipse from my host system. The code and needed libraries can be found in the projects folder of the SVN repository. You have to check it out, then create an Eclipse project from the existing sources.

I shared the project folder using SMB from Windows and mounted it in the Ubuntu image using the following commands:

sudo apt-get install smbfs
sudo mount -t cifs //(hostcomputer)/(share) /media/project-share \
-o username=(username),password=(password),iocharset=utf8,file_mode=0777,dir_mode=0777

Fill in the words in brackets with the appropriate values.
Additionally, I made a softlink in order to access the share more easily. That's just for convenience.

At this point, you should have everything you need, provided that you have Eclipse installed on your host system. There is a nice page on how remote debugging works with Eclipse. I have adapted the jtt.sh script for remote debugging and called it debug-jtt.sh. It waits for connections on port 55555 and does not start until you have connected to the VM from within Eclipse.


The Eclipse configuration is not hard to accomplish. Once you have done this, set a breakpoint in the main method in
iaik.tc.apps.JTpmTools
, start the debug script (it will tell you that it listens to the remote port) and your remote debugging in Eclipse.
That's it. Have fun debugging remotely!

Sunday, June 1, 2008

Pimp my explorer

The German c't magazine has some nice tools to enhance the Windows explorer in issue 12/2008. I tried some of these tools to enhance the usability of my Win Vista system (no discussion about platforms in here).
I made a system image right before that -- just in case, you know?

Tools I want to evaluate:

  1. QTTabBar gives me tabs for the Windows explorer

  2. QTAdressBar adds subdirectories to the breadcrumb navigation of Vista (also works on XP).

  3. FolderGuide allows me to define folder shortcuts in the context menu

  4. Switcher is an overview of my open windows as the Vista 3D task switcher is (the one you get with Win+Tab), similar to Exposé from OS X

  5. Vista/XP virtual desktop manager (man, why do you have to enable JavaScript just to download the software) gives me virtual desktops and is supposed to be than the Microsoft version from Powertoys (never tried to use them, besides SyncToy, which I like).



I've tried the tools while doing some (though inextensive) work on my computer. Here's what I've found so far:

QTTabBar: Well, I think it's quite nice, but I still need time to get acquainted. I just reconfigured the keyboard short cuts to fit the short cuts I'm used from Firefox. Basically, I now open a new tab with Ctrl + T and a new explorer windows with Ctrl + N. I think I will start using it similar to the tabs in Firefox. I certainly always have way too many open tabs, but I prefer this to many different windows. If I get a hold of this tool, I think it will ease some work.

QTAdddressBar: Another tool which is part of my explorer now. Now I have a two bars with a slightly different way to handle, which annoys me to some extent. Besides that, I found the new breadcrumb navigation slightly better. However, the level of subdirectories is not that high on my file system, and I try to keep important folders near me (by using NTFS junctions, mainly). I'll keep that tool at least for some time.

FolderGuide: Man, that's definitely the tool one is watching for. It just gives me a new menu point in my explorer context menu. Well, my context menu usually gets too clutched, but this tool just eases my work. You can define menu point that can be reached in the FolderGuide sub menu. Simple as.
I have some folders that I have to reach quickly regularly, like special save locations for files or the project folders of my current work. Now, they are always just two mouse clicks away. Simple as, but really cool. If you often were annoyed about browsing through your file system and wishing it was laid out more flatly, here's your answer.

Switcher: I have not brought myself in using it regularly by now, even though it is a neat task switcher. I still think of replacing the windows Alt + Tab switcher with this one, currently I replace the 3D switcher from Vista (Win + Tab). But I think I'm gonna keep Switcher, since it gives a good overview when your system is full of open app windows again.

Vista/XP Virtual Desktop Manager: Speaking of open windows, I also installed this desktop manager to get multiple desktops into Windows. I know it from Linux, I also have used it there, but I found no use for it in the past days, perhaps also due to my monitor resolution which allows me to watch 2 to 3 windows simultaneously if I have to. Even though it's a good thing, this will eventually be the first of the tools thaht gets deinstalled from my system.


I plan to review these tools and perhaps add one or two new after I examined them in more detail. I'll post my results same place.

Tuesday, May 20, 2008

JMock 1 short how-to

This document is a nice resource on how to perform a unit test with JMock (which is part of AppFuse).

For some small remarks on how to build the test, here is a portion of the code I used:
 List<Home> homes = new ArrayList<Home>();

// set expected behavior on dao
mock.expects(once()).method("findInPerimeter").with(eq(center),
eq(radius / Constants.KM_PER_DEGREE)).will(returnValue(homes));

List<Home> result = manager.findInPerimeter(center, radius);
assertEquals(result, homes);
This tells the mock that we expect the next method call of the proxied object (in this case a dao) to be of parameter findInPerimeter with the given parameters and to have a result of returnValue. manager uses this proxy to verify the call.