Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X
Post

Lost password for Android keystore

Today I found myself banging my head on the desk out of frustration for forgetting the password to the KeyStore I use for my Android apps. This is a big deal, because if you cannot sign your application with the same keystore you used previously, your app becomes “orphaned” on the Android Play Store. The store will not allow you to upload your app as an updated version and neither will it allow you to take off and re-upload the existing APK. The only way around losing your keystore or the password to it, is to upload your app under a new name – thereby losing your existing user base and statistics.

Luckily, if you’ve only lost the password to your keystore, you can try brute-force crack it, which is what I did. I found this nifty JAR (see below) that attempts to brute-force the password to the keystore. The nice thing is it has a mode called “Smart Wordlist Attack“, which allows you to supply a dictionary file that contains likely passwords as an argument. This speeds up the program immensely if you have a list of passwords you use often. It takes this list and goes through all permutations of each password, as well as a variety of other techniques such as uppercase, appending numbers etc.. You can also supply the `-p` flag, which tells the program to try replace letters in your password with common symbol and numeric representations e.g. ‘@’ instead of  ’a’.

So, if you find yourself without your keystore password, give the android-keystore-password-recover a try.

Post

Slow multi-dimensional array iterations

I came across some strange times when benchmarking my code. Essentially, my iteration through a large 2D array was excessively slow, so I looked around and it turns out my problem was that I was changing the shallower index more often than the deeper index. See the following test results of iterating through 100 million array elements:

int[][] tmpGrid = new int[10000][10000];

for(int i = 0; i < 10000; i++){
	for(int j = 0; j < 10000; j++){
		tmpGrid[j][i] = 0;
	}
}
----------
Took 2031.414ms

as opposed to

for(int i = 0; i < 10000; i++){
	for(int j = 0; j < 10000; j++){
		tmpGrid[i][j] = 0;
	}
}
----------
Took 46.376ms

Notice the massive difference the swapping of the variables on the assignment statement make? After some looking around, I found this reason from Stackoverflow:

Because you have decreased cache coherence. The fastest-changing indices should be the last ones, so that most memory accesses occur next to each other, within the same cache blocks, instead of forcing your processor to wait until the blocks are read from the main RAM.

It seems so logical, but its not really something you think about whilst writing code or is rarely of much consequence for the average array, but for large data sets it can shave a couple of seconds off your program.

Aside

Increasing the Eclipse console’s output length

By default, Eclipse limits the number of characters in the console’s output buffer. This can be a pain if you require the output of large volumes of data. Fortunately, it’s easy to change:

Window -> Preferences -> Run/Debug -> Console -> Limit Console Output

Here you can either adjust the output limit, or remove it entirely.

Post

Gretel: breadcrumbs for Rails

Breadcrumb navigations are becomming increasing popular, especially on websites. Wikipedia defines breadcrumbs as:

Breadcrumbs typically appear horizontally across the top of a web page, often below title bars or headers. They provide links back to each previous page the user navigated through to get to the current page or—in hierarchical site structures—the parent pages of the current one. Breadcrumbs provide a trail for the user to follow back to the starting or entry point.

I’ve often wanted to add breadcrumbs to sites I work on, but they can be quite a pain in the ass to implement properly or you have more important things to get done.  Recently I stumbled breadcrumb Gem for Rails called Gretel and it has really impressed me. It is simple to configure and implement, without having to add tons of ugly code to your controllers. Drop in and add some rules to your breadcrumb.rb initializer file and one line per view (optionally placed in the view itself, or its controller method) and you’re done!

More…

Post

Rails vs Grails

Groovy on GrailsI’ve been at Quirk now for almost 3 of my 6 week internship and I must say, it has been thrilling thus far! Over at Quirk, they’ve been in the process of transitioning from a previous Java web framework to Groovy on Grails for the past few months. From what I’ve gathered, the main justification for moving to Grails specifically was for the support of legacy client code and the slightly smaller learning curve, since Grails is anyway based on the Java platform. So naturally, we (the interns) have had to pick up ‘em handy tutorial books and get cracking on learning Grails.

The process of learning Grails, personally, wasn’t as big of a task as I initially thought it would be. Being largely fluent in Ruby on Rails, the standard MVC design pattern was familiar, aside from a few syntax and terminology differences such as a model in Rails is called a domain in Grails. Lol – DVC anyone? Other than that, the only other learning curve would be Grail’s syntactically ugly taglibs – that is, the logic tags used from within the views – my main irk being that fact that the syntax – for example an if or loop statement – is different in the view than in the controllers or domains. A few standards would really be nice.

Anyway, enough bitching! I thought it would be a good exercise to (somewhat) objectively compare Rails vs Grails, so hoist ye anchors ‘n drop ye sails! Please note, I purposely did not go into any code-testing capabilities.

More…

Post

Sudoku solving

SudokuWith exams coming to an end, I have found myself working on a few small projects that have absolutely no purpose other than to keep myself occupied. My latest distraction comes in the form of a Sudoku puzzle solver (I blame Steven). We first tackled a rather trivial version of this problem in first year CSC1005F(?) using Python 3. To be honest, it was (and somewhat remains) probably one of the most useful, or rather, practical programs we’ve had to create for an assignment.

Anyway, I’ve decided to expand upon the original project – more than a year down the line. To start, I’m taking an OOP approach (for shits-and-giggles really) to make things a little different and I’m working on some more advanced techniques for solving it. By advanced, I mean more than just recursively eliminating obvious cell possibilities, called the “naked single” method. I’m also trying to speed it up somewhat and will be coding it up in my ever-favourite Ruby.

For anyone interested, I’ve created a public repo on Github, available at https://github.com/Supy/sudoku-solver. Its really raw and messy. You’ve been warned.

I’ve actually learned quite a few new usages for various methods in Ruby, especially dealing with arrays. So even in the likely event that I get bored and move on to another distraction, it wouldn’t have all been a waste of time!

Post

Mobile development with Phonegap

Phonegap
Phonegap

Ben and I recently decided to have a crack at an application idea that would greatly benefit from being able to run on Blackberry’s, whilst neither of us own one. Enter Phonegap, a multi-platform development ‘library’ that converts your application written in HTML5, CSS and Javascript to the various mobile platforms such as Android, iOS, Blackberry etc. While this sounds like a developer’s dream, my experience with it suggests otherwise. Having a fairly strong programming background, learning a new language (new in this context meaning a bit of experience) isn’t all that difficult, since the constructs are the same across the board. Learning a new language whilst having NO syntax highlighter or error reporting on the other hand, is an absolute nightmare. So much so that I’ll probably save time writing the application over for each platform.

More…

Post

Graph Theory

Having gone over some graph theory notes from lectures, I realised there was actually more to it than what I had first initially assumed when we were sitting in the actual lecture. Mind you, we were busy trying to find the equilibrium point of a bottle containing a few drops of water on a slanted desk while this particular topic was being covered. Who can blame me, right?

Anyway, it came down to the grind this evening and I cleared up quite and researched a few pointers on basic graph theory that I will probably need soon and would have most likely forgotten about by then. More…