Apps in SG – A showcase of Apps designed and built in Singapore

I realised people outside of the development and entrepreneur circles are often unaware that there are many talented app designers and developers in Singapore. And when I try to show them examples, there isn’t such a list of made in Singapore apps. You either know that autumn dynasty is one of the top selling games made locally, or you don’t.

AppsInSG.com is first and foremost a quick way to showcase beautiful and/or useful apps released by locals, and the talented people and companies behind them. Although the list is heavily biased towards mobile apps at the moment, I’m working to include more web, desktop, and even console apps in the coming weeks. I hope it can grow to provide additional exposure for newly launched apps, inspiration, and eventually a place for developers and designers looking for work at interesting companies.

Know a beautiful or useful app made by Singaporeans? Make a suggestion here.

Parse with deprecated Facebook headers on iOS gives “Semantic Issue” errors

If your app uses the deprecated Facebook headers, i.e. #import "Facebook.h" instead of #import <FacebookSDK/FacebookSDK.h>, importing Parse.h using the standard instructions at https://www.parse.com/apps/quickstart_push would fail your build with multiple errors of

Semantic Issue, Redefinition of enumerator 'FBSessionsStateCreated', 'FBSessionState....', etc.

The issue is that Parse imports the Facebook headers internally. To work around this, open Parse.h and replace

#if __has_include(<FacebookSDK/FacebookSDK.h>)
#import <FacebookSDK/FacebookSDK.h>

with

#if __has_include("Facebook.h")
#import "Facebook.h"

Next, open PFFacebookUtils.h and replace #import <FacebookSDK/FBSession.h> with #import "FBSession.h" and you’re good to go.

MVP vs BVP

The Barely Viable Product

The term minimum viable product shouldn’t be foreign for startups. It represents the fatest route to market, a product that has the minimum set of features that allow the product to be deployed (and gather data), and no more. It’s a simple concept to grasp, with obvious benefits, and most entrepreneurs I know at the prototyping phase use the term as if it’s common sense. Yet, I still see many MVP’s taking double the expected amount of development time, and launching with a feature set that is just shy from version 2.0. Where’s the disconnect?

There is nothing wrong with the term and its definition. The issue doesn’t seem to lie with the intention and sincerity of those using the term as well. The problem seems to lie in the perception of “minimum”. I’ll attempt to illustrate this using a series of grayscale gradients.

This is how the desired features of a product can be listed in an ideal universe. Each feature is easily categorized as essential, or not. In practice, this is hard. The features more than likely appear as the following to a product developer:

And the actual features implemented as the “minimum viable product” usually becomes:

Although this is still much better than implementing all the features and delaying the launch, it is straying quite far from the original intention of a MVP. Remember we are not just comparing time spent developing those extra features, you need to include iterations and testing as well, and each new feature adds to the total time non-linearly. Reflective developers would probably make a note to themselves to stay closer to the objective next time around. Some may kick themselves for failing to do so yet again.

Its easy to attribute this to greediness and lack of discipline, but I feel its more likely due to the ambiguous nature of the term “minimum” – where do you draw the line in the grey area? Any feature seems just as a good fit under the minimum label as the other. Therefore I am proposing a new term to help product developers deal with the idea of minimum – the Barely Viable Product.

The term barely inherently denotes a much less greedy approach to selection – you are not even selecting what’s minimum, you just want it to be barely viable. I hope this conjures such an image when translated into my greyscale gradient:

Much better isn’t it?

The barely viable product isn’t a replacement for the ideas and concepts behind the original term, but a new guide when picturing the minimum viable product. I hope this simple alias would help startups form a bettre mental picture of what they are trying to achieve. The truth is, product developers would still stray, but hopefully much less. This change of perception is a kind of reverse of the aim-for-the-stars-and-reach-the-moon way of thinking, it’s more like the experts’ way of packing for a trip – pack what you need then throw out a third.

Perception aside, startups need to be reminded to use BVP in conjunction with the underlying aim of learning about customers, not just early releases. It is definitely helpful to release and start gathering customer feedback but make sure what you are releasing allows you to do that. In the end its more about customers than your product, you’ll still need to figure out a balance yourself.

Beta Testing for Leendy

After 3 months of weekend development sessions, I’m excited to finally start the beta testing phase for Leendy. I’ve even squeeze out time to do up the website and Facebook page!

Leendy is the easiest way to share and swap things among friends while saving the earth. It is based on the collaborative consumption philosophy of sharing to cut down on resource wastage and allow everyone to enjoy more value out of existing items. If you have an iPhone and some free time, why not register as a tester?

Running manage.py locally with auto pythonpath

While trying to run my manage.py locally to syncdb, it complains that my project’s .settings isn’t in the sys.path. Instead of setting it manually, I decided to add it into the manage.py script itself:


from os.path import abspath, dirname
sys.path.insert(0, dirname(dirname(abspath(__file__))))

This works perfectly in Django 1.6 on Python 2.7+

Drupal 7 – Debugging Illegal offset type in isset or empty in … and other errors

Though the title mentions Drupal 7, this article is really about the debugging technique and so is applicable to general php as well. I want to share a recent bug we had to solve at work. Though experienced developers would usually have an idea what new code is breaking, mysterious warnings and errors sometimes do slip through while working in teams (even when having a proper svn system in place!). You check with your co-developers and the one who broke it have no idea where this might be coming from, or worse: they have seen and have been ignoring this error for some time because they felt it didn’t matter. What do you do then?

Read the error
The error message “Illegal offset type in isset or empty in…” points to an illegal type used in a call to isset or empty, and it conveniently points you to the offending line – but with Drupal’s (and most of today’s frameworks’) complex page execution flows, it is hard to spot where is the real source of error, especially if the line is in one of the framework’s frequently called core routines (in my case it was in user_access). Since this is not much help in trying to deduce the real source, I resort to setting my own error handler (temporarily overriding Drupal’s) so that I can do a debug_back_trace().

To set your own error handler, define a function and feed the name to php’s set_error_handler():
[php]
// Your custom handler
function my_error_handler($errno, $errstr, $errfile, $errline
, array $errcontext)
{
// error was suppressed with the @-operator, ignore
if (0 === error_reporting()) {
return false;
}

// print the backtrace
echo ‘<pre>’.print_r(debug_backtrace(),true).'</pre>’;

// throw an error exception if you want to catch it at the caller
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}

// Back at the offending line:
set_error_handler(‘my_error_handler’);

try {
// original code
}
catch (ErrorException $e) {
// print your own debug log or what not
}

// Restore Drupal’s own error handler. You don’t want a backtrace
// on every other E_USER_NOTICE’s do you?
restore_error_handler();

[/php]

While you may find it useful to convert every error into an exception, note that even E_USER_NOTICE would then halt your page execution, so please use with care (refer to php manual on the ErrorException class for a handler that ignores non-fatal errors).

Now, what’s left is to carefully read through the debug backtrace and spot the problem. For my case, it was a line of code someone embedded in a view context. Hope this helped, share your own debugging methods and opinions in the comments.

End note
Some people may feel that my style of debugging isn’t very ‘elegant’ but my experience is that the fastest way to find the problem isn’t necessarily the most elegant way. Rather than going through hours of deducing which functions might or might not be involved, and later realising the problem was in one of those functions that “logically shouldn’t have mattered in this case”, I find that getting a solid backtrace – after a quick deduction fails – is usually my best bet in the long run.

Fixing Drupal’s Canonical link meta tag

Fblint complained that one of my page’s canonical link mismatches the og:url meta tag. Turns out Drupal 7 outputs relative canonical links by default and although there’s nothing strictly forbidden about relative links, both facebook and google seems to prefer absolute links. Rather than altering the offending tag through hook_html_head_alter() or even worse, mess with the core files, I decided to install the Metagtag module (http://drupal.org/project/metatag).

The default configuration looked fine (the module even supports og meta tags!) so I ran the page through fblint again, hoping it to be another fine install-set-go Drupal 7 module. 58827 sites were using this module at last count, that’s pretty reliable. I was dismayed when I got the same results and a quick check revealed that apparently the module modified none of my head tags. I also noticed that its only the front page that was having this issue. The module works fine on all other pages. A few drupal.org threads later I arrived at the solution: calling render($page['content']); is all it needs to get it to work on overidding page–*.tpl.php’s. Yup just calling render() will do, no need to print.

Solution thread: http://drupal.org/node/1293214

Tips while profiling your app to solve low memory warnings and crashes

Just a quick post to share what I learnt while investigating crashes in my iPad app. The crash reports consistently showed low memory warnings before the crash so I started using instruments to profile the app. Here’s some tips that may help you out when you are stuck using the instruments tool:

Turn off Zombies. Zombies are great for debugging messages sent to de-allocated objects, but they come at a cost of memory – NSZombies are never deallocated. Turning this off immediately showed great reductions in terms of live bytes in the allocations instrument. Apple’s documentation advises zombies to be used only on the simulator while debugging and testing.

Mark your heap before and after performing actions on your app to inspect the memory changes introduced by the action. A simple evaluation to keep in mind is that if any set of actions returns the app to the same state as before the actions, the changes in heap before and after the set of actions should be close to 0. Any significant amounts detected here would signal a leak, which need not necessarily reflect in the leaks instrument profile. Many conditions, like circular references, may cause actual leaks to be ignored in the leaks instrument, but that’s the focus of another article.

The Allocations and Activity Monitor operates differently, and gives very different results. I made the mistake of assuming the ‘live bytes’ column in the allocations report to be what my app was consuming. While allocations reported that my app is using a consistant amount of memory, I was still receiving low memory warnings, so I finally decided to run activity monitor. Surprise – the low 6.3mb consumption in allocations actually translated to 180mb in activity monitor. Why is that so? Turns our when you deallocate memory in your app, or even if you are using ARC, the memory is only released at undetermined intervals when iOS feels like it. While allocations track every memory your app allocates and deallocates, the activity monitor gives a true reflection of your app’s memory footprint.

But of course, those latent released memory wouldn’t chalk up to 100 over mb’s. The real culprit turns out to be CoreGraphics, while it handles all on screen drawings and image operations behind the scenes. The real memory consumed by these operations are not reflected in allocations at all. ARC also does not track CG objects so do remember to release them properly.

Now knowing the real issue, I proceed to refactor and restructure my drawing code to improve reuse of bitmap contexts and reduce repainting areas by keeping track of dirty rectangles. Hope these tips would help give some ideas to those of you debugging your crashes at 3 in the morning. Do also share some of your own tips or experiences in the comments!