Dec 27, 2013

Path to iPhone Simulator files in Mac OS X Mavericks, Xcode 5

Posted Dec 27, 2013
You should start looking in:
/Users/[current user]/Library/iPhone Simulator/

If you can't see the Library folder in Finder, click here how to show hidden files and folders in Mac OS X.

To access the applications in the Simulator, pick the iOS version you are using e.g.:
/Users/[current user]/Library/iPhone Simulator/6.1

Go to Applications folder and pick the hashed folder name that contains your application e.g.
/Users/[current user]/Library/iPhone Simulator/6.1/Applications/2ABAAFD5-71B0-478A-BEBD-13BA56AA03D7

For the SQLite Database, it should be inside the "Documents" folder with the extension ".sqlite" e.g.:
/Users/[current user]/Library/iPhone Simulator/6.1/Applications/2ABAAFD5-71B0-478A-BEBD-13BA56AA03D7/Documents/myapp.sqlite

You can use Liya app (it's free) to open the sqlite database.

Show all hidden files and folders Mac OS X Finder

If you can't see the hidden files in Mac OS X's Finder, execute the following in Terminal:

defaults write AppleShowAllFiles -boolean true

killall Finder

Oct 18, 2013

Why I can't upgrade my Openshift account to a paid one [Updated]

Posted Oct 18, 2013
[Update 19 March 2014] Openshift has just introduced a new plan: Bronze plan! Which costs $0 to maintain and you have options to place add-ons. This is great news!

Openshift is a great platform to host your web application. I like the the way it was designed, allowing the community to contribute. I like its performance and up time. Another great thing about Openshift is the free account; you start with 3 small gears, 512MB RAM and 1GB storage and unlimited bandwidth which is good enough for a small start-up website.

What's the problem with Openshift?
I find its pricing plan unusual. If you're on FreeShift, you cannot add resources (like storage, RAM, etc).. not until you upgrade to Silver Plan. So from $0 per month, your next option is already the Silver plan which is $20 per month + resource usage costs.

I find this extremely strange why you're forced to have a minimum of $20 per month before you can add resources.  It's expensive, where as Digital Ocean offers 20GB of storage space 512MB RAM for $5 per month; only downside is the 1TB bandwidth limitation.

There's already a feature request to add a pay-as-you-go storage for FreeShift but no update yet when it will be implemented.

Oct 4, 2013

[Solved] How to make iOS Simulator choose Wi-Fi Connection

Posted Oct 4, 2013
Depending on your configuration, you may notice that the iPad or iPhone simulator uses the LAN connection. One workaround is to unplug your ethernet cable so that the simulator will be forced to use WiFi, but if you don't want to do this every time, you may also try the following configuration below:

1. Go to Network Preferences

2. Click the Gear icon and choose "Set Service Order"

3. Move the Wi-Fi service on top of Ethernet service.

You can restart the simulator and see if it uses the Wi-Fi connection.

Sep 25, 2013

How to update regular Eclipse Kepler to Java EE [WTP, Webtools]

Posted Sep 25, 2013
If you're like me who downloaded the Standard Edition of Eclipse in the hopes of saving space and maybe performance (Because I was supposed to just use it as a CVS client for Mac OS), then you'll also realize later that you should've downloaded the Java EE version instead because Eclipse's Web Tools Platform is very useful.

I tried the Eclipse Market Place and the Install New Version menu (using existing update sites) to no avail.

If you tried searching the web how to update Eclipse to J2EE version without downloading the entire Eclipse again, then it is most likely that you've probably ended up in an outdated documentation pointing to an old Webtools repository.

To cut to the chase, to add Webtools Platform (WTP) to Eclipse Kepler, go to Help > Install New Software

Add to Location and Name it whatever you like e.g. Webtools Kepler. Check the Web Tools Platform and update your Eclipse. After installation you should now have the Java EE perspective and the various editors for Javascript, HTML, CSS, and other web components.

For other version of Eclipse, it's will highly likely follow the pattern[eclipse_name]/

Sep 17, 2013

[Solved] Smooth Div Scrolling in iPad Browser (or iPhone / iOS Devices)

Posted Sep 17, 2013
If you have a scrollable div using overflow: auto or overflow: scroll, you will notice that the scroll is slow or choppy. To make the inline scroll smooth, just add the following in your css class:

-webkit-overflow-scrolling: touch;


  height: 300px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;

Sep 13, 2013

[Solved, Mac OS X] Disable web security in Chrome

Posted Sep 13, 2013
Execute this in terminal:

open /Applications/Google\ --args --disable-web-security

I use the above settings when testing Backbone JS + Require JS + Underscore JS + Text Plugin to read files from file system. Google Chrome won't allow it unless the above parameter is set. This is also related to disabling Chrome's Same Origin Policy.

Aug 11, 2013

I hate Ghost Blogging Platform!

Posted Aug 11, 2013
Hate is such a strong word along with despise, abhor, resent, loathe.. okay I'm just writing synonyms here but the thing is, this is not a hate blog, it's just a response to a blog written by Nitin Khanna. I enjoyed reading the post because it gives a different perspective on the what's not to like in project Ghost.

For those who don't know yet, Ghost is an open source blogging platform started by John O'Nolan. The motive and vision are great. I was immediately hooked and got excited with the idea of a new blogging platform to address the issues of existing ones, plus it will be written in my current favorite framework: Node JS which is based on Javascript.

Upon reading John's idea of his new project, a question popped in my head: will he and his team really achieve the "Just a blogging platform" concept? This aims to focus mainly on publishing content, but at the same time, make it customizable. I don't want to fight the idea, but more of challenge it, because what I'm seeing is this will be a Wordpress-like platform that does everything, but hopefully better. Sure, it will start as "Just a blogging platform" but if it's really that customizable, then there's no stopping anyone from turning this into the next WCM or CMS built for modern times. Just like what happened to WP.

Do we really need another Wordpress like platform?

If you understand what Node JS is addressing, then YES we do need another blogging platforfm. In my experience in using Node JS, from very simple codes like this site to somewhat more complicated ones, like in, I really enjoyed it. Coming from a Java background, it made me excited about web programming again. Simple codes, doing extra-ordinary stuff; much like Ruby on Rails but I don't know, it might be very subjective to say it, but I didn't enjoy RoR as much as I enjoyed programming in Node.

This is the reason why I found Ghost in the first place, because I was looking for a blogging platform / CMS based on Node JS. But since node is still relatively new, I found it difficult to find a pre-built open source systems that just work.

However, Ghost is not really advertising itself as another Wordpress like platform, but more of a blogging platform. It will probably also focus on workflows and workflow customization which is virtually non-existent in other platforms (well, at least natively). Even so, do we need another blogging platform? A new one wouldn't hurt. People arguably just choose between Blogger and Wordpress nowadays. Those who wants more elegance and professionalism would go for Wordpress, those who want more freedom and lesser cost would go for Blogger.

NodeJs, Yes! Really!

Nitin Khanna's point is that Node is not yet ready for prime time: problem with native hosting support, and usability issue for non-developers. I can't speak for the laymans, but as a developer I find it relatively easy to get Node JS up and running, to the point the it can be done in one command. The command can be wrapped in a shell script which an end user can just double click, wait a few minutes and see his/her system live on the internet.

There are already various free and paid hosts that support Node: See the list here. One of the great things about Node is its resource consumption because it doesn't require a huge ram to run, and start-up is also relatively fast. These were my main problem with Grails framework, a Java framework. The framework is great, but it's so bulky and consumes a lot of resource that even a simple application needs at least 512MB of RAM to run normally, and start-up is extremely slow. Node JS I think only needs 256MB to run smoothly. It's relatively easy and less costly to support Node compared to other frameworks, and it's happening right now; more and more hosts are supporting Node.

Nitin's point may still be right though as Node is still new and needs more time to mature. It's getting there, yes, but probably not yet prime time-ready. However, Ghost, when it's released, won't be a mature platform instantly anyway. It will also take time and probably years to be ready for prime time; just enough time for Node to also mature.

Wordpress is here to stay.. well, at least for a while.

Another Nitin's point is how O'Nolan allegedly stole from Wordpress and gave nothing back. Controversial statement which John O'Nolan couldn't resist but to reply in the comment section. It would be cool if he were to also comment in this blog, but I don't have anything controversial to say, haha!

From my perspective, O'Nolan is passionate about writing / blogging and would like to use a platform in which he could really enjoy doing it. I believe WordPress is ALMOST it but still not quite, and this "almost but not quite" feeling probably bothered him everyday; why isn't there a service or a system that he really wants to use? I can relate to this. This is the same reason why I created; for my needs, and help others who have the same needs and wants as I do.

Ghost won't probably replace WP anytime soon. WordPress is a proven platform, whereas Ghost still needs to time to prove itself. And even in the far future, I would see the two, along with other blogging platforms, co-existing to give end users a choice.

Final Words

Many of us, especially software developers / designers, have ideas that pop-up in our head from time to time. Some are great, some are not so great, but only a few really go out their way to make their idea into reality. Not everyone has been given the chance to learn to type stuff and make the computer do something special.  It's almost a god-like skill because it is as if you are creating something out of nothing; the possibility is endless, imagination is your limit. Take advantage of it!

I admire what O'Nolan started. I'm excited to try Ghost now, but unfortunately the code is not yet available publicly. I do wish they release it soon! This part I don't get, why not just release the code immediately. I hate it! I hate Ghost Blogging Platform, haha!

A thought just came to mind.. I wonder if Google would think of upgrading Blogger to use Ghost. Far-fetched.

Jul 29, 2013

[Solved] Zurb Foundation and Google Custom Search Engine layout problem

Posted Jul 29, 2013
When adding a Google Custom Search box in your site that uses Zurb Foundation 4, it is most likely that the search button will be distorted and the search box won't have proper padding and you'll see various styling issues.

For a demo of a working zurb + custom search, just visit

The solution is to add this into your CSS:

.gsc-control-cse  * {
 -moz-box-sizing: content-box !important;
 -webkit-box-sizing: content-box !importantx;
 box-sizing:  content-box !important;

.gsc-control-cse input {
 box-shadow: none !important;

.gsc-control-cse input:focus {
    outline: none;

.gsc-control-cse table {
 border: none;
 background: transparent;

.gsc-input-box, .gsc-search-box .gsc-input>input, .gsc-input-box-hover {
 -moz-box-shadow: none !important;
 -webkit-box-shadow: none !important;
 box-shadow: none !important;

Jul 28, 2013

How to Add Responsive Google Ad Code

Posted Jul 28, 2013
Many asked before if it's legal to change the ad size through javascript, now it's official, Google allows modification of its ad sense code for responsive design.  You won't be breaking any terms and conditions when you do this.

Do note that the adsense javascript code below is not really responsive in a sense that when you resize the browser, the ads change size dynamically; no it doesn't do that. It only checks the window size at start and set the appropriate ad size. You have to refresh the page after resizing the browser to see the ad size change.

The code:
<script type="text/javascript">
    google_ad_client = "your publisher id"; //change
    width = document.documentElement.clientWidth;
    google_ad_slot = "111"; //change
    google_ad_width = 320;
    google_ad_height = 50;
        if (width > 500) {
        google_ad_slot = "111"; //change
        google_ad_width = 468;
        google_ad_height = 60;
    if (width > 800) {
        google_ad_slot = "111"; //change
        google_ad_width = 728;
       google_ad_height = 90;

<script type="text/javascript" src="">

At least it's getting there, maybe soon we'll see a truly responsive ad.

Jul 16, 2013

XCode 4.2 and Phonegap / Cordova and CDVInvokedUrlCommand compile error [Solved]

Posted Jul 16, 2013
When you download Cordova / Phonegap and create an iOS project using the create command, the resulting project has many compile errors if you do not use XCode 4.5. It is also written in their documentation and at least XCode 4.5 is needed to run their project.

Those using Snow Leopard OS are stuck with XCode 4.2, so it would be helpful if phonegap / apache cordova runs in XCode 4.2.

The first error you will encounter is Automatic Reference Counting Issue of CDVInvokedUrlCommand for instance message does not declare a method with selector... on line 62 of CDVInvokedUrlCommand.m with the code: [self massageArguments];

Found out that the compatibility issue was just due to declarations, position of methods, and use of new syntax (The "at" syntax of new iOS @{} for NSDictionary). So I just changed the code to be compatible with older version of compiler / SDK and it worked! I was able to compile and run it in my simulator.

I uploaded the working sample project in github:

Jul 4, 2013

XML nodes over 64K in size cannot be printed when using Binary XML Storage [Oracle] [Solved]

Posted Jul 4, 2013
If you're using Binary XML Storage and you used DBMS_XSLPROCESSOR's CLOB2FILE method to write to file, there is a chance that you'll encounter the 64K limit of nodes.

The workaround is to use another method to write XMLType to file: DBMS_XMLDOM's WRITETOFILE:

Declare your desired directory:

create or replace DIRECTORY XMLDIR AS 'C:\tmp';

Use dbms_xmldom to write XMLType column to file:

  doc DBMS_XMLDOM.DOMDocument;
  for c in (select xml_col from xml_table x where key_col='mykey') loop
    doc := DBMS_XMLDOM.NewDomDocument(c.xml_col);
    DBMS_XMLDOM.WRITETOFILE(doc, 'XMLDIR/output.xml');
end loop;

Jun 19, 2013

Write XMLType Column to File using dbms_xslprocessor [Oracle] [Solved]

Posted Jun 19, 2013
Declare your desired directory:

create or replace DIRECTORY XMLDIR AS 'C:\tmp';

Use dbms_xslprocessor to write XMLType column to file:

  for cur in (select XML_COLUMN from YOUR_TABLE) loop
    dbms_xslprocessor.clob2file(cur.XML_COLUMN.getClobVal(), 'XMLDIR', 'NAME.xml');
  end loop;

Clear Oracle DB Cache [Solved]

I used these 2 commands to clear cache in between queries in Oracle DB especially when testing for performance:



Jun 14, 2013

[Solved] NoClassDefFoundError, cannot find VirtualMachine when using HotThread

Posted Jun 14, 2013
I got a NoClassDefFoundError when trying to execute HotThread.jar in Cent OS Linux using java -jar command, seems it cannot find com/sun/tools/attach/VirtualMachine which is part of tools.jar.

[root@ALFSYSTEST4-VM bin]# ./java -jar /home/samba/HotThread.jar 3223
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/attach/VirtualMachine
        at hotthread.Main.main(
Caused by: java.lang.ClassNotFoundException:
        at Method)
        at java.lang.ClassLoader.loadClass(
        at sun.misc.Launcher$AppClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
        at java.lang.ClassLoader.loadClassInternal(
        ... 1 more

The solution is to just use the java -classpath approach and load the two libraries then execute the HotThread program:

java -classpath "/opt/jdk1.6/lib/tools.jar:/home/samba/HotThread.jar" hotthread.Main 3223

Mar 23, 2013

[Solved] File to import not found or unreadable: compass/css3

Posted Mar 23, 2013
I'm on Windows 8 and I tried installing sass and compass and when I tried "compass watch" on an existing project which has an "@import "compass/css3";, I got an error:  File to import not found or unreadable: compass/css3

The solution is to install rails-compass

gem install compass-rails

After that "compass watch" now worked.

Mar 14, 2013

Convert Twitter's created_at to Javascript Date

Posted Mar 14, 2013
There are several solutions found on the web to parse Twitter's date, but some seems outdated, maybe Twitter changed its date format. But as of March 2013, the code below works:

function parseTwitterDate(aDate)
  return new Date(Date.parse(aDate.replace(/( \+)/, ' UTC$1')));
  //sample: Wed Mar 13 09:06:07 +0000 2013 


Feb 7, 2013

Rounding a number to two decimal places in Javascript / Node JS

Posted Feb 7, 2013
Rounding numbers with decimals in Javascript is not straightforward. Javascript has a utility Math.round but it only rounds to the nearest integers. Some uses toFixed function e.g. (2.55555).toFixed(2) but it doesn't work consistently across all browsers, sometimes it just truncates the value which makes it troublesome for computations.

Creating a simple function for rounding numbers to two decimals in Javascript should be easy:

function roundTo2Decimals(numberToRound) {
  return Math.round(numberToRound * 100) / 100


If you want to use a library, numeraljs is a good one. It also formats numbers with commas. Very useful.

Feb 1, 2013

How to Get the email address from Twitter Developer API [Rant]

Posted Feb 1, 2013
You can't; sorry to disappoint. As of writing, this is an unresolved issue and many developers are hoping for a positive reply from the Twitter development team: See this discussion and this one for more information. Seems that the Twitter dev team has no plan to support getting the user's email address from Twitter API.

It is unfortunate that this is the case. One big factor of going through the pain of setting up a 3rd party single sign on service is to avoid the process of verifying the user's email address (which takes developer effort). In Twitter's case, you have to do both (set-up authentication AND verify user's email). The same goes for the user who still has to undergo the email verification process. -1 for usability.

I don't know if it's privacy issue that Twitter decided to opt this out, but Facebook and Google, along with other services, are allowing it. Just be transparent and say to the user, this application will know about your email address. What's the big deal, Twitter?

Jan 31, 2013

[Solved] WARN No appenders could be found for logger

Posted Jan 31, 2013

log4j:WARN No appenders could be found for logger (com.turn.ttorrent.common.Torrent).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See for more info.

If you are encountering the error above when you're running a program that uses log4j, the solution is to add a that can be seen by the class loader. Normally it's in the "src" folder of your Java project:

Here's an example of content:

log4j.rootLogger=INFO, stdout

log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

Jan 30, 2013

Imgscalr and DPI

Posted Jan 30, 2013
In my previous post, I practically hailed imgscalr as, arguably, the best native Java library for resizing images or creating thumbnails.

This entry is a follow-up for setting the DPI of jpeg output of a Java image. Note that this only works if your output is in jpeg format:

BufferedImage img = File("c:/img/test.jpg"));

BufferedImage scaledImg = Scalr.resize(img, Mode.AUTOMATIC, 640, 480);

File destFile = new File("c:/img/resized.jpg");

JPEGEncodeParam jpegEncodeParam = JPEGCodec.getDefaultJPEGEncodeParam(scaledImg);
final int dpi = 300;
jpegEncodeParam.setQuality(0.85f, false);

FileOutputStream fis = new FileOutputStream(destFile);
try {
  JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(fis);
  jpegEncoder.encode(scaledImg, jpegEncodeParam);
} finally {

System.out.println("Done resizing");

Jan 29, 2013

Resize Images using Java

Posted Jan 29, 2013
When resizing images in Java, one would normally use Image.getScaledInstance() but it has been proven that this is not the most efficient way to scale images, in terms of quality, performance and resource usage.

An alternative would be ImageMagick which is a popular tool used for programmatically resizing images. However, it wasn't implemented in Java so you still need an interface for it a.k.a. JMagick. This could be a pain especially when you need to set-up additional dependencies just to resize images.

The best solution I found is to use imgescalr, a native Java library for resizing images. It uses hardware acceleration if available. The best thing about it is you don't have to set-up dependencies. It has been tested and used in production environments, so it should be reliable. Here's the link to their website and github.

BufferedImage img = File("c:/img/test.jpg"));
BufferedImage scaledImg = Scalr.resize(img, Mode.AUTOMATIC, 640, 480);
File destFile = new File("c:/img/resized.jpg");
ImageIO.write(scaledImg, "jpg", destFile);
System.out.println("Done resizing");

Jan 22, 2013

DBVisit Standby Review

Posted Jan 22, 2013
DBVisit Standby is a tool for creating standby database for Oracle db which ensures high availability and protection of data. This is very similar to what Oracle Data Guard does, but before you can use it, you have to upgrade to Enterprise Edition (EE) which costs money. This is the main selling point of DBVisit Standby because it can work with Oracle Standard Edition (SE).

The cost of Oracle 11g Enterprise is $47,500 / processor + first year support $10,500 which I cannot uncheck so it means it's mandatory. Oracle Data Guard costs $10,000 / processor + $2,200 first year support. The total cost of the Oracle Data Guard solution is a whopping $70,200!

Let's try to compute the cost of DBVisit solution. The cost of Oracle 11g Standard is $17,500 / processor + $3,850 first year support. The most expensive DBVisit Standby option is $14,342 + $3,586 for 1 year support. Total cost is $39,278, a 44% savings compared to Oracle Data Guard solution.

I haven't tried DBVisit personally, because I don't need it but upon checking the forums and blogs, the problems encountered by users are more of set-up related or something went wrong in the back-up process. I'm yet to find a major problem in data corruption, but according to DBVisit team in a forum post, it checks the integrity of the transferred archive log and if it does not match the original log, it retries until it reaches a threshold before it stops and notifications are sent.

In summary, seems DBVisit employs a comprehensive integrity check. And even if data were corrupted in the main destination, there are several ways to fix it since it has several backup mechanisms in place.

Initial impression is that I'm comfortable to use the product because aside from ensuring data integrity, it has good documentation, helpful community and active development team (in case something wrong happens). But again, this is just my impression.

I have checked the last 60 entries of DBVisit forums regarding technical issues, and almost all have a solution and a reply within 1-3 working days, sometimes they even release a new version within 1-2 days of the issue. They have a very active development team which responds to user concerns. This, in my opinion, is one of the most important strengths of DBVisit. I remember a different scenario when I was using Alfresco, I looked at their forums and many issues are left unresolved, even issues we personally encountered.

In this informal review (because I haven't tried the product personally), I'll give DBVisit Standby a rating of 4 out of 5 stars. -Manny

Discard changes in git

If you want to revert your changes made in a given directory with git versioning, execute this command:

git clean -df & git checkout -- .

This will also handle staged and unstaged files.

Jan 10, 2013

[Solved] Property 'cornerRadius' cannot be found in forward class object 'CALayer *'

Posted Jan 10, 2013
When I tried the following:

UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectZero];
myLabel.layer.cornerRadius = 2.0f;
[myLabel release];

I get an error: Property 'cornerRadius' cannot be found in forward class object 'CALayer *'

The solution is to import the QuartzCore framework:

#import <QuartzCore/QuartzCore.h>

Happy coding!

Jan 8, 2013

Get GMT in iOS using NSTimezone

Posted Jan 8, 2013
There are cases that you want to get the GMT string of an iPhone / iPad device. Here's how you can do it:

  NSTimeZone *localTime = [NSTimeZone systemTimeZone];
  CGFloat gmt = ([localTime secondsFromGMT]/60.f/60.f);
  NSMutableString *gmtStr = [[[NSMutableString alloc] init] autorelease];
  int hours;
  if (gmt < 0) {
    hours = ceil(gmt);
  } else {
    hours = floor(gmt);
  int minutes = abs(round((gmt - hours) * 60));
  if (gmt >= 0) {
    [gmtStr appendFormat:@"+%d",hours];
  } else {
    [gmtStr appendFormat:@"%d",hours];
  if (minutes > 0) {
    [gmtStr appendFormat:@":%02d", minutes];
  NSLog(@"GMT is %@", gmtStr);

Jan 4, 2013

UIView is blurred after setting its width (autoresizingmask / anchoring related)

Posted Jan 4, 2013
Blurring of views usually occurs when the device is trying to fit 1 point to two pixels. This happens when you have an x or y origin with a decimal place. X or Y origins can have unintentional decimal places when you're setting the "center" property of the view instead of the actual frame. It is more apparent in non-retina devices because they have fewer pixels.

Unintentional decimal places in a view's origin can also occur when you set the width of a view that has an autoresizingmask where the view is automatically anchored to its parent and the system is adjusting the origin for you.

In my experience, I get a blurred view in landscape mode when my I set the width of my anchored view to an odd number, so I just make sure I always set the width to an even number.

CGRect myRect = self.view.frame;
int myRectInt = (int) roundf(myRect.size.width);
if (myRectInt % 2 != 0) {
  myRect.size.width = myRectInt + 1;
self.view.frame = myRect;

Happy coding!

Converting CGFloat to int [Objective-C]

There are cases that you want to convert float numbers to integer. One example is when you're using a frame's attribute, say, frame.size.width and you want to know if it's odd or even number. Before you can do a modulo operation, the numbers must be in integer format.

The easiest way is to round the float value first and typecast it to int.

int integerWidth = (int) roundf(myFrame.size.width);

Hope this helps!