SOPA – so far, so crap

There’s a very good mashable on this SOPA/PIPA in which a fellow programmer managed to unravel the spaghetti loops behind the meaning of SOPA.

As a fellow protestor, and showing my support, I have tweaked this site to show the message to stop the craziness by hapless fools who put together a string of meaningless rubbish and legalese in this upcoming act.

Post to Twitter

Sad passing of Dennis Ritchie

Saw a tweet earlier on today and it caught my eye.

Then learnt that the creator of the C programming language and also Unix, passed away over this weekend.

RIP Dennis Ritchie.

On a more serious note, need to get this off my chest, and no dis-respect either in this regard to Apple’s Steve Jobs who also passed away last week, but…and this is what I find absolutely gob-smacked about, very little was mentioned of Dennis Ritchie (dmr). The twitter-sphere has been going on about Steve Jobs for the last week or so. The cruel twists of fate has been made… when you read on and realize…

But what the twitterers fail to grasp the concept and realization, there would have been no C language nor Unix for that matter, no applications/games that was possible in the 1980′s and 1990′s either, and no operating systems either.

When you think about it for a moment, the influx of different designs of operating systems was programmed in C, combined with assembler programming language.

Nor would the advancements  in chip design have been achieved, which is a catch-22 in this regard, some kind of a package to be able to program the logic flow of chips etc. Hell, even, there would be no mobiles/smartphones, no Android, no Apple OS….

Even in the telecommunications sector, without C, there would have been no improvements somewhat in the arena of phone switching etc, nor even a operating system to run, in the sense of to manage the telecommunications infrastructure either.

There would have been no internet (TCP/IP protocols which was formed on the backbone of the C programming language), or even would DARPA have existed only for that once when the gates to the internet world was opened up? What about web pages, blogs, Twitter, Facebook, the things that we take for granted now today in this electronic age where communication is even more emphasized.

And it was not Steve Jobs that is a legend either, for that matter, sure he pushed and raised the bar for Apple has become of today. No dis-respect to him either, without him, certainly, smartphones would not have been made possible in terms of features and raising of the bar for standards across the board.

The real legend was the quiet man who hacked away and coined the biggest revolution in his hands alongside with Brian Kernighan that totally changed the IT world forever.

You may object and say hang on… but I digress, sure it sounds a little one sided, but have you not thought of what the world would be like today without the Unix, C today.

What would have become if dmr did not pioneer  C, or Unix. What would the IT landscape be like without it, would Apple have existed, would Microsoft have existed, internet, tcp/ip protocols, Windows, you name it…

So for all people out there, I ask you to re-tweet a simple tweet of your liking to salute dmr for he totally changed and revolutionized the IT landscape right back in the late  1960′s/early 1970′s.

From me, who was a self-taught C programmer, and Linux fanatic, I salute you dmr, you’re the real legend!

Post to Twitter

Windows-free zone!

Ha! Been wanting to say this for a while!

I am now a Windows free zone – no Windows systems lying around. :D

Goodbye Windows

Goodbye Slackware – yes, I know, I know, was a long time fan of Slackware ever since I  acquired Walnut Creek CDROM set with kernel 1.2.13 .. :)

And now I welcome in open arms….(drum roll please)

Arch Linux (Ba-dum-tish!)

Well, what can I say, its a rolling release distro… put simply, updates come out and all dependencies taken care of :D The simple chant of the command sudo pacman -Syyu and pulls down the latest updates from the Arch Linux’s repository. Now, I have currently a testing repository selected – heh, I like to be on the bleeding edge, and so far, extremely impressive and fast!

Now for you winblows (l)users xD try shutting down and reboot back, time it, now, there’s a catch with this challenge – no SSD disks please.

Personally, I can go from Gnome 3.2 desktop to reboot and back again in under 1 minute. There’s no delay, its instant boot up – well, a lot faster than winblows that’s for sure :)

Yes, Gnome 3.2… Its actually quite a neat GUI system, sure there are rough edges that need smoothing out but its way better than Gnome 3.0, which caused ire among the Linux users… Will blog about that later on :)

And you know something, it feels good to have a non-windows system running as there’s no associated stress and frustration with applications freezing or locking up due to bloated registry size and flaky drivers.

Everything works as it is out of the box with Arch.

Post to Twitter

APK + Code Signing

Recently, during a project, that involved code signing and custom deployment/updating the apk, I discovered that if an apk is debug-signed and gets downloaded, the installer will not update the apk, in fact, it will refuse to work with an installation error!

That was a rather simple error but to show that it is often overlooked from Google’s pages on the code signing, and going on a wild-goose chase wondering why the installer refuses to install. This article is just to serve a quick tip and short reminder! :)

There was a lesson to be learnt from it – if an apk needs to be distributed/published and has a custom deploy outside of the market, make sure it is release-signed before custom deployment, otherwise, frustration will step in and customers will not have the latest version. :)

Post to Twitter

Setting up your own GitHub

This article is about how to set up your own private github repository on Linux, in a few easy steps. I have tried a few packages that I personally, found, convoluted and complicated. Sometimes the simplest way is the best way. A few pre-requisites here needed:

  • A user id that has been created by root, make sure that the said user id does not have a login shell, in this case, call it gituser (This should create /home/gituser!)
  • A group id that, also, has been created by root, in this case, called it git. (The above two are for reasons of security to prevent exploits etc, should the Linux box be ever compromised)
  • That there is the latest git binaries or compile from source which can be found here from the main git site. And that it is installed, the installation path will vary depending on your Linux Distribution.
  • There is a super-internet daemon running, xinetd.
  • Optional: Open the port on your firewall, 9418 for the git protocol.

Now, root access is needed for the most part to get this set up and running.

The pre-requisites out of the way, let’s go ahead and create the github server.

  1. All the source code changes will be tracked and stored inside the /home/git/scm directory so create the directory. And this will be referenced by the super-internet daemon configuration.
  2. So. inside that directory /home/git/scm, create a directory for each git repo that you want to set up, for example, Kernels and inside that directory you would have different kernel versions, ending in .git. E.g. /home/git/scm/Kernels/2.6.32.9.git This will be perceived via way of git protocol as this: git://localhost/Kernels/2.6.32.9.git (See the tip below if you wish to make this accessible outside of the localhost address)
  3. Taking the above example, that the directory is created, issue the following command:
    1. git –bare init
    2. touch git-daemon-export-ok
  4. Now, still being as root, change the owner-ship of all of the directories/files within the /home/git/scm directory (chgrp -R git:gituser *).
  5. Edit the super-internet daemon configuration, found usually in /etc/xinetd.conf like this:

service git{

disable=no

type=UNLISTED

port=9418

socket_type=stream

wait=no

user=git

server=/usr/lib/git-core/git-daemon

server_args= --inetd --export-all --reuse-addr --enable=receieve-pack --base=/home/git/scm

log_on_failure += USERID

}

Now, restart the super-internet daemon and all should be okie. That’s the server side done and ready to accept files.

As a tip, instead of confining the github repository to be at just localhost, set it to the IP address of the actual linux box that you are hosting the repo at, for example, 192.168.10.1.

As an ordinary user, and have a need to check in the files into your private github, do the following:

  1. git init # This initializes the current directory to be used for git-tracking.
  2. git add * # This tells git to accept a list of files that needs to be tracked.
  3. git commit -a -m “Initial comment and initial version” # Tell git to store the commit message that is related to the the list of files added.
  4. git remote add origin git://localhost/Kernels/2.6.32.9.git # Tell git that we’re using the server side address that will be the centralized point of tracking changes. This is only done once!
  5. git push origin master # Tell git to push the list of tracked files and changes across to the server. Again, do this once, as it will be stored in the configuration within the directory and will remember next time, i.e. git pull, git push, git log, git status, etc.

Now, your own private github repository is working.

Repeat the steps for each repository/directory that you want tracked by git.

Happy Git’ting :)

Post to Twitter

Windows free Zone!

Ha! Been wanting to say this for a while!

I am now a Windows free zone – no Windows systems lying around. :D

Goodbye Windows

Goodbye Slackware

And now I welcome in open arms….(drum roll please)

Arch Linux (Ba-dum-tish!)

Will blog about that shortly :)

Stay tuned!!

Post to Twitter

Android + using System Settings intents

A big gotcha I discovered, suppose you want to fire an intent to bring up a System Settings screen like this


final settingIntent = new Intent(Settings.xxxx);

final int INTENT_SETTING_ACTIVITY = 1;

startActivityForResult(settingIntent, INTENT_SETTING_ACTIVITY);

And accordingly to the SDK, there’s a return code used to check the status of the Settings activity, which looks like this in the call-back code:


@Override

protected void onActivityResult(int requestCode, int resultCode, Intent data){

super.onActivityResult(requestCode, resultCode, data);

if (requestCode == INTENT_SETTING_ACTIVITY) {

if (resultCode == RESULT_OK) {

// Handle the good condition

}else{

// Handle the bad condition

}

}

}

Watch out!

That condition will fail – for some obscure reason the logic fails.

You can make it succeed by replacing the ‘RESULT_OK’ with a 0 and all should be okie. :)

Post to Twitter

A insight into a Android Game Developer

This is by far the best blog posting I’ve ever read and the author explains a lot when it comes to producing a Android game called “Theseus and Minotaur”, from concept to production and the challenges along the way, such as using AdSense to market it, using Illustrator to polish up graphics, and a few nice tips also.

The story spans a year coverage from start to finish and documented along the way… There’s a lot of insight into it and a worthy blog post to keep coming back to.

Please do read it and let him know you appreciate his blog posting.

(The url has been bit.ly’ified, the real url is http://kerebus.com/2011/03/my-year-as-an-amateur-android-game-developer/?android)

Post to Twitter

Updated code for ZTE Blade FM Radio + CM7

Hello again, I have updated the code on github to make it a daemon server that will handle the simple and intuitive command set to control the FM Radio. As from the previous blog posting, the code has been revamped. I have discovered a thing or two about the Android NDK that made be go “WTF”…

Read more »

Post to Twitter

ZTE Blade and CM7 missing feature

Cyanogenmod ROM 7 is currently undergoing testing and receiving huge feedback, currently for the Orange’s San Francisco/ZTE Blade, there’s still a lot to be ironed out, one of the notable features inherently missing is the usage of the FM Radio.

Read more »

Post to Twitter

Compiling kernel for Android – Part II

Ok, to keep to the topic as per in the previous posting about how to compile the kernel for Android, I thought I’d share some scripts that I use myself to make life a bit easier….

  • ak_stg1 – (Android Kernel, Stage 1), takes in parameters to create a boot.img.
  • ak_stg2 – (Android Kernel, Stage 2), again, takes in parameters, copies the modules across to a specified directory.
  • ak_stg3 – (Android Kernel, Stage 3), to create a clockworkmod updater script – work in progress…. :D

ak_stg1 bash script.


#!/bin/sh

usage(){

cat << EOF

usage: $0 options

This script creates a kernel boot image for flashing with ClockworkMod 3.0.0.x [Stage 1]

OPTIONS:

-h      Show this message

-k       Location of recently compiled zImage

-r       Location of ramdisk

EOF

}

invoke_mkbootimg(){

echo "$@" | awk '{ system($0); }'

}

KERNEL_ZIMAGE=""

RAMDISK_IMAGE=""

RESERVED_STMT="androidboot.hardware=blade console=ttyMSM2,115200 g_android.product_id=0x1354"

BASE_ADDR=0x2A00000

BOOTIMGF=boot.img

while getopts "hk:r:" OPTION

do

case $OPTION in

h)

usage

exit 1;;

k)

KERNEL_ZIMAGE=$OPTARG

;;

r)

RAMDISK_IMAGE=$OPTARG

;;

?)

usage

exit 1

;;

esac

done

if [[ -z $KERNEL_ZIMAGE ]] || [[ -z $RAMDISK_IMAGE ]]

then

usage

exit 1

fi

BOOTMAKE="$HOME/bin/mkbootimg"

BOOTMAKE_OPTS="  --base $BASE_ADDR --cmdline "\'"$RESERVED_STMT"\'" --kernel $KERNEL_ZIMAGE --ramdisk $RAMDISK_IMAGE --output $BOOTIMGF"

invoke_mkbootimg $BOOTMAKE  $BOOTMAKE_OPTS

ak_stg2 bash script.


#!/bin/sh

usage(){

cat << EOF

usage: $0 options

This script copies the freshly built kernel modules for flashing with ClockworkMod 3.0.0.x [Stage 2]

OPTIONS:

-h      Show this message

-k       Location of recently compiled kernel source

-m      Location of where to copy the modules to

EOF

}

KERNEL_PATH=""

MODULES_PATH=""

while getopts "hk:m:" OPTION

do

case $OPTION in

h)

usage

exit 1;;

k)

KERNEL_PATH=$OPTARG

;;

m)

MODULES_PATH=$OPTARG

;;

?)

usage

exit 1

;;

esac

done

if [[ -z $KERNEL_PATH ]] || [[ -z $MODULES_PATH ]]

then

usage

exit 1

fi

cat $KERNEL_PATH/modules.order | sed s/^kernel\//g | while read -r line

do

cp $KERNEL_PATH$line $MODULES_PATH

done

 

Now, no fuss, no muss, and less prone to errors on the command line. w00t. \o/

Post to Twitter

USB Charge Commander

I promised the forum members over at Modaco, to develop a simple application designed for the ZTE Blade/Orange San Francisco handset. As the title of this blog post, it is exactly that.

A bit of background – I am constantly plugging in the cable into the handset for at most 2 minutes max, just to copy files on it, worrying about the battery getting messed up or shortening the battery life. I set about to pursue an alternative to allow plugging in the cable without charging the battery.

This is the application that is the simplest Android application, which selectively enables/disables the battery charging. It is now available on github repository for anyone to download and tinker with the code. :)

The binaries are available to install directly on to the handset.

Warning: Do not run this on any other handset!!!

Post to Twitter

Compiling kernel for Android

Here are the steps required to build your own kernel for your Android handset. All commands are italicized and precedes the $HOME variable to indicate the directory.

Prerequisites:

  • Linux box up and running that contains the full developers tool-kit such as bison, flex, automake, bash, gcc, git, curl, kernel sources of your choice, adb. Your mileage will vary in accordance to different Linux distributions of your choice so refer to your package manager if you do not have the above developer tools. I am using Slackware 13.0 distribution.
  • A Android based handset, in my case, its Orange’s San Francisco/ZTE Blade, running Modaco Custom ROM 11, and also, that you are using a ROM Manager, in my case, I use Clockwork Mod recovery.
  • Tools to extract the kernel from your android’s boot image, namely, split_bootimage.pl which can be found here.
  • Java – You will need Java 1.5 runtime and sdk, if you ever want to build a Android release from the Android Open Source (AOS), crucially, 1.5 is required for releases up to Froyo (Eclair, Donut, Cupcake releases), Gingerbread and upwards requires Java 1.6 or better. The thing about it is, it’s difficult to obtain the official 1.5 from Sun since Oracle took over….
  • That you have $HOME/bin in your $PATH, this is where the split_bootimg.pl and repo, mkbootimg, testsign.jar will be found in.

Steps:

  1. Obtain the Android SDK from the official download page here, in my case, I installed it into $HOME/ANDROID.
  2. Pull down the entire Android Source tree by following the instructions from here. I installed this into $HOME/mydroid, this is a clone of the current source tree as maintained in the public repository. Be warned, this will take a while depending on your broadband connection, the source is well over 3.5Gb. You need to follow the instructions there, this step is required so you could obtain the necessary tools to build the kernel.
  3. Now when that’s done, I cloned the repository residing on github into $HOME/repository.
    1. $HOME/repository: git clone https://github.org/ZTE-BLADE/ZTE-BLADE-2.6.32.git
  4. Obtain the original ROM that is used in your handset and unzip the ROM into $HOME/myrom.
    1. $HOME/myrom: unzip -d my_rom.zip
    2. There should be two directories – META-INF and system. The one that we are interested in is boot.img.
    3. Using the split_bootimg.pl, we extract the information from boot.img:
    4. $HOME/myrom: split_bootimg.pl boot.img
    5. There should be two files, boot.img and boot.img-ramdisk.cpio.gz(your mileage will vary as the ROM may be different…) boot.img is the actual kernel, the ramdisk.img is the image that is loaded into ram which the kernel runs the initialization of hardware etc.
  5. Plug in your handset and using adb, obtain the kernel’s configuration
    1. $HOME: adb pull /proc/config.gz $HOME/androidconfig.gz
  6. Go into the kernel’s sources and issue the following commands:
    1. $HOME/repository/ZTE-BLADE-2.6.32: zcat $HOME/androidconfig.gz > .config
    2. Now, we need to set up a special flag to indicate that we’re cross-compiling to the handset’s chipset architecture $HOME/repository/ZTE-BLADE-2.6.32: export CCOMPILER=$HOME/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
    3. You can at this stage, if you’re feeling adventurous, to browse through the configuration of the kernel via the kernel’s menu: $HOME/repository/ZTE-BLADE-2.6.32: make menuconfig
    4. To build the kernel, issue this, $HOME/repository/ZTE-BLADE-2.6.32: make ARCH=arm CROSS_COMPILE=$CCOMPILER
    5. The above step will take a while…
    6. The kernel will reside in $HOME/repository/ZTE-BLADE-2.6.32/arch/arm/boot/zImage
    7. Also, watch out for the optional kernel modules, this can be found in $HOME/repository/ZTE-BLADE-2.6.32/modules.order
  7. Navigate back to the $HOME/myrom, and go into the system/lib/modules directory:
    1. cat $HOME/repository/ZTE-BLADE-2.6.32/modules.order | sed s/^kernel\//g | awk ‘{ system(sprintf(“cp $HOME/repository/ZTE-BLADE-2.6.32%s .\n”, $0)); }’
    2. What we have done here, is copied the freshly built optional kernel modules here.
  8. Navigate back to $HOME/myrom and copy the freshly built kernel image here.
    1. $HOME/myrom: cp $HOME/repository/ZTE-BLADE-2.6.32/arch/arm/boot/zImage .
  9. Now, to recreate the boot image, this part is extremely important, ensure the hexadecimal address is correct as this is where the kernel will get loaded on the handset in the region of memory as specified by the hexadecimal address. Check around first before doing this, as when you re-flash the new ROM, the addresses will conflict and worst case – the handset will refuse to boot. For the Orange’s San Francisco/ZTE Blade, the address is 0x2A0000:
    1. $HOME/myrom: mkbootimg –base 0x2A00000 –cmdline ‘androidboot.hardware=blade console=ttyMSM2,115200 g_android.product_id=0×1354′ –kernel zImage –ramdisk boot.img-ramdisk.cpio.gz -o boot.img (Thanks to hecatae from blade.modaco.com for the correction by pointing out that –cmdline was left out – whoops! ;) )
  10. Next step, re-zip up the ROM:
    1. $HOME/myrom: zip -r my_new_rom.zip META-INF boot.img system
  11. Finally, we need to re-sign the newly created ROM:
    1. $HOME/myrom: java -classpath $HOME/bin/testsign.jar testsign my_new_rom.zip my_new_rom_signed.zip

Now, copy the file my_new_rom_signed.zip to your SDCARD on your handset and reboot, using your ROM manager to install and flash the ROM. In my case, I can tell Clockwork Mod Recovery to install the zip and flash the system.

Post to Twitter

Android Force Close

There’s a site that is remarkably similar to the StackExchange site format, such as StackOverflow.com, called ForceClose, a lot of interesting questions that is geared and orientated towards the Android system. A Q&A site specifically for the Android platform.

Incidentally, the acronym that is bandied around FC means exactly that, Force Close, a dreaded programming error that causes the application to crash and a dialog box appears prompting to Force Close the application.

Post to Twitter

Cygwin 1.7.7.1

Have went through the trouble in downloading cygwin 1.7.7.1, so have decided in spirit of open-source, I am willing to burn a copy of it into ISO format for burning on DVD for anyone.

For a small donation to cover the postage to anyone, anywhere in the world, for every 3 euro donated, 1.50 euro will go to the cygwin foundation…

Now, is that fair? :)

Post to Twitter

Android development

I highly recommend this site, plus the subscription is worth it IMHO – CommonsWare, where you get 3 books for a subscription for a year, in which you can download it and learn at your own pace… it’s not all that difficult, if you’re new to Java, well, there would be a learning curve. If you come from a different programming language, you will easily pick up the pace of the tutorials and explanations…

At $40 for a year, including updates on the books.. Excellent treasure trove!

In short – highly recommended. Cheers to Mark Murphy of CommonsWare for his time in writing those books! \o/

Post to Twitter

Back and bad-ass

Well, after taking a hiatus from the blogging sphere for a while, I thought I’d send out my New Year Greetings to all readers of this blog, sure it’s being a while but over time I will tell what’s been happening…

Well, 2011 is here, this year is going to be exciting… there’s new things happening in the Samsung bada world, and also in the android world…

Will let you on to a secret, I am in love with Android… in a geeky nerdy way that one could describe, the beauty and simplicity of it plus the fact combined with the Linux kernel, this makes it a truly a geeky system, the joys of finding out so much on what can be done with it… over the coming few days I will be blogging about all sorts on Android, and not forgetting Samsung’s Bada…

Til then… have fun and practice safe hex \o/

Post to Twitter

Gameboy Emulation in JavaScript

Uh huh, yup, you’ve read that correctly. This is an excellent read and is very very interesting…it talks about using Javascript to emulate the CPU instructions that is found in the Nintendo Gameboy hand held console using the Zilog Z80 instruction chipset…

That is a worthy article that explains everything very well and could form the basis of the same principle for other emulators…

Thanks to Imran Nazar for the enjoyable read

Post to Twitter

Building a superior Bada Community site – II

Well, as I have blogged about this on previous occasion, I can now breathe a sigh of relief and voted to close this site proposal as the crew (Hi Wit, Nour ;) ) over at badadev.com has come up with their own innovative site aptly named Ask Badadev, so thanks to GeekyBob, and the rest of the pirate crew, to those who have joined in and gave their support in the site proposal.

It is a mixed blessing in disguise now we have a superior bada community there now @ ask.badadev.com…

Long may it last and wish every success in that adventure on the bada seas…. ;) arr arr

Post to Twitter

Android, threads, message passing

Recently I was tackled with a task to be able to put a thread into the background, and from the main UI thread, to be able to pass a message into the thread, this left me stumped… Read more »

Post to Twitter

WordPress Themes

Bad Behavior has blocked 301 access attempts in the last 7 days.

Stop SOPA