Converting M4B to MP3

Wanted to convert a M4B file to MP3 last week. When searching Google on how to do this it came up with loads of (commercial) conversion programs. Somehow I didn’t feel like installing any of the suggestions, and many ran on Windows while I’m using Ubuntu.

After a while I found a program available in Ubuntu which does the trick easy and simple, the only annoying part is installing the encoders… just follow the instructions below.

Open ‘Ubuntu Software Center’, search for ‘sound converter’ and install it.

Sound Converter in Ubuntu Software Center

Sound Converter

After installation it can be found at ‘Applications -> Sound & Video -> Sound Converter’. Start it and click ‘edit -> preferences’. If you see the following message then press ‘Read how to install’.

MP3 encoder not installed message

MP3 encoder not installed

GStreamer

GStreamer

After clicking ‘click here’ click ‘ok’, click ‘install’ and enter your admin password. Restart ‘Sound Converter’ and open the preference screen once again, select ‘MP3′ as ‘format’ in ‘Type of result’.

Press ‘Add file’ and select your M4B file. If you don’t have the right codecs to play M4B files yet, the program will prompt to install those. For me it said the installed codecs were not the right ones… it didn’t stop the process of converting the file to MP3 though, so if you get a warning (after installing the suggested codecs) just try to continue. It will require a restart of ‘Sound Converter’ once again.

Finally, ready for converting… press ‘Convert’ and wait till the proces is done.

Converting M4B to MP3

Converting M4B to MP3

Posted in Linux, Ubuntu | Tagged , , , , , | Leave a comment

The Mythical Man-Month

Book cover During my holiday I read “The Mythical Man-Month: Essays on Software Engineering” by Frederick Brooks.

Published in 1975 it might sound outdated for a IT book. It’s not, mainly because it’s focused on software engineering and project management, not programming. Reviews and summaries can be found anywhere, instead of that I’ll quote some recognizable parts.

When one hears of disastrous schedule slippage in a project, he imagines that a series of major calamities must have befallen it. Usually, however, the disaster is due to termites, not tornadoes; and the schedule has slipped imperceptibly but inexorably. Indeed, major calamities are easier to handle; one responds with major force, radical reorganization, the invention of new approaches. The whole team rises to the occasion.
But the day-by-day slippage is harder to recognize, harder to prevent, harder to make up. Yesterday a key man was sick, and a meeting couldn’t be held. [..] Snow, family problems, emergency meetings with customers, executive audits – the list goes on and on. Each one only postpones some activity by a half-day or a day. And the schedule slips, one day at a time. (Brooks, 1975)

First, my wife, my colleagues, and my editors find me to err far more often in optimism than in pessimism. I am, after all, a programmer by background, and optimism is an occupational disease of our craft. (Brooks, 1975)

Posted in Books | 1 Comment

Variable scope in ActionScript Flex

Hoisting, the strangest ActionScript/Flex “feature” I’ve ever seen (at the moment of writing). Probably you’ve never heard of hoisting. I was hinted to this feature when I had two variables with the same name in one function. Flex was warning about this, but I didn’t really understand why.

Check the following example:

private function existsInSources(searchFor:String):Boolean {
	if(searchFor.length > 10) {
		for each(var valueObj:Object in longStringsCollection) {
			if(valueObj.key == searchFor) {
				return true;
			}
		}
	} else {
		for each(var valueObj:Object in shortStringsCollection) {
			if(valueObj.key == searchFor) {
				return true;
			}
		}
	}
	return false;
}

By default Flex will give the following warning at the second declaration of valueObj, line 9:

3596: Duplicate variable definition.

Coming from other program languages this will (should) strike you as odd behaviour. Both variables ‘valueObj’ exist in their own scope… right?
Not in ActionScript, ActionScript has “Hoisting”.
From adobe.com:

An interesting implication of the lack of block-level scope is that you can read or write to a variable before it is declared, as long as it is declared before the function ends. This is because of a technique called hoisting, which means that the compiler moves all variable declarations to the top of the function.

So basically, the code from the example is transformed to:

private function existsInSources(searchFor:String):Boolean {
	var valueObj:Object;
	var valueObj:Object;
	if(searchFor.length > 10) {
		for each(valueObj in longStringsCollection) {
			if(valueObj.key == searchFor) {
				return true;
			}
		}
	} else {
		for each(valueObj in shortStringsCollection) {
			if(valueObj.key == searchFor) {
				return true;
			}
		}
	}
	return false;
}

“It just shows a warning and doesn’t have any impact on that beautiful piece of code you wrote there, so who gives a ….”.

The problem lies in the fact that this “feature” also means you can refer to objects before they are even initialized.

if(myString.length > 20) {
	trace('Length is over 20!');
} else {
	trace('Length is 20 or smaller');
}
var myString:String = "Hello world!";

Result: a runtime error.

Cannot access a property or method of a null object reference.

Flex compiles (yes, this code compiles fine…) this to:

var myString:String;
if(myString.length > 10) {
	trace('Length is over 10!');
} else {
	trace('Length is 10 or smaller');
}
myString = "Hello world!";

Pay attention to your variable scope, especially when using Flex/ActionScript.

Posted in Coding, Flex | Leave a comment