Upgraded wordpress
Jeroen | June 6, 2008 8:00 | 8:00Did a long overdue upgrade of my wordpress install and plug-ins. If you see any glitches, let me know.
Did a long overdue upgrade of my wordpress install and plug-ins. If you see any glitches, let me know.
At my company the sysadmins provide a little service when putting all phone numbers of colleagues on my cell phone. Every colleague is prefixed with a dot. My car’s carkit though lists all numbers grouped by alphabet. So this leads to like a couple hundred entries grouped under a single dot. Fortunatly I can sync my phone to my Apple’s Address Book. When it’s in there, the following little AppleScript allows me to change all first names starting with a dot to something without a dot.
First I transfer all dot-prefixed entries to a special group, then this script runs the people in that group through a little check and adjustment when needed.
(The syntax of AppleScript is a real pain.)
on lstripString(theText, trimString) set x to count trimString try repeat while theText begins with the trimString set theText to characters (x + 1) thru -1 of theText as text end repeat on error return "" end try return theText end lstripString tell application "Address Book" set infoSupporters to people of group "InfoSupport" repeat with p in infoSupporters if first name of p starts with "." then set new_first_name to my lstripString(first name of p, ".") set first name of p to new_first_name end if end repeat display dialog "Done!" end tell
Last week I presented at J-Spring 2008. It was one of the first times I presented to such a large group of unknowns. The room wasn’t packed, but still quite full. Afterwards I heard the head count was over 70 people attending my session. Good to see that many people interested in ANTLR. I was in the before last round of sessions and not everyone of the 1000 people attending was on the premises anymore. So all in all. I think I did good by at least attracting 10% of those people still there.
My presentation went very smooth. In 45 minutes I crammed 42 slides, 3 short demo’s and a 5 minute Q&A.
I did fumble on one single thing.
ANTLR does allow more than 2 nodes with the same root node in a tree.
It’s all supported in the tree grammar syntax. The grammar I demoed was indeed binary, I thought the question was about that fact, while in hindsight I realised the person was asking if ANTLR support AST’s with more than 2 child nodes on a node.
I’ve just put some final touches to a presentation and demo I’m giving on ANTLR v3. On april 16th I will be presenting at the Dutch NL-JUG J-Spring conference. It’s a Dutch conference focussed on all things Java.
Hope to see you there, and if not, my employer is probably going to post my slides very soon somewhere linked of of this page.
Oh my, that Redmond OS called Vista is truly a freakish beast. Today my girlfriends laptop refused to connect to my new Apple Time Capsule. I had my Time Capsule configured for personal WPA/WPA2 over 802.11 b/g/n. My girlfriends Vista laptop was able to connect and authenticate, but was unable to get a DHCP lease, it ended up with one of those 169.xxx.xxx.xxx addresses. The steps to remedy the problem were really bizarre.
I reconfigured my Time Capsule to use no wireless security. I then connected her Vista laptop, it could get a DHCP lease. I re-enabled all security. Adjusted the network settings on her laptop to use WPA2. And it works flawlessly, I can even do ipconfig /renew from a command prompt.
Vista: The dumbest operating system ever if you ask me.
I just wanted t see if I still knew how to write a quicksort by hand. Checked it against “Intruction to Algorithms, 2ND ed.” afterwards and it actually checks out.
package net.leenarts.algorithms.quicksort;
import java.util.Arrays;
public class QuickSort {
public static void main(String[] args) {
int[] A = {3,8,5,9,2,7,4,6,2,9,1,4,2,7,5,4};
System.out.println(Arrays.toString(A));
doQuickSort(A, 0, A.length -1);
}
public static void doQuickSort(int[] A, int p, int r) {
if (p<r) {
int q = partition(A, p, r);
doQuickSort(A, p, q-1);
doQuickSort(A, q+1, r);
}
}
private static int partition (int[] A, int p, int r) {
System.out.println("p=" + p +" r=" + r +" A = " + Arrays.toString(A));
System.out.println();
int x = A[r];
int i = p -1;
for (int j = p; j <= r -1; j++) {
if (A[j] <= x) {
i++;
exchange(A, i, j);
}
}
exchange(A, i +1, r);
return i + 1;
}
private static void exchange(int[] A, int i, int j) {
int temp = A[i];
A[i] = A[j];
A[j] = temp;
System.out.println(Arrays.toString(A));
}
}
Some guy from Buenos Aires made a write-up bashing some features of Java. Let’s test the validity of his argument. Oh, I came across his post through programming.reddit.com.
Based on his gripes he sounds like a systems programming to me, and if your one of those: What kind of problems is he trying? Perhaps pick another language better suited for the job. He actually states this by saying Java is good for web programming, it sucks for what he’s trying to do.
Let’s start with the first one.
It has no unsigned types
He argues about this being a problem when reading unsigned bytes from input. Well according to my memory the inputstream classes support a read byte method which returns an int in the range of 0 to 255. No problem reading unsigned bytes there. It could hurt some people that you are wasting a few bytes though. Also, it does not matter when working with bytes alone.
The shit does start when you actually have to convert bytes to another type, then you need to start thinking about how to deal the signed-ness of bytes in Java. So in my opinion, always having signed types (except for the 16 bit char) can get nasty when doing systems programming. Not to mention the problems this might cause when having to take into account if you should work big- or little- endian. For networks this is no problem, TCP/IP makes sure everything is “network order” which is big-endian and hey Java is also big-endian. Fortunatly the new IO classes can handle byte ordering easily, just have a look at the API docs. Look for ByteOrder and the order methods on the various buffer types. (It really is straight forward stuff, make a buffer, set it’s byte order, start getting and/or putting.)
So yeah, unsigned types can be a pain if you’re doing things the old way (ie. java.io). The new way (java.nio) however makes handling byte orders dead simple, and unsigned bytes can be handled as well as well. The example he gives can still be a pain though, because you easily forget a bit shift, an addition, or a proper read/write of a single byte. I do wonder though if there isn’t a neat way around this.
You can’t inherit constructors
Yeah you can’t. It’s a choice. By requiring explicit constructors calling nothing but super constructors you prevent people from instantiating your class without circumventing the classes initialisation logic. For simple constructors it can look stupid though.
You can’t declare destructors
That’s because you don’t control your objects garbage collection either. You mark an object eligible for collection by dropping references to it, at the same time you could call some cleaning logic. A dispose method is a common pattern.
He states that he had to write stupid finally blocks in his wrapper class. WTF man, add better exception handling. Catch those, handle all you want and be done with it.
You don’t have a sane way of controlling the terminal
He starts yapping on about String security and finally gets to his actual gripe. You can’t hide a password typed on the console. Well, ehm, know your stuff, it helps: http://java.sun.com/javase/6/docs/api/java/io/Console.html
No, you can’t leave stdin/stdout/stderr fscking alone!
What about the get*Stream methods? Ok, your code does have to handle input on those. So you have to do some extra work instead of dumping stuff on the standard console.
No, you can’t handle signals
And then he says you can, because it’s undocumented in some sun package. Well, there’s a reason it’s in the sun package, you shouldn’t use it except when you really really know what your doing.
Conclusion
Lot’s of stuff claiming that Java is garbage, but in the end it comes down to a few misunderstandings, differences of opinion and missing some features in the JDK6 release. And above all, Java is NOT the obvious choice for systems programming. Better leave that to shell scripts, C code, python, Perl, Ruby or some other language.
I hope this post doesn’t qualify me as a Java Zealot. Because there are things I don’t like about Java. Maybe I’ll report about those some other day.
I recently got word from the NL-JUG that they have granted me a presentation slot based on my session proposal regarding ANTLR.
I think it will be a tricky session to pull of properly. I’ll have to make a guess about how much my audience will know about grammar definition, parsers and compilers. But hey, that challenge is part of the reason I made my session proposal.
More details will follow.
Recently I came back from a snowboarding vacation. Only half an hour home after a 12 hour drive I had to check my e-mail.
Too bad I missed the sender and recipient address on an e-mail message. I f-ed up and clicked a link leading me to a PayPal phishing site. I logged in and the site asked for my credit card details straight up. WTF!?! PayPal wouldn’t do that.
I immediately changed my password for PayPal. They didn’t have time to harvest my account. But they sure tried, because PayPal has blocked my account and has me jumping through the usual hoops to let me prove I’m still in control of my PayPal account.
Sigh! Just when I was about to purchase MarsEdit. I never thought I would fall for one of those phising e-mails. But finally I almost missed one, I never thought I would be so stupid.
Moral of this story:
Always double check the links you click in e-mails.
The Mini Cooper parts catalogue details a 2 Board Snowboard roof carrier. I ordered that and thought I could carry my snowboards to some snow covered slopes in the near future. Turns out Mini is not yet manufacturing these things or something. Bottom line, I couldn’t get what I needed.
Next stop Automat, it’s one of those shops where people go to pimp their cars in a very very bad way. They’ve got all sorts of decals, plastic bumpers that would make Dolly Parton jealous, ridiculously over-powered car stereo amplifiers that’ll suck your battery dry and make your ears pop. I should have went there all dressed up in a trenchcoat with a hat and sunglasses like some sleezeball going for a pop at one of the local “ladies of pleasure”.
Anyway, I digress. They’ve got Thule roof carriers too. And I needed a set bad, because it did take a while before word got back that I could not get the BMW part. I ordered a Thule Snowpro, model nr. 746.
The problem is, the brackets supplied with Thule parts only fit they small square bars here in the Netherlands. To make it fit their streamlined bars you need some adapter costing 20 euros. And then it still is a question if these adapters are going to fit my Mini rails. Because the profile on top of my bars are a lot wider. I wouldn’t want my snowboards to go flying of and crash into someone’s windshield, now would I? For the 888 adapters see the image below.
Anyway, I put in a call to my tool-time-Tim super dad. He’s got a garage full of tools and I don’t, so he can actually manufacture stuff. We measured everything and then fabricated 4 little adapters of our own. Made of a solid aluminium bar, 4 bolts, 4 nuts and some locking washers. Total tally at the end of the day 1,65 euro’s. Eat that Thule… Oh, and we the bolts and stuff we used are air service rated, so if you winch my car up by the rails, it wont be the bolts or bolts that’ll break. ![]()
I’ll post a picture of the end result when my digital camera is charged again.
Now I’m off to the garage again.
I was killing time because the garage won’t have service personnel available until 9. Got a flat tire…
:( And I don’t wanna drive 90 kilometers on a flat tire, even when they’re run flats.