2011-03-19

sed made comprehensible!

I needed a regex for a Makefile in an ebuild I was working on, and hit a problem. I needed to match part of a line, discarding the rest and repacing it with something else. This was slightly beyond my experience, having only ever done
:%s/foo/bar/g
in vim before.

I joined #sed on freenode for some advice, and being a good internet citizen I followed their links in the /topic before I asked. Wow, was I in for a surprise finally a sed introduction that is easy to follow and clear. Thank you so much!

My first proper regex, of which I am inordinately proud (put together with no interactive help or direct advice).
sed 's:\(VERSION \=\).*:\1 foo:'
Thank you Grymoire!

--> This blog now has syntax highlighting!

2011-01-31

Converting Nokia Ovi Suite Contacts for Android (nbu2gmail, or nbu2csv)

== 2012 Update == This has gotten easier! I've posted a more up-to-date version here. == Too Long, I'm Lazy Version ==
Since most people getting to this page will just want a quick solution, here's the quick-and-easy version of the post. If you're in the mood for how I got to this awful hack of a way to convert contacts, read on ...

Phone -> OVI Suite -> NBUExplorer -> Microsoft Live Mail Address Book -> Gmail
On-phone -> .nbu -> (many) VCards -> .csv -> Online

If you're not stuck in Windows waiting for an interminable Ovi Suite synchronisation, you may have more luck with the scripts I discuss later in the post.

Update 2011-09-25 : Made this summary a little easier to follow, since this post is being read by way more people than I would have expected.
== Full Post ==

I just bought an HTC Desire, upgrading from my Nokia E66 which suddenly started to feel dated when I saw how fast Opera loaded on one owned by a friend of mine.

The problem is that in 2008, Nokia decided to do a complete overhaul of their mobile software, rebranding it from "Nokia PC Suite" to "Ovi Suite". They massively simplified the UI, introduced many bugs, and slowed it down to a crawl. Most importantly for me, they removed any way of extracting my Contacts in any useful format. All I could get with the most up-to-date version of Ovi (as of Jan 2011) was a "Nokia BackUp" .nbu file, which is intended to lock you into Nokia's Ovi platform. Fantastic.

According to the article on wiki, they've just added the ability to receive delivery reports to the phone, having sent a text message from Ovi. This despite the many hundreds (thousands?) of posts I have read asking for .csv output. Oh well.

Open-source to the rescue though - thank you to petrusek for his excellent NbuExplorer, which extracted all of my contacts with ease.

Bizarrely, it seems that the contact details stored in the .nbu file are in a perfectly simple and open format, VCard. I can't think of a reason that OVI doesn't allow users to extract them aside from platform lock-in. I'm very glad that the rest of the world seems to be moving away from this kind of thinking.

So now I was left with 334 VCards, only to find that Gmail Contacts would only allow me to upload one at a time. Poor thinking Google!

I have used VCards in KAddressbook before, so I knew that it was possible to create a single .vcf file with many VCard entries in it, but Gmail doesn't support this. There goes my easy
$ cat * >> contacts.vcf ! The only multiple-entry format that Gmail seems to support seems to be tried-and-tested CSV.

I first tried VCF-to-CSV-converter, but the VCards that OVI output were VCARD-2.1, and the converter only supports VCARD-3.0. Maybe it will someday. It also fails silently, adding a WARNING tag to the output csv file, but printing nothing to the console. Tut tut.

In retrospect, I should have tried replacing the version string in my VCards and trying vcf-to-csv-converter again, but it didn't occur to me at the time, and it seemed obvious(!) that there would be a script to do this incredibly common conversion.

Being stuck in Windows while Ovi Suite did its thing, I wasn't able to run VCFConvert, since PHP wasn't available through the Cygwin installer. If you are less paranoid than me, you could use the online version though.
I downloaded VCF2CSV, but had a solution before Cygwin installed a compiler for me (I use this Windows install so infrequently, I didn't even have an editor!)

Rather unbelievably, Annesoft wanted $20 for this trivial task. I didn't try their software either.

I tried CKHung's vcf2csv, the only script-based tool that I could get to work. Bizarrely though, "vcf2csv ignores the problematic FN field. (First Name)", which seriously limits its usefulness. I wonder what makes it harder to deal with than other fields. Again, this is probably easily fixed, but I was getting impatient to try my new phone!

In parallel with these attempts, I installed Thunderbird, confident that any decent open-source program as mature as TBird would be able to deal with common plaintext formats like VCard for me. Imagine my surprise when it couldn't! Oh, it would import from Outlook Express for me, but not VCard! The "More Functions for AddressBook" extension promised to do this for me, but I could not get it to work.

Seeing as Thunderbird had alerted me to it's presence, I next tried Outlook Express, and I was shocked to see exactly the same program my parents had been using the year that we bought our Pentium 4. Needless to say, Outlook Express didn't support importing multiple VCards at once.

Some more googling found me a blog post suggesting Windows Live Mail, which as it turned out was also installed on my machine. Lets not get into talking about finding new programs installed by stealth by a system update utility... Despite all that, it worked! The only hiccup was that I had to pretend to have a pop3 account just to use the Address Book feature. Importing the VCards took a long time (20-30 minutes?), but I was able to import them all, and then export to CSV. Success!

Minutes later, my Gmail Contacts were fully populated with phone numbers. Whew.

// This post was written while listening to a really catchy tune

2011-01-18

Chromium, Tab completion

So I'm typing out the first few letters of a URL into the Chromium Omnibox (that box for addresses and search strings), and Chromium happily auto-completes it for me. Cool, now I can get to reader.google.com just by typing 'r'!

Except not - conditioned bash user that I am, my subconscious sometimes expects Tab-completion - so I hit TAB before I hit Enter. Suddenly I'm at some other website, Tab has changed the focus to the first link on the page contents. Gah!

When I started writing this post, I hadn't quite figured that out -- but Tab to change focus is perfectly normal UI behaviour. Still, it's pretty aggravating; not that I can see a way around it, since using Tab to iterate through the links on a page is pretty useful (say, when you have no access to a mouse). Oh well ...

2009-08-11

Ugly Firefox in Gentoo (and a fix!)

Somehow, this xkcd strip really made me want to post here again. I'd all but forgotten that I attempted to start blog many months ago, except for a "Follow this blog" button that would appear on other blogs.

I started writing my first post with the intention of noting down useful technical tips that I'd come across and that other people might need. I never ended up writing an introductory post, just leapt into describing my Qualnet problem. I find it amazing the way that closed-source programs never seem to generate a helpful community around them like open-source does; their support forum was dead and there were almost no websites covering Qualnet or any blogs at all that I could find (surprise!). The only counter-example I can think of is Matlab, but the general status-quo there is for people to upload zip files of scripts that they've created. No versioning, no concerted open projects and no real community spirit (that I could find, anyway).

Anyway, today's post is about ugly Firefox in Gentoo. If you've ever used Firefox in Gentoo, or (who knows?) other distros that don't set up the GTK theme nicely by default, you'll have noticed how horribly ugly the default menus are. The program looks ancient, and really makes you feel like you're back in the Firebird days (or before :( ). I discovered later, that they are a theme called "Gentoo", so someone put it together intentionally (??). Anyway, on to making it look a bit better.

Here's what it looked like before. Look at the horrible grey boxy menus. Check out how new to this I am :-/ )


So, first I installed some Gnome themes. I don't have a full gnome install on my machine, so couldn't use whatever Control-Panel-alike that they have.


Next, I installed a handy GTK theme Switcher (switcher2 if you're a Debian/Ubuntu head)


Here's switcher2 in action (run as my normal user).

Before: Initially, it looks as retro as Firefox


After: (Of course, there are piles of other themes available, but this is the one I chose)


This equates to the following in ~/.gtkrc-2.0
  
include "/usr/share/themes/Clearlooks/gtk-2.0/gtkrc"

include "/home/jim/.gtkrc.mine"

(I don't have a .gtkrc.mine btw)


Now let's check Firefox, to see if it had an effect :


Victory!


In case you're wondering, I ended up using the Gimp to take the screenshots after failing to get import and xv to only capture the Firefox window. A nice side effect of running through this again to write it up is that I got to see Gimp start to look prettier too :)






2009-04-25

Qualnet on more then one X Screen - java.lang.ArrayIndexOutOfBoundsException

Edit:  Damn, apparently switching to java 1.6 brings its' own host of problems with it. Have to stick to java 1.5 for the moment. 

--------------

So google totally failed me when I got this error, so here's how I fixed it. 

I have two monitors, each running an X screen on the same X server (:0.0 and :0.1)

The Qualnet IDE was starting fine from the first screen (:0.0), but when trying to run it on the second (:0.1), I was getting : 


Using /home/broadhej/.qualnetUserDir as user directory...
-- System Info ----------------------------------------------------------------
  Product Version = QualNet 4.5 (Build 200803141608)
  IDE Versioning = IDE/1 spec=1.43.3 impl=200803141608
  Operating System = Linux version 2.6.28-gentoo-r1 running on i386
  Java; VM; Vendor = 1.5.0_18; Java HotSpot(TM) Server VM 1.5.0_18-b02; Sun Microsystems Inc.
  Java Home = /opt/sun-jdk-1.5.0.18/jre
  System Locale; Encod. = en_IE; UTF-8
  Home Dir; Current Dir = /home/broadhej; /main/linprogs/qualnet/4.5/gui/netbeans/bin
  IDE Install; User Dir = /main/linprogs/qualnet/4.5/gui/netbeans; /home/broadhej/.qualnetUserDir/4.5
  CLASSPATH = /main/linprogs/qualnet/4.5/gui/netbeans/lib/patches/openide-compat.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/core.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/openide.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/ext/crimson.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/ext/derby.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/ext/derbytools.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/ext/flexlm.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/ext/jh.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/ext/regexp.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/ext/skinlf.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/ext/terminalemulator.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/ext/xerces.jar:/main/linprogs/qualnet/4.5/gui/netbeans/lib/ext/xmlparsers.jar:/etc/java-config-2/current-system-vm/lib/dt.jar:/etc/java-config-2/current-system-vm/lib/htmlconverter.jar:/etc/java-config-2/current-system-vm/lib/jconsole.jar:/etc/java-config-2/current-system-vm/lib/sa-jdi.jar:/etc/java-config-2/current-system-vm/lib/tools.jar
-------------------------------------------------------------------------------
java.lang.ArrayIndexOutOfBoundsException: 1
  at sun.awt.X11GraphicsEnvironment.getDefaultScreenDevice(X11GraphicsEnvironment.java:178)
  at java.awt.Window.init(Window.java:271)
  at java.awt.Window.(Window.java:319)
  at java.awt.Frame.(Frame.java:419)
  at java.awt.Frame.(Frame.java:384)
  at org.netbeans.core.Splash$SplashWindow.(Unknown Source)
  at org.netbeans.core.Splash.createW(Unknown Source)
  at org.netbeans.core.Splash.showSplash(Unknown Source)
  at org.netbeans.core.Main.main(Unknown Source)
  at org.netbeans.core.TopThreadGroup.run(Unknown Source)
  at java.lang.Thread.run(Thread.java:595)
/main/linprogs/qualnet/4.5/bin

The fix? Get Qualnet to use a newer jvm. For me, that was:

JDK_HOME=/opt/sun-jdk-16.0.13/ qualnet_ide

Incidentally, it's ridiculous that they don't ship qualnet with a directory-aware executable; here's my script for starting it up;

 cd /main/linprogs/qualnet/4.5/gui/netbeans/bin

 ./runide.sh $*

 cd -

Problem solved!