My First Taste Of Success

I have written a lot of code. I have worked for several companies and written loads of code for them, but most times I am not even permitted to disclose what I was working on. I have a few projects that has seen some few interests, in sourceforge and on github, personal open source projects, but not at a scale I would really call successful.

I have also written a few web apps (faffies.com, unotifier.com, statusforsale, gridtext, jaara, webatter). Of all these I still support only the first two, the remaining I have either discontinued or have not put any work into them for over a year.

I have also written a few mobile apps, blackberry and j2me (expensetracker, faffies, king solomon’s mines, RimSMS etc). None of those ever see light of day, in terms of downloads. The only one I still support is expensetracker and I have not added any new feature in over a year.

For android, I have written a few also (ICE, JungleEscape, ChatRevolver). I never get to finish JungleEscape. But both ICE and ChatRevolver are still kind of active. Even at that, both combined did not even crossed the 100 downloads mark.

But my luck is about to turn. I have an app that has 35, 000 downloads in 4 months. Yes you read that right. And unlike faffies and the others, I have not paid a dime in advertisement!! How I did it??

First, my experience has shown me that Nigeria has a very high Blackberry user base, so I should put more effort in making the blackberry app if I am going to sell in the Nigerian market. So I made an app with local contents and put it on the blackberry app store. The first few weeks was boring, trickle of downloads per day, even zero on some days.

Next, I created a twitter account for the app. So that I can tweet @ the people I post their contents and hopefully I will get a retweet. Some of them have hundreds of thousands of followers.

Getting contents is hard, so I have foot soldiers. I pay them a token to help get the contents. At first I have 4 of them, but as we have loads and loads of contents, I let three of them go and I have only 1 for now.

Next I tried to forge a partnership with some of the content owners. So that they can retweet me and instead of me getting the contents myself, they can give me the contents themselves, before it gets to the public.

Next, I started attending events where I know my content providers will also be. It afford me time to meet so many of them and show them my app. I know it is something that has not been done before and immediately I show some of them, they were endeared to it.

By this time, we are 1 month since release and I have about 1K downloads already, that number is huge for me, and I celebrated it big. I even rewarded some of the people that downloaded with free airtime (I get some airtime for free every month in my workplace).

One day, I stumbled upon two facebook groups where people share their blackberry pins. I decided to get a new blackberry for the app, and use it to invite the people on that group and chat with them one on one, telling them about the app. I also send broadcasts once in a while. This is where things began to get interesting.

At first I sit by my computer and invite the people from that group one after the other. it was slow work and painful as hell. There’s no way to bulk invite people to your blackberry messenger. The only alternative is write a code that can do it. In under an hour, I wrote another BB app, I call it Invitator. It’s simple, give it a comma separated list of bb pins and it will send them an invite using your bb pin.

The next job is sit down and harvest the pins. It was easier than I thought and after a few days I have harvested over 1K pins. I chat with each and every one that accept the invite. It was a painstakingly boring job for a programmer. But I did it anyway. Within a month after I started this exercise, we had another 5K downloads.

All these while, I have not advertised on facebook or yahoo or google like I would have normally done. A lot of people even advised I do it, but I was head strong. I wanted to see what I can do without adverts. Because of the increase in downloads, reviews and comments and RFEs starting pouring in. I tried my best to implement some of the features people are requesting and downloads are soaring. I couldn’t do much because I have a day job and only have the nights and weekends to work on the app. People starting telling their friends about the new cool app.

And here we are, four months down the line, I have 35K downloads, and for the first time, I feel what having a successful app is like. It’s a feeling of joy, that people find pleasure in your work, and actually use it. On a daily basis now, we have over 5K calls to the server from within the app and about 500 downloads per day on a bad day.

I know you have been dying to know what the app is all about. It is called NaijaLyricsWiki. It is an app that provides a wiki like functionality for lyrics of Nigerian songs. You can also download the song you are viewing the lyrics, you can share lyrics on facebook or send to a friend. And finally you can get latest entertainment news and gists from the app. If you have a blackberry, you can download from the app store. If you use an android device, you can download from getjar.com. Either blackberry or Android, you can download directly from http://bit.ly/nlwmobile. The website is http://naijalyricswiki.org

Comments (6)

Simple Sorting Algorithms Implementations – Part 1

In the below, I will be presenting java source code of popular sorting algorithms. The problem with so many books I have read is that they don’t provide the simplest of solutions. I always consider myself an Hello World programmer. If I pick a new language, the first thing I look for is hello world, if I pick a concept, the first thing I look for is the simplest implementation, not the most optimized solution. NO. So when I look for implementations of algorithms, even if you are going to present me the most optimized algorithm, let me see the simplest, non-optimized implementation first.

When someone asked me why am I using for example, java.util.logging instead of log4j, I tell them, so far java.util.logging is working and I am yet to see a case I can not easily handle with it. So it is with these algorithms, let the reader/student see the simple solution and then present him with the problems with the simple solution, and then the optimized, more difficult to implement solution. If he likes, he can go with the simple implementation, when he finally discovered the problems with the simple implementation himself, it will be easier to understand the complex ones.

The programs below are very simple. Non of them have been optimized, they are meant to introduce to you these algorithms. You can take the code and optimize all you want. I also take care to use only simple data structures, no Lists, or Sets or any class in the collections package.

The below code are just segments of the full code. The important segments. The full source code is publicly hosted on Github

Finally if you want to read-up on these algorithms, please head to wikipedia
BUBBLE SORT

The algorithm below is based on the assumption that after every run through the array, the last element is already sorted.

So
for run1, the nth element is sorted,
for run2, the n-1th element is sorted,
for run3, the n-2th element is sorted, etc

	public void sortList(int n) {
		boolean swapped = true;
		while(swapped) {
			swapped = false;
			for(int i = 1; i < n; i++) {
				if (toSort[i] < toSort[i - 1]) {
					swap(i, i - 1);
					swapped = true;
				}
			}
			printArray();
			n = n -1;
		}
	}

INSERTION

	public void algorithm() {
		for(int i = 1; i < toSort.length; i++) {
			int key = toSort[i];
			int k = i - 1;
			while(k >= 0 && toSort[k] > key) {
				toSort[k + 1] = toSort[k];
				k--;
			}
			toSort[k + 1] = key;
		}
	}

SELECTION

	private void sortList(int startIndex) {
		int minIndex = findMinimum(startIndex);
		if(minIndex != startIndex) {
			//swap
			int temp = toSort[minIndex];
			toSort[minIndex] = toSort[startIndex];
			toSort[startIndex] = temp;
		}
		startIndex++;
		if(startIndex < toSort.length) {
			//recursively call sortList
			sortList(startIndex);
		}
	}

	public int findMinimum(int startIndex) {
		int min = toSort[startIndex];
		int minIndex = startIndex;

		for(int i = (startIndex + 1); i < toSort.length; i++) {
			if(min > toSort[i]) {
				min = toSort[i];
				minIndex = i;
			}
		}
		return minIndex;
	}

In the Part 2 of this post, I will show codes for MergeSort, QuickSort and HeapSort.

Source Code: Github

Comments (1)

Codename One Dynamic Ads Component

Codename One (CN1) really took off with a blast. Although still in beta, but loads of people are already using it for various apps, from banking to a mobile front for this. What is commendable is the ease with with you can build mobile apps that are truly cross platform without having to install tools for each platform.

If you are still wondering what CN1 is, please head to CN1 Website and read up about it for yourself.

I am going to be doing a series of tutorials or useful code snippets for CN1. Today we are looking at the ads component.

To use codename one ads, you need to register and have an account on inner active

Here are the steps to getting your ads on your CN1 app

  1. Create an account on inner active
  2. After login in, click the Add App tab and provide details for your app. The trick is to create different apps for different platforms so that inner active don’t go displaying a download app link on the appstore to blackberry users. You can also profile by age group and/or location.
  3. For every App you added like this, inner active will generate a unique key for you. Key this key.
  4. Now in your code, create an hash table that holds all the keys mapped to the specific platform and populate it. Then write a method as in below to add the ads component to the form.
    public static final Hashtable adKeys = new Hashtable();
    .............
    adKeys.put("rim", "[inner_active_rim_ad_key]);
    adKeys.put("and", "[inner_active_android_ad_key]");
    adKeys.put("me", "[inner_active_others_ad_key]]");
    ......................
    public static void showAds(Form f) {
        Ads ads = new Ads(adKeys.get(Display.getInstance().getPlatformName()).toString());
        if (!f.contains(ads)) {
            f.addComponent(BorderLayout.NORTH, ads);
        }
    }

Now for every page where I want to show the ad, I just call the above method and pass the form instance. Notice however that all my forms are BorderLayout and the North part is reserved for ads.

If you want to however use any type of layout other than border layout, you can use this code to add the ads component to the top of the page

Ads ads = new Ads(Helpers.adKeys.get(Display.getInstance().getPlatformName()).toString());
if (!f.contains(ads)) {
f.addComponent(0, ads);
}

That’s it, you now have Ads. You can visit your inneractive dashboard to see how your App is doing.

Comments (1)

CodenameOne: Another Java Promise Delivered

Back in 2001 when I started reading about this new programming language  called Java, I have only being a programmer for a few months and I see nothing serious about the mantra, “write once, run anywhere“. Don’t blame me, I have just learnt how to make a div jump using javascript and wrote a few arithmetic functions in pascal.

Fast forward to 2003, I have read about C/C++ and I have done more than my fare share of pascal, I never really got the hang of web programming, so I really suck at javascript then, but once again I started reading about Java and this time around something really caught my attention: The book I was reading said “Java can run on anything that has a memory and a microprocessor“. The author said,

soon your fridge will be able to determine when you are low on say milk and automatically make an order using you predefined credit card, soon, you TV will be able to send emails, soon, your credit card will be able to store more information that your account number, and these will be made possible by java.

Now those are pretty big claims to make in 2003, now? not anymore, even though your fridge can’t yet make orders, but the possibility is there and is not really something very difficult to do. But I digress, last week I was installing JRE for a client and Oracle said on the installer that Java runs on 2.5 billion devices! Great numbers right? but no, those numbers meant nothing to me if Java can’t run on iOS. iOS is the biggest mobile operating system out there and powers millions (if not billions) of devices and yet, Java can’t run on them. Those iOS devices are actually in every home right now (maybe not), but the point is Java could run on a gazillion devices, but they meant nothing if it isn’t running where it matters. One can argue that Java powers Android devices, yes, but that doesn’t dispute the fact that iOS devices are actually very important if you are an app developer.

Another place where Java is failing in it’s promises is the write once, run everywhere mantra, no it doesn’t work for mobile devices. There’s no way your can write once and run everywhere in mobile space, you write and write and write and hope and pray it runs on a few devices.

But all that is about to change. Enter Codename One. I don’t even know how to define what Codename One is, all I know is

  1. Now you can write once and run on every mobile platform.
  2. Your Java code can finally be made to run on iOS devices.

You can head to the Codename One Website to learn more about the goodies that it has to offer. I have successfully tested and seen a single code base running on Android (ICS), Blackberry (OS 4.2 and above) and Java ME feature phones (MIDP 2.0 and CLDC 1.0 and above). I didn’t have to make any changes to the codebase, and believe me the UI looks pretty cool.

Development is also easy, all you need is Netbeans. It comes with a GUI builder and a Simulator. One thing you will notice again is that the Simulator is fast. Very fast! Have you tried to develop for Android and Blackberry? Then you will notice that the Codename One Simulator is order of magnitude fast.

If you’ve been following the mobile app development space for a while, you would have heard of LWUIT, Codename One is built on LWUIT but is far more than that, the GUI Builder generates one of the most efficient code I have seen a GUI Builder generate. It throws away most of the fluff GUI Builders add to your code. It also builds your GUI as a state machine, such that you can think of your application as a series of states.

I can go on and on.

Codename One is currently in private beta and I believe beta is not far out (I am not speaking on behalf of the developers, but based on my perceived success of the private beta). I recommend you give it a try, you’ll be amazed.

Below are some sample screen shots from the application I built using Codename One private beta

twitpic.com/8nc5if yfrog.com/kio3ivp yfrog.com/oessyqp yfrog.com/kjm7rgp

And here is a live application

J2ME and RIM: http://www.getjar.com/mwc12

Android: https://market.android.com/details?id=com.israelmobilesummit.mwcevents&feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5pc3JhZWxtb2JpbGVzdW1taXQubXdjZXZlbnRzIl0.

iOS: http://itunes.apple.com/us/app/mobile-world-congress-events/id497801040?ls=1&mt=8

Comments (1)

2011 in review

The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog.

Here’s an excerpt:

The concert hall at the Syndey Opera House holds 2,700 people. This blog was viewed about 14,000 times in 2011. If it were a concert at Sydney Opera House, it would take about 5 sold-out performances for that many people to see it.

Click here to see the complete report.

Comments (1)

Book Review: Java the Complete Reference, 8th Edition

Java, the Complete Reference, 8th Edition has been updated according to changes in Java 7. For those not willing to read the whole review, I will say my conclusion is, be you a beginner or an expert Java developer, you need to read this book.

This book is an in-depth guide to the Java language. A very large portion of the core Java APIs are discussed comprehensively. The book has four parts, plus appendix and index.

PART 1: The Java Language

This part has 14 chapters and comprises discussions ranging from the simplest to the fairly complex. It starts with a history of Java and ends with a discussion on Generics, touching topics like Annotations, IO, Threading and Exceptions along the way. I particularly like the part that talks about C programming language, extolling the virtues of the language. Of course no Java book is complete without talking about OOP (Object oriented Programming) and chapter 2 of part 1 did justice to this. One good thing for beginners is that you start writing code straight from chapter 2. If you are an experienced programmer, you can safely skip to chapter 10. Although I recommend reading everything.

Chapter 1: The Introduction and Evolution of Java

Chapter: 2: An Overview of Java

Chapter: 3: Data Types, Variables and Arrays

Chapter: 4: Operators

Chapter: 5: Control Statements

Chapter: 6: Introducing Classes

Chapter: 7: A closer look at methods and classes

Chapter: 8: Inheritance

Chapter: 9: Packages and Interfaces

Chapter: 10: Exception Handling

Chapter: 11: Multithreaded Programming

Chapter 12: Enumerations, Autoboxing, and Annotations (metadata)

Chapter 13: I/O, Applets and Other topics

Chapter 14: Generics

 

PART 2: The Java Library

This part also has 14 chapters, taking the chapters count to 28. Here the book discusses the core Java Library; which includes Strings, NIO, Networking, java.util package, AWT, concurrency and Regular Expressions. This is the chapter for you if you are an experienced developer. Here, the book discusses the new Java 7 Features and more. I’ll advice beginners to read the Part 1 at least twice before diving into Part 2.

Chapter 15: String Handling

Chapter: 16: Exploring java.lang

Chapter: 17: java.util Part 1: The collections framework

Chapter: 18: java.util Part 2: More Utility Classes

Chapter: 19: Input/Output: Exploring java.io

Chapter: 20: Exploring NIO

Chapter: 21: Networking

Chapter: 22: The Applet Class

Chapter: 23: Event Handling

Chapter: 24: Introducing the AWT: Working with Windows, Graphics and Text

Chapter: 25: Using AWT Controls: Layout Managers and Menus

Chapter 26: Images

Chapter 27: The Concurrent Utilities

Chapter 28: Regular Expressions and Other Packages

 

PART 3:  Software Development Using Java

This part discusses some really very import ant Java concepts. It contains just 4 fully packed chapters, recommended for both beginners and experts alike

Chapter 29: Java Beans

Chapter 30: Introducing Swing

Chapter 31: Exploring Swing

Chapter 32: Servlets

 

PART 4: Applying Java

In this part, we have two chapters. Each chapter picks a real world Java application. describes and implemented it. A note to beginners here, because of the volume of code you will be required to type, you might want to do copy-and-paste, but I strongly recommended against that. Doing the typing will definitely help you in more ways than one. This chapter concludes this book, bringing the number of chapters to 34.

Chapter 33: Financial Applets and Servlets

Chapter 34: Creating a download manager in Java

 

Appendix and Index.

In the appendix, javadoc is discussed. I particularly like and recommend this part to all. Documenting code is very important and should be embraced by all.

 

In summary, this is a good book, read it, study it, use it as a reference, whatever you decided to do with this book, you will find out it is more than equal to the task.

Great thanks to Faltermeier Bettina for providing me the preview copy.

Comments (1)

Defying the Odds: Setting up Oracle NoSQL DB on MAC, using VMs for replication


I have a Macbook Pro, 2010 Model with 8GB of RAM. While reading the Admin Guide for the Oracle BigData release, it says that only linux and Solaris OSes are supported for now. I hissed and went ahead anyway. Next It said I shouldn’t setup multiple nodes using a Virtual Machine, another hiss.

The reason why I hissed was I was pissed, why Linux and Solaris, and now I couldn’t use VM? I went back to the Guide to see why, but the reasons given wasn’t convincing, so I went ahead and started the deployment on my mac. My disobedience paid off, not only did it work on a Mac, I was able to setup other Nodes using VM running on the same Box.

I have two VMs running headless. The type of Networking is Bridged. I have a wireless router that also has ethernet port, I hooked my Mac up on both the wireless and the LAN. I use the LAN for the Brigded networking on the VMs and the WIFI for my MAC.

This is all the setup you will need. Note that of you have read the Admin guide, you will see things like node1, node2 etc used to name the systems on which the different instances of the NoSQL DB is running, to avoid having to go into naming and hosts file and that, we will just use the IP addresses, they also work.

I am going to assume that my MAC ip address is 192.168.1.4, and the VMs are 192.168.1.5 and 192.168.1.6 respectively.

After installing the NoSQL DB on all three machines (My MAC and the two VMs.), I run the below commands in the same directory as where the NoSQL DB is installed.

mkdir Data
./bin/kvctl makebootconfig -root Data -port 5000 -admin 5001 -host 192.168.1.[4,5 or 6] -harange 5010,5020
./bin/kvctl start -host 192.168.1.[4,5 or 6] -root Data

The above will create a config in /Data and start the NoSQL DB.

Next, you need to run the below command on 192.168.1.4 only

./bin/kvctl runadmin -port 5000 -host 192.168.1.4 -script script.plan.txt

The content of script.plan.txt is

configure mystore
plan -execute -name "Deploy Boston DC" deploy-datacenter "Boston" "Savvis"
plan -execute -name "Deploy Node1" deploy-sn 1 192.168.1.4 5000
plan -execute -name "Deploy Admin" deploy-admin 1 5001
addpool BostonPool
joinpool BostonPool 1
plan -execute -name "Deploy Node2" deploy-sn 1 192.168.1.5 5000
joinpool BostonPool 2
plan -execute -name "Deploy Node3" deploy-sn 1 192.168.1.6 5000
joinpool BostonPool 3
plan -execute -name "Deploy the Store" deploy-store BostonPool 3 300
quit

If all went well, visit 192.168.1.4:5001 from you browser and click on topology.

For a description of the commands in the script.plan.txt see the Adming Guide.

Leave a Comment

Older Posts »
Follow

Get every new post delivered to your Inbox.

Join 194 other followers