Skip to content

www.rolfje.com

Author: rolfje

Where’s North again?

Posted on 2005-10-03 By rolfje 1 Comment on Where’s North again?

Lately, I’ve been collecting race circuit locations using Google Earth. It’s really nice to see the sometimes very detailed satelite images of race circuits. You can actually see the seperate kerbstone blocks of silverstone, and see how many cars there were parked at the time the picture was taken. You should try it.

What really started to catch my interest is the fact that the maps of circuits as they are used in logo’s or (worse) “how to get there”-maps are almost never of the “north pointing up” type. An example:
The circuit “Road America”, which is located a few miles north-east of Atlanta, Georgia, has a web-site which shows you a detailed map of the circuit, as well as pointers to the nearest highways. I have grabbed an image (because they only have these stupid noise making flash movie thingied nobody is interersted in after the second visit). It looks like this:

So, in my quest to find this circuit using Google Earth, I found the circuit to be along the 53, halfway from the I85 to the I985, just like the directions stated. But, the circuit seemed to be “turned around:

I have noticed this with a lot of ciruits. I understand the need of turning and simplifying the circuit to make a nice logo, but when the circuit is depicted next to driving directions, I would make the map “north side up” so nobody gets confused. In the first image, the I85 apears to be west of the circuit, while it is actually east of the circuit.

Google Earth location of Road America (so you can check for yourselves):

<?xml version=”1.0″ encoding=”UTF-8″?>
<kml xmlns=”http://earth.google.com/kml/2.0″>
<Document>
<Style id=”khStyle662″>
<IconStyle id=”khIconStyle664″>
<Icon>
<href>root://icons/palette-3.png</href>
<x>224</x>
<w>32</w>
<h>32</h>
</Icon>
</IconStyle>
</Style>
<Placemark>
<name>Road Atlanta</name>
<LookAt>
<longitude>-83.81483349103033</longitude>
<latitude>34.14598906888146</latitude>
<range>2835.974155514713</range>
<tilt>-8.888997363646108e-012</tilt>
<heading>0.3186400317363279</heading>
</LookAt>
<styleUrl>#khStyle662</styleUrl>
<Point>
<coordinates>-83.81483349103033,34.14598906888146,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>

Racing

Ibatis and Timestamps (2)

Posted on 2005-07-04 By rolfje No Comments on Ibatis and Timestamps (2)

People who have read my last post are now probably removing the Date classes from their beans, replacing the code with things as new Long(new Date.getTime()) and such. This is also what I started doing, until a collegue of mine pointed out that the TypeHandler I wrote last saturday could also do the trick. This would mean my beans could still contain clean Dates. I was so close, and failed to realize that I (or ibatis) had that power.

So I set out to do this and it works wonderfully. What I did was the following. I changes all postgres timestamp fields to bigints, like you read yesterday. I left my beans unchanged, containing java.util.Date objects for representing dates. So now all we need to do is write a typehandler which converts the date to a long and back, so Postgress and the buggy JDBC driver don’t realize it’s actually a Date.

To do this I wrote the following TypeHandler:

public class DateTypeHandler
implements TypeHandlerCallback {

public void setParameter(ParameterSetter setter,
Object parameter)
throws SQLException {
if (parameter == null) {
setter.setNull(Types.BIGINT);
} else {
Date datetime = (Date) parameter;
setter.setLong(datetime.getTime());
}
}

public Object getResult(ResultGetter getter)
throws SQLException {
long millis = getter.getLong();
if (getter.wasNull()) {
return null;
}
return new Date(millis);
}

public Object valueOf(String s) {
return s;
}
}

Now, all we need to do is tell ibatis to use this typehandler whenever we try to insert or retreive a java.util.Date. We do this by adding the following line to the ibatis SqlMapConfig.xml file, just after the typealias definitions:

<typeHandler javaType="java.util.Date"
callback="com.bestlaps.database.typehandlers.DateTypeHandler"/>

After doing this, you can cary on doing things as normal. Beans can contain java.util.Date, and ibatis happily inserts and retreives them in postgres bigint columns without any timezone conversion. Please note that timezones are not stored at all here, so when you retreive a Date from the database, the java.util.Date object will have your local JVM’s devault timesone offset. You can happily ignore this, especially if you’re not going to do any calculations with it.

The beauty of this solution is, that when there is a solution for the silly timezone conversion problem/bug, we can simply convert all database fields to timestamps, and remove the typehandler reference from the SqlMapConfig.xml file, and you’re all set without changing a single line of code.

Thanks Joris!

Software

Ibatis and Timestamps

Posted on 2005-07-01 By rolfje 1 Comment on Ibatis and Timestamps

I am using Ibatis and PostgreSQL for this great project, www.bestlaps.com. However, we’ve recently ran into a strange problem where we store a java.util.Date into a postgress TIMEZONE column, which works fine. However, when you want to retreive it, Ibatis returns a “StringIndexOutofBoundsException” at position 23. For some reason, the result returned by Postgres can not be converted back into a java.util.Date.

I’ve tried really hard to circumvent this problem with custom setter methods (parsing the results myself), and using jodatime (a great java date and time replacement library). The fix is as simple as it is strange: Make Ibatis convert the timestamp into a java.sql.Date, without changing your code.

So: You have your normal bean, in which you use java.util.Date. Then, make your Ibatis sqlMap as usual, but for the timestamp column you put the following in the resultmap: javaType=”java.sql.Date”.

Strange, but it works for now. Maybe more info on this later.

UPDATE: Okay, after spending the whole weekend with this problem I discovered that the trick I just described does noet work. java.sql.Date has no time component, so when you retreive it, your java.util.Date in the bean will have a 00:00 time. So I had to search a bit further.

When querying with SquirrelSQL, I can insert and retreive a timestamp to and from Postgress without it being changed. So it seems that it is no Postgress bug. When I am using Ibatis to insert a java.util.Date into Postgress, it gets “timezone corrected”, although I specifically told Postgress to store timestamps without timezones.

The time gets corrected by 2 hours. This seems to come from the util.Date class, which seems to have a default offset of -120 minutes, although I did not set that, and did not request any timezone to be set.

I tried to make my own typeHandler for Ibatis, where I could convert the java.util.Date to a java.sql.TimeStamp, and give it directly to the PreparedStatement. But even that did not help. I am guessing the bug is in the Postgress JDBC driver, although that conflicts with the fact that SquirelSQL (which is als a Java/JDBC program) can do it.

THE FIX: After more than 16 hours (!) of research I decided I would go for the workaround. We are behind schedule allready for the www.bestlaps.com project, so I needed a quick fix. The way to go was dissapointingly simple: Convert Date’s to Longs (with getTime()) and store the Longs in the database as number. This way ibatis and postgress don’t know that it’s a time. Pay attention to the fact that you need a postgress BIGINT to store the large number of milliseconds since the epoch.

Final thoughts: It seems that people who do not know how to handle timezones have built code to handle timezones. For Java, Postgres, Ibatis, or somewhere around that neighbourhood. Oh well, we knew that Java doesn’t have a great Date system. A promising solution I found (but not used yet) is JodaTime.

I really hope the bug gets fixed soon so I can have proper dates in the database when we go live. For now, Longs work (and will probably stay in to the end of time).

Software

Dodenherdenking

Posted on 2005-05-04 By rolfje No Comments on Dodenherdenking

Ben ik nou gek, of word dodenherdenking tegenwoordig een beetje “afgeraffeld”? Iedere Nederlander zou toch moeten weten hoe belangrijk het herdenken van de tweede wereld oorlog is (en zou moeten blijven). Toch lijkt het erop dat er steeds meer gemorreld wordt aan de gedachte, en de uitvoering van de herdenking zelf.

Read More “Dodenherdenking” »

Uncategorized

Drag Racing Season 2005 Calendar

Posted on 2004-12-11 By rolfje No Comments on Drag Racing Season 2005 Calendar

As usual at the end of august, in 2005 there will be another edition of the Nitro OlympX. Aside from being a great entertainment-for-the-family weekend, it is also round 5 of the FIM/UEM EUROPEAN CHAMPIONSHIP TOUR:

Round Venue Date
1 Santa Pod, England
(Main Event)
May 27-30
2 Alastaro, Finland
(FHRA Nitro Nationals)
July 1-3
3 Mantorp Park, Sweden
(Veidec Nitro Festival)
July 28-31
4 Gardermoen, Norway
(Drag Challenge)
August 5-7
5 Hockenheim, Germany
(NitrOlympX)
August 19-21
6 Santa Pod, England
(European Finals)
September 8-11
– Bahrain
(Dragracing Festival)
November 9-11

Please note that the dates may be subject to change.

More information can be found at Monique’s Top Fuel Drag Racing Site (it’s also the place where I got the schedule from :-), thanks Monique!.

Have a great 2005 season and may the best bike win! (like it did last year 😛 )

Racing

Milling aluminum housing

Posted on 2004-11-14 By rolfje No Comments on Milling aluminum housing

Today I found the first good use for the milling machine. I had this cast aluminum housing for an electronics project, with ridges on the inside. I made a hole for a connector in it, but I never got the nut on the inside flat to the surface because of the ridges on the inside of the housing. I decided to use the mill to flatten the surface on the inside of the housing. The housing did not fit in the clamp, so I had to find a way to get it attached to the bed of the mill in a different way. I took a piece of wood, drilled two holes in it and bolted that to the bed of the mill. Then, I used long plywood screws and another piece of wood to hold the housing. In the picture on the right you can see this construction. I used a test indicator to align the house to the X-axis of the bed.

Since I only needed a plane large enough to place a ring and nut on, I roughly adjusted the 6mm mill to just not touch the bottom of the housing. I milled down to the point where the ridges were not visible. The image on the left is the result of the work. The mill is a very nice tool to adjust ready-made electronics housing to your likings.

Hardware, Racing, Workshop

Miling machine

Posted on 2004-11-07 By rolfje No Comments on Miling machine

16mm mill detail Yes, that’s right. That’s a mill you’re looking at. And yes, that photo was taken at my workshop. Last week I took a couple of days off from work, and decided to do another workshop upgrade session. After buying some decent wrenching tools, I spent some hours on the web looking for a nice bench drill. I was thinking of buying a cheap mill later on, but I found a nice combination of the two at the locloods. This small mill, the HMD Black & Red X1-super, is a nice hybrid. It operates like a bench drill, but when the handle is locked, you can use the wheels to precisely control X and Y movement of the working piece and Z movement of the mill.

Milling MachineI made a nice sturdy table for the mill to rest on and bolted it on. It was a bit hard to get the mill on the high table, because it weighs about 45 kilograms and it’s really hard to grab on to. I’ve put a piece of white MDF board on the wall to hold the tools that go with the mill. Putting pieces of wood against the wall to hold tools is terrific. I’ve also done this with the tools for my lathe, see the zundapp image gallery for more pictures of the workshop.

What was once a gray and dark place to just park a car in, is now almost a solarium with lots of tools. There’s still a lot of work to be done to get the workshop completely ready, and I wonder if it will ever be finished, but it’s becomming more practical every day.

Workshop panorama

Hardware, Workshop

Mopeds are cool

Posted on 2004-10-31 By rolfje 5 Comments on Mopeds are cool

Today I picked up my old moped at my parents house. Yes, that’s right, I’m 33 and I still have my very first moped. It’s a real special one. I belonged to my grandfather, who passed it on to my nephew, who passed it on to me when I turned 15. When I got it it needed a lot of work. I spent some months taking it completely apart with my dad. We didn’t have a workshop back then, so we took it apart in the kitchen, of my parent’s apartment on the 7th floor :-)When I turned 16 it was ready and better than new. It was really cool to have a classic Zundapp CS50. At that time, it looked like a motorbike next to my friend’s puchs and peugeots. It really was a dream to ride, you could sit for hours on it without getting tired. I drove it for a good 6 years before it went in to “hibernation”.

So, having my own home and my own workshop right now, I decided it was a good time to pick it up and make it run once again. These German mopeds are made to last, I can tell you. When I get it running again I am sure it will be able to run for at least another 20 years or so, provided it gets reasonable maintenance.

Browse through the “Zundapp” gallery to see more pictures.

Hardware, Workshop

DTM2 on PS2 uses Gamespy!

Posted on 2004-10-30 By rolfje No Comments on DTM2 on PS2 uses Gamespy!

History, Sony Online Drama
I bought a Sony PS2 a few years ago, when it just got out. I beleive it belongs to the first or second batch of Playstation 2 consoles arriving in the Netherlands. It costed a small fortune. About a year later, I purchased the Linux kit for my PS2. The Linux kit came with a network adapter and a harddisk. It worked like a charm. Sony had not started the online game service back then.

When Sony finally announced their network gaming plans, the Linux for Playstation group very kindly sent me a “Network Access Disc”. This is the disc you normally get when purchasing your network adapter for the PS2. However, being an early version and all, I never got it working properly. I spent hours (no, literally!) trying to register my handle and username. I never got it working properly. Friends of mine who bought the official adapter had newer versions of the software, which seemed to work better but still not good enough.

The beautiful world of non-Sony developers
I had given up on online gaming on the PS2 by now. A few months ago I played an online demo of DTM race driver 2 on my PC, and had great fun. I registered with GameSpy and was online and gaming with my friends in less than 5 minutes.

Last weekend, I found a copy of DTM2 for the PS2. Since I liked the fysics engine of DTM2 for the PS2, I decided to give it a try. Not even thinking about the cruddy PS2 online gaming option. When I got home and started the game, I was pleasantly surprised to see that DTM2 for PS2 actually uses the GameSpy system in stead ot the stupid Sony stuff. Again, I was playing online in within 5 minutes (had to look up my old GameSpy Id). I even hooked up an USB keyboard, which made logging in even simpler! Terrific!

My compliments to Codemasters and Gamespy, who have restored my hope and ability to play online games with my PS2.

Games

Posts navigation

Previous 1 … 34 35
           

Recent Comments

  • rolfje on Methode Buijs uitgelegd
  • LinkedIn is at Peak Enshittifaction – Will Chatham's Blog on Linked-In not really Opt-in?
  • Hans j on 1N4148 diode as RF switch
  • Roaming Rhonda on DLNA on OSX, done right
  • Frans on How to fix a Krups XN2001 Nespresso machine

Tags

Anonimatron Apple backup design DIY DRM eclipse environment Fun gmail google hacking hamradio Hardware helicopter iphone ipod iTunes Java Keynote maven modelling motorcycle music news opinion oracle osx photo photography programming repair review security Software Steve Jobs T-Mobile technology Time Machine Ubuntu usability Utilities vacation windows Workshop

Categories

  • Apple (105)
  • Divorce (1)
  • Electronics (3)
  • Fun (57)
  • Games (7)
  • Hardware (72)
  • Microsoft (18)
  • Racing (14)
  • Software (134)
  • Uncategorized (65)
  • Workshop (20)

Archives

Copyright © 2025 www.rolfje.com.

Powered by PressBook WordPress theme