Using special characters in a linux sed command without having to escaping them
May 11th
I came across a brilliant little feature of the linux sed command today that I wasn’t aware of, and thought it was well worth posting up about.
I’d been using sed statements inside a bash script, to trawl through property files and replace values, these were all alphanumeric values so I didn’t have any problems with the usual sed comand of
sed -e s/replaceThisValue/withThisValue/g
That worked great, but then I had some properties introduced that contained special characters, notably the forward slash and equals. I scanned the interwebz for answers and there were all sorts of complicated techniques for escaping special characters, passing them into awk and all sorts of other such nonsense, however there is a much simpler way, just use a different separator character.
Asserting for a Toast message using Robolectric
Feb 18th
I’ve recently put together a few proof of concept applications, and since they’re “rough and ready” applications, a lot of the functionality is actually mocked, or given a stubbed implementation.
For example, I’ve got various buttons for things like “sign in with LinkedIn” or “Connect with Facebook”. Since its just a proof of concept, and those features aren’t really must haves, I stub them with a Toast message saying something along the lines of “feature not yet implemented”.
This gives the user the opinion that the buttons are there, functional, however the actions they take are not yet implemented.
A second app to launch; Agile Planning Poker
Feb 12th
After launching my first application onto the market back in March 2011, and amassing somewhere in the region of 15,000 downloads since it’s launch, I was eager to produce another.
I offered up my services at my work to develop an application to “test the water”, teaming up with the marketing director we created a simple yet useful application for agile project managers; planning poker decks.
How to add a splash screen to your android application in under 5 minutes
Jan 29th
Adding a splash screen to your application is a quick and easy way to make it look more well rounded, complete, and more professional, it can also serve as a useful distraction whereby you have an extra few seconds to initialise your application components before displaying them to the user.
In this post I’ll show you how to quickly and easily add a splash screen into your application, I’ll also show you how you can create an option whereby users may disable or enable the splash screen for subsequent launches of your application. I’ll also post up my sample code freely on Github so you can checkout what I’ve done and use as you please.
Converting dp to pixels in android
Jan 24th
Sometimes in android you have to deal with pixels, which can often be awkward, such as view.setPadding(int, int, int, int). Obviously this is not ideal as pixel ratings vary from device to device, nonetheless there is a work around for this
Simply come up with the value you want in dip (density independent pixels), such as 10, and then convert into pixels using the display metrics of the device you’re working on. This will ensure that when the conversion runs, it’ll always scale to the device the application is running on.
float sizeInDip = 10f; int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, sizeInDip, getResources().getDisplayMetrics());
Enjoy!
Top 10 Techie things I want to achieve in 2012
Dec 24th
I’m not the type of person that gets bored easily, I’ve always got many things to keep me amused, mostly side projects at home. I’m a firm believer, that if you don’t set yourself goals in the first place, then you won’t have anything to fail to achieve, so I’ve set myself a list of targets that I’d like to achieve in 2012 knowing full well I probably won’t get around to them all, but if I can do at least 3, it was worth it.
SMS text messaging simulation on android
Dec 24th
- The port the emulator runs on. To find this out, open up a command window and type :
adb devices
You should see something like this :
How to remove the default grey title bar on android apps
Dec 22nd
Fed up of the default title bar on your android applications?
We can get rid of that easy, either use the following in your activities to do it :
requestWindowFeature(Window.FEATURE_NO_TITLE);
Or, the way I prefer, disable it application wide by slipping the following into the AndroidManifest.xml file :
android:theme="@android:style/Theme.NoTitleBar"
Automating android application signing and zipaligning with maven
Sep 15th
This is something that has had me tearing my hair out for a few days now, I was pretty much border-line braveheart-ing my screen….
I’ve recently been on a little drive to try to maven-ize my projects. All had been going well until I needed to sign and zipalign my APKs. This post will help you conquer that barrier with the use of some maven plugins.
When using ant, I was able to simply enter keystore details into build.properties and just call “ant release”. Unfortunately that approach doesn’t carry across to maven, and you have to provide some more configuration.
String concatenation operator
Sep 7th
The string concatenation operator is a bit like a hedgehog, it looks cute and sweet, but try to grab hold of it quickly and you’ll soon know about it…

It’s actually quite simple, however there are some traps that are very easily overlooked (just got caught out with it on a mock test, so I’m here to rant).
The rule of thumb is, that if either one of the operands being “+” is a String, then concatenation will occur, but if they are both numbers, arithmetic addition will occur. Sounds simple right? What do you think the following equate to?







