Pothi for Blackberry Tablet

In an attempt to nab a free playbook as offered by RIM, I put together this Gurbani Search App aka Pothi.

In it’s initial release pothi will allow you to search in both Gurmukhi (First letters only) and English (All Words). You can also perform a random search for random shabads.

You can also change the formatting in the Shabad view to view by paragraph or by alternating lines.

While the current release is pretty simple, hopefully (pending if I get a free Playbook) additional features in subsequent releases will include:

  • Advanced search options. (Multiple search filters and search modes)
  • Bani and translations from Dasam Granth.
  • Shabad view formatting options. (Change font size and colours)
  • Cleaner search layout for use when in portrait mode.
  • Transliterations.

Pothi will hopefully be is now available in the app store. shortly after review.

Embedding Fonts in Flex 4.5

Embedding fonts in traditional Air apps has always been straightforward, but for optimization reasons the processes has seemingly become a little more convoluted when embedding fonts for mobile apps. The following worked for me when importing custom fonts when developing for the Blackberry Playbook and comes courtesy of rhgillis of the Blackberry Developer Forums.

Locate the fontswf located in the Flex/bin folder (On OSX I found it in /Applications/Adobe Flash Builder Burrito/sdks/4.5.0/bin and run:

fontswf -a titr -o titr -3 titr.ttf

Then you continue to embed the font as normal:
@font-face {    
            fontFamily: titr;
            fontWeight: normal;
            fontStyle: normal;

API Fail

My Blackberry Torch is an excellent ipod replacement, but it lacks a sleep function, to stop playing media after a given time (not sure if my ipod ever had this feature either).

No problem I thought, I’ll just write a little app, where you specify a given number of minutes and have the app stop the active playing media. As with everything when it comes to RIM and its API’s this was easier said then done.

  1. There is no way to access the standard media player. Sad but true, the only native apps that you can really interact with are those listed in the Invoke API, (Maps, AddressBook, BlueToothConfig, Calculator, Calendar, Camera, Maps, Memopad, Messages, Phone, Search and Tasks.)
  2. You can manually send commands (events) to other apps using the ApplicationManager, there isn’t a way to close any third party app, unless the app provider has created methods, (and provided documentation).

Even though there is some sense in preventing such API access, rouge apps closing or removing competitor apps, it does create a limitation to developers, such as myself just wanting to create a simple Sleep App.

The only other alternative would have been to just mute the speaker of the device, but even this doesn’t seem to be possible, as every player can only access its own volume control.

While I’m sure there maybe still a way for now the answer eludes me, if you have any ideas feel free to share.

Multiple DB Backup Script

I haven’t always had the best of luck with some of my web hosts, when its come to backups. While 99% of the time everything has worked as expected, there are those times where I’ve been left with this queazy sinking feeling that I may have just lost all my data or worse yet, users data. So as the old adage goes, “if you want something done right then you better do it yourself”.

So I wrote up a quick awk script that handles the downloading and dumping of multiple mysql databases automatically. I setup a cron that runs the script on the daily.

#!/bin/awk -f
# Dumps the mysql databases for sites listed here.


  if ($0 ~ /^#/)
    print "skipping ", $1;
    dateStr=strftime("%w", systime() );
    cmd=sprintf("mysqldump --quick -e -h %s -u %s -p%s %s | gzip > /Backups/sites/Daily/%s.%s.sql.gz\n",$2,$3,$4,$5,$1,dateStr);
    printf("Backing up %s ... \n", $1);

END { print "** DB Backups Complete **"}

You simply need to pass it a db secrets file in the format of:

title:host:user_name:password:databases to backup

and let the script handle the rest. You may want / need to change the path that your dumps are stored, and depending on how regular you want change the file name structure. Also it’s best to lock down your secrets file to something like 600, so that only that user account can access the file.

Blackberry Rounded TextField

Not the cleanest code, and branded specifically for my case, but can be easily expanded on to be more flexible, and reusable if needed.
Rounded Edit Field for Blackberry OS 4.6>

class BubbleEdit extends VerticalFieldManager{

  protected String _label;
  protected EditField _editField;
  protected LabelField _lblText;

  final static int PADDING_HORIZONTAL = 5;
  final static int PADDING_VERTICAL   = 3;

  BubbleEdit( String title ){
    _label = title;
    _editField = new EditField( TextField.NO_LEARNING | TextField.NO_NEWLINE | TextField.NON_SPELLCHECKABLE ){
      protected void paint(Graphics graphics) {
        graphics.setBackgroundColor( Color.WHITE );


    _lblText = new LabelField( _label ){
      public void paint(Graphics g ){

    Border roundedBorder = BorderFactory.createRoundedBorder(new XYEdges(10,10,10,10), Color.WHITE, Border.STYLE_FILLED);

    _lblText.setFont( Font.getDefault().derive(Font.PLAIN,20,Ui.UNITS_px)  );
    _editField.setBorder( roundedBorder );
    setBackground( BackgroundFactory.createSolidBackground(Color.BLACK));

    add( _lblText );
    add( _editField );


  protected void sublayout(int iWidth, int iHeight)
        int iNumFields = getFieldCount();
        int iYPos = PADDING_VERTICAL; 

        for (int i = 0; i < iNumFields; i++)
            Field fField = this.getField(i);

            setPositionChild(fField, PADDING_HORIZONTAL, iYPos);
            layoutChild(fField, iWidth - (2 * PADDING_HORIZONTAL), Integer.MAX_VALUE);

            iYPos = iYPos + fField.getHeight() + PADDING_VERTICAL;
        this.setExtent(iWidth, iYPos + 10);

  public String getLabel(){
    return this._label;

Trying this again..

I’ve gone through a few iterations of my site. This is only but the latest, of the hundreds. and hopefully the one that sticks. For those tuning in, this is not a blog, well not really, so don’t come around expecting daily, weekly, <insert timely interval> updates at all. At the best this is where I’ll be sharing snippets, code fragments, rather more importantly general ideas that I’ve either put in practice, or borrowed from the next guy.

While the focus may specifically be tech their maybe some personal add-ages added on the side. Just saying is all.

Dynamic YAMJ

YAMJ (Yet Another Movie Jukebox) is the top movie jukebox available for NMT (Network Media Tanks). Unfortunately YAMJ isn’t a media server, rather just an app that catalogues all vide files in your collection and generates static XML files that the NMT’s can read and render into useful (depending on your skin) interfaces.

Problem with this however is you have to run the app over your collection each time you add a new movie / tv show to your collection. Also there maybe times when due to your internet or just the way files are named shows aren’t always found, therefore cover art lost etc, in which case you’d probably want to re-run yamj to refetch movie posters and art all over again. Fortunatly yamj does support multiple configuration files.

Using this I was able to setup two cron jobs. One that runs daily, which refreshes all media content and another that runs every 5 minutes which only looks for new media that may have been added. While this does thrash the hard drive more then anyone would want, it does seem to work to offer a reasonable solution.