Blog


What was I thinking ?

4 years zero blog streak

Here I am, almost 4 years later with a personal blog update.

Just to initially say that I finally got my website moved of a mix of wordpress and other fancy stuff over to Awestruct.

Now we’ll see if I actually get around to write those blogs I’ve been saving up for the last 4 years!

Comments


Converting thousands of WMA files to MP3

I've been using a Mac Mini for a while now to run my media center but recently I discovered that I actually had more than 8.000 songs in WMA format that iTunes silently ignores when importing.

This blog is about how I managed to get that converted without too much fuzz.

UI Conversion tools

There are many various conversion tools out there for OS X, Switch being one of the better ones but it does not seem to handle massive conversions very well. The Windows version has a command line interface that could be used but its just too much hassle.

If you got small set of files to convert then Switch works fine. Be aware that the latest Flip4Mac might cause problems for Switch, I had to use an older version (2.2.2.3) to make it work.

Because Switch and all other UI's I tried for OS X did not work well for large scale conversions I decided to find a way to do it via a command line. This allows me to easily control it and in case something fails restarting it from where it stopped is much easier than any UI tool.

Converting (non-DRM) files via command line on OS X (excl. Tags)

Note: The following converts the files fine, but tags are not maintained! Just be aware of this limitation! Using LameXP described below seem to copy tags better, but that requires a Windows installation.

For command line conversion under OS X you need Lame+MPlayer installed; I got mine installed by simply using MacPorts:
sudo port install mplayer
You might need to also install Flip4Mac in case there isn't another WMA decoder available.

After installing mplayer, create this shell script which convert a single file, name it convert.sh:
if (test -e "`dirname "$1"`"/"`basename "$1" .wma`.mp3"); then
 #echo mp3 $1 already exists
 test true
 else
 mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$1" && lame -m j -h --vbr-new -b 160 audiodump.wav -o "`dirname "$1"`"/"`basename "$1" .wma`.mp3"
 rm -f audiodump.wav
 fi
This script checks if a wma file given as input has a matching mp3 file in the same directory and if it has not it uses mplayer + lame to perform a direct conversion to mp3.

With the convert.sh script in place you can use the following command to convert all .wma files that does not have a matching .mp3:
find . -name "*.wma" -print0 | xargs -0 -n 1 -L 1 -I {} ./convert.sh "{}"
The -print0 and additional arguments to xargs is what ensures filenames with spaces, weird quotes or non-latin characters gets properly quoted.

Then you should see console output for all the conversions and get all your files converted nicely. It took my laptop about 24 hours to churn through my non-DRM WMA files.

In case you bump into a file that cannot be converted then check if the file is actually valid and can play somewhere else (i.e. on a Windows machine or with iTunes with right encodings installed) - if it can play, but Lame will not then it is mostly likely because it is a DRM protected WMA. I had about 2.500 of those (yeah, I forgot to disable DRM when converting parts of my CD collection ;(.

Conversion of DRM protected WMA files (incl. Tags)

There exists many weird applications which doc's state they can "break" the DRM encoding by letting iTunes play them and then record the digital output stream to write them to a virtual ISO image for then to convert them to mp3.

I tried many and most of them simply did not work out of the box or required massive tweaking to actually work but then the conversion took ages plus it was not very fault tolerent.

Therefore I decided to simply startup my Windows 7 virtual machine, Install LameXP and simply let it do all the work.

Again, I had many DRM files that needed conversion (2.500+) and adding them manually would take forever. Once again a little script made it much easier.

Create a file named check.sh with the following content:
if (test -e "`dirname "$1"`"/"`basename "$1" .wma`.mp3"); then
 #echo mp3 $1 already exists
 test true
 else
 echo $1
fi
Then use this script with the following one-liner:
find . -name "*.wma" -print0 | xargs -0 -n 1 -L 1 -I {} ./check.sh "{}" > needconversion.m3
Running this finds all files matching *.wma, passes them to xargs in a way so there won't be problems with quotes, spaces, etc. and then for every single found file calls the check.sh script and writes the result to the file "needconversion.m3u".

All there is left then is to Add the "needconversion.m3u" to LameXP and when it has spent a few minutes on importing it press the Encode button and let it do its business. On my laptop it takes about 10 sec. per file, thus 2.500 files takes about 7 hrs.

Be aware that LameXP as many other conversion UI's does not seem to cope well when you have many thousands files to convert, but it did though a good job with my 2.500 files at once. If someone know a good way to do similar conversion but via command line on windows I would love to hear.

Fixing Tags

To fix broken tags i'm experimenting with using Jaikoz which is a for pay Java app that uses MusicBrainz to match songs by acustic fingerprints. For now it looks to doing a great job of matching up the songs, but if someone knows how to copy tags from 6.000 WMA to their matching mp3 let me know :)

Comments


Migrating from Serendipity (s9y) to WordPress

I migrated this blog from from Serendipity (s9y) to WordPress.

It turned out to be pretty simple to import s9y posts to WordPress with the s9y importer, but making sure the old links to posts and feeds turned out to be a bit trickier.

I found a blog post that outlined how to use .htaccess to solve some of these problems, but it included manually having to figure out which id's that had become skewed during the import process. Luckily the SQL schema of both s9y and WordPress is pretty similar and easy to do queries against to generate matching .htaccess lines.

The following SQL queries is what I used to create a working .htaccess file for my migration, use at your own risk ;)

SQL for posts:

SELECT CONCAT( "RewriteRule ^archives/", s9.id,
"\-.*.html$ /index.php?p=", wp.id, " [L,R=301]" )
FROM `serendipity_entries` s9, wp_posts wp
WHERE wp.id != s9.id
AND wp.post_parent=0
AND s9.title = wp.post_title
ORDER BY s9.id
SQL for category feeds:
SELECT concat("RewriteRule ^feeds/categories/", s9y.categoryid,
 "\-.*.rss$ /index.php?cat=", wp.term_id, "&feed=rss2 [L,R=301]")
FROM `wp_terms` as wp, serendipity_category as s9y
where name = category_name
SQL for category:
SELECT CONCAT( "RewriteRule ^categories/", s9y.categoryid,
 "\-.*$ /index.php?cat=", wp.term_id, "[L,R=301]" )
FROM `wp_terms` AS wp, serendipity_category AS s9y
WHERE name = category_name
Once you have the output from these insert them into the following .htaccess file:
RewriteEngine On
RewriteBase /


## skewed articles [Insert output for Posts]

## categories [Insert output for Categories]

## category feeds [Insert output for Categories feeds]

## handle defaults RewriteRule ^archives/([0-9]+)\-.*.html$ /index.php?p=$1 [L,R=301] RewriteRule ^archives/([0-9]{4,4})/([0-9]{2,2}).*.html$ /index.php?m=$1$2 [L,R=301] RewriteRule ^archive$ / [L,R=301] RewriteRule ^feeds/index.rss2$ /index.php?feed=rss2 [L,R=301] RewriteRule ^feeds/index.rss1$ /index.php?feed=rss [L,R=301] RewriteRule ^feeds/index.rss$ /index.php?feed=rss [L,R=301] RewriteRule ^feeds/index.atom$ /index.php?feed=atom [L,R=301] RewriteRule ^plugin/tag/(.*)$ /index.php?tag=$1 [L,R=301] RewriteRule ^categories/(2)\-.*$ /index.php?cat=3 [L,R=301]
With that in place in the root of your WordPress installation those using your old s9y links should now be redirected automatically to the matching WordPress posts/feeds/categories.

Another useful post I found were about how to move WordPress between domains, which I needed because I intially installed it on wordpress.xam.dk but needed it to end up on blog.xam.dk and apparently WordPress thinks it is a good idea to stored absolute url's in its settings.

Now if I could just find a WordPress theme that were both beautiful, simply and functional...still searching..

Comments


Jing - the best tool for reporting bugs for any UI!

Jing is a tool for grabbing screenshots and screencasts on Windows and Mac.

That does not sound so new and exiting until you actually try and use Jing.

They made it so easy to do the screenshot and screencasts that everybody can do it without spending any more time than it takes to actually do the act you want to record.

Furthermore they provide a one-click sharing facility so the only thing you have to do is to paste the automatic generated url into your favorite products issue tracker to be able to let everyone see what the bug is about.

Jinq does not have many editing facilities so you can't fix any stupid mistakes you did for e.g. a demonstration (I currently use Wink for that), but for quick'n'dirty grabbing a screenshot or recording a screencast nothing gets close to the ease and use of Jing!

I'm definitly going to recommend it to anyone that want to easily show a bug (or a cool thing) in JBoss Tools or JBoss Developer Studio.

Update: I realized I had written jinq instead of jing. That is now fixed ;)



Comments


Making Eclipse look good on Linux

I have been bothered a long time by the "clumsy" look that Eclipse has on my Fedora box compared to how it looks on Windows and Mac.

Eclipse 3.3 running on Windows XP

Windows Sample

Eclipse 3.3 running on Fedora 6 (but looks very similar on other distros)

Windows Sample

Notice that the font size is bigger ( 10 vs 8 ) and that there is alot of extra spacing between elements (The package tree and problem view is much more compact on windows).

I tried changing the GTK themes but the issue prevailed - the themes doesn't seem to adjust the fonts only the component "look".

But with some help from my Red Hat friends on our tech-list I got some tips and ended up getting close.

The tweaks



Install Red Hat Liberation fonts which are free/liberated Windows fonts available for any OS and readily available in Fedora's repositories so they are very easy to install via yum.

After they are installed I ran gnome-font-properties and used the following settings:

Application/Document/Desktop font: Liberation Sans, size 8 Window title font: Liberation Sans Bold, size 10 Fixed with font: Liberation Mono, 10

Font rendering: Best contrast (the others left weird artifacts, but mostly up to taste here I think)

Under details: Resolution: 99 dpi (to avoid the letters to get too close, need at least 1 px between them ;) Smoothing: Grayscale

Hinting: Full

Depending on your Eclipse font settings the above will be enough, but if you already have tweaked some settings remember to check your Font settings under Eclipse preferences and verify that you are actually using the System default or the Liberated fonts to get the smoother more compact look.

Eclipse 3.3 with Liberation font + tweaks

Windows Sample

Much better, but unfortunately GTK still thinks it needs to have 1-2 extra pixels between components. If anyone knows any tips on how to reduce that wasted space then please leave a comment ;)

(Now I just need to figure out how to get this more compact look into the distro...;)





Comments


Eclipse The Memory Hog - resolved!

A couple of months back I made a blog entry about Eclipse and its memory settings. I wrote it because so many people complained that even when they put memory flags in their eclipse.ini Eclipse was still a memory hog and it crashed all the time. The entry blog explains how fragile eclipse.ini is and how to write it correctly and verify that it is picked up correctly.

That helped many, but suddenly I was starting to see more and more blogs, jira issues, forum postings, phone calls, personal assaults etc. about Eclipse memory usage sucking and our users started having memory issues with the latest builds and releases of JBoss Tools.

Why were so many seeing memory issues on a release that actually should use less memory than the previous one ?

As it turns out, on top of the issues with eclipse.ini from my previous entry, Eclipse 3.3.1 introduced a major bug in parsing the settings in eclipse.ini that resulted in PermGen memory settings not being set correctly on Sun Java VM's!

Result: Eclipse 3.3.1 runs "fine" at first, but as soon as you start having larger projects and/or using additonal plugins you are bound to get OutOfMemoryExceptions!

Thankfully eclipse.org is now in the process of doing a respin of Eclipse 3.3.1 and the first build is now available for testing.

So what do you do if you like your Eclipse 3.3.1 and don't want to try the build from above ?

You have a couple of options:

  • Use the *exact* settings described in my previous blog - they are not affected by the Eclipse 3.3.1 bug
  • Use Red Hat Developer Studio which automatically uses the settings described in my blog
  • Use another VM, only Sun's and Apple's VM requires the PermGen setting; IBM's and JRockIt JVM allocates PermGen space dynamically


















Comments


Who needs an iPhone anyway...

Get a decent phone $20
+ GMail Mobile $0
+ Google Calendar $0
+ GooSync $0 to $19.95
+ Opera Mini beta 4 $0


Result

The real web, e-mail and synchronized calendar on a mobile device without having to sell your soul to the Apple mania ;)

Especially GooSync and Opera Mini beta 4 is what makes this experience enjoyable!



What would make it perfect...

GooSync should add the option of syncing the description and comments, currently it is only the time, title and notification that is sync'ed. Opera Mini should include something like the "Wand" from it's big-brother Opera to fill in forms (which is a pain on a desktop, but horriable on any phone).

Comments


Todays favorite tool: svnmerge.py

I was about to have fun merging our two branches in rhdevstudio, the Eclipse 3.3 branch onto main trunk, when I remembered Emmanuel whining about the false promise of svn and all the issues he had. His issues were apparently partially because of his IDE but probably mainly because svn surprisingly does not keep track of merges by default.

Luckily I remembered noticing svnmerge.py the other day and tried using it today.

It is great and I don't need an PhD to use it (keeping The SVN Book near by is though still recommended :)

svnmerge init [theotherbranch + possible revision info] on the two branches you want to merge (if you did a svn copy initially the revision info is not needed)

svnmerge avail to see the revisions that are available for merges

svnmerge merge [piecemal revisions] to do the merge either piecemal or one big merge.

The wonderfull thing is that svnmerge uses svn properties to keep track on which revisions you have already applied and from where. Making the merge info easily available and future additional merges trivial.

Excellent!

note: the only thing i'm annoyed about with respect to svn is that the actual svn merge or svn diff seem to be extremely heavy operations - or at least very little informative about its progress even with the verbose flag ;(



Comments


Import/Export of Eclipse 3.2.x Working sets Hack!

For some reason Eclipse Working Set's definitions are not exportable from Eclipse (see Eclipse Bug #156041 and #138854.

We should fix that, but until then the following hack can be used to ease the pain of migration between two setups:

  1. Setup your new Eclipse and import all the projects you want to have in it
  2. Stop Eclipse
  3. cd [old-workspace]/.metadata cp workingsets.xml [new-workspace]/.metadata/.plugins/org.eclipse.ui.workbench
  4. Start Eclipse with a -clean argument


After this all the shared projects between old and the new eclipse that you had grouped into working sets will now also be grouped in the new eclipse.

That saved a couple of hours/days of my time, so here it is for you ;)

Comments


Hibernate/JBoss JIRA Quick search in Opera

Here is how you can do quick search in your JIRA directly from the browser url in Opera:

Go to Tools/Preferences/Search and add the following:

Name: Hibernate JIRA Keyword: h Address: http://opensource.atlassian.com/projects/hibernate/secure/QuickSearch.jspa Query String: searchString=%s Use POST: true



Name: JBoss JIRA Keyword: j Address: http://jira.jboss.com/jira/secure/QuickSearch.jspa Query String: searchString=%s Use POST: true

Now I can just enter "h hbx seam" to see hibernate jira issues for HBX that includes the word "seam"; and similar for JBoss but with a "j" as prefix.

If anyone can tell how I get the same functionallity in Firefox then it would be great (note: I know you can add custom searches to the firefox search field; what I'm asking for is the "enter string in URL line and get a custom search executed"-feature)

Update: Just saw this article which describes "Add Keyword for this search" popup menu in FireFox - same functionallity, but actually easier to configure (touche!)

Double update: Opera actually have a "Create search" popup menu too - I guess it's even functionality wise (but Opera had it first ;)

Comments