Category Archives: Programming

NYC & LA Restaurant Guide iPhone App Clean Plates

clean plates iphone app

I’ve spent part of my development schedule over the last few months rebuilding the iPhone app for NYC based startup Clean Plates. The Clean Plates iPhone app v2 is now available on the app store so check it out. Clean Plates offers professional restaurant reviews and a series of email newsletters with a healthy eating focus. The app allows users to search nearby or by neighborhood to find restaurants (think Yelp’s app but with more advanced filtering options and only professional reviews).

From a development perspective it was an interesting project in one way in particular: it was  a brand new re-write of an existing app. Why re-write instead of extending the existing code base? Read on…

The old app was originally built several years ago and consisted of 475 classes and 79,889 lines of code. If that sounds like a lot of code that’s probably because it is. Because of it’s age there was no use of Storyboards and art assets were fixed in size (no Auto Layout). Combine this with poor performance, frequent crashes and heavy usage of an old un-upgradable version of RestKit and you have a perfect case for a brand new build.

The new app uses Storyboards and Auto Layout so it is compatible with the newer, larger iPhone models. It has been redesigned to be more in line with iOS 7+ style guides and even has more advanced features, including better restaurant filtering and the ability to save favorite restaurants. It is also only has 52 classes and 6,910 lines of code. With the new updates I tried to not to leave any existing users behind so it is still compatible with iOS 7.1+ devices, including hardware compatibility with the iPhone 4 and it’s shorter form factor. Finally, there are no major dependencies on third party libraries such as RestKit so future upgrades should be relatively smooth. The app is not perfect and at least one update will be needed for minor improvements but I consider everything here a big win.

WordPress Plugin Pods

wordpress pods logo

When I first started messing around with WordPress many years ago it was simply known as a powerful blogging platform. Today, WordPress is a highly configurable content management system that can handle almost any type of web based platform (though not necessarily the best choice for everything!). One of the best aspects of WordPress is the unbelievable number and variety of plugins. For a client project I was tasked with build a custom Content Management System (CMS) utilizing the WordPress plugin Pods.

Pods utilizes the existing WordPress admin interface and supporting MySQL database to allow for the creation and management of custom objects. Objects can be very complex in nature and can take the form of many fields with customizable data structures. Complex relationships can also be defined between objects, such as many-to-many. Pods can also reinforce simple object creation and editing validation, such as required fields.

In general I like Pods but I did find a few negatives. First, performance can be rather slow so make sure you have a respectable WordPress hosting provider. Second, object customization is not always straight forward and some of the settings can be rather arcane and without much in the way of documentation. Third, I found a number of bugs such as cases where objects were not updating properly and the data export / import process plain broke. Finally, the underlying database objects created by Pods is somewhat non-standard and not exactly how you would personally build a well designed normalized database.

One final thing to note: development on a WordPress JSON restful APIs has been ongoing for several years and is set to become a default component soon. Leveraging upon this work, there is a Pods JSON API plugin. I made an attempt to configure the Pods JSON API plugin but I had several issues. Couple this with the fact that the Pods database structure is not ideal at all for fast queries that are needed to support an efficient API and I decided to handle my API by leveraging the Slim PHP Micro Framework.

In the end, I think Pods is an interesting choice for those wishing to leverage their existing WordPress infrastructure and expertise to build a highly customizable and powerful content management system. With it’s bugs and quirks, however, be prepared to spend at least a minimal amount of time getting setup and running.

PHP Slim Micro Framework

I recently had to build an API for a client. The client is a content based business that prefers to utilize WordPress related technologies whenever possible. Since WordPress is built on top of PHP and I think it’s a good idea to limit the number of disparate technologies in any tech stack, I decided to stick to PHP solutions for the API development. After researching several different PHP micro frameworks I chose Slim.

So far my experiences with Slim have been great. It is easy to install and configure and performance is excellent. To get started, install PHP, install Composer, create a Composer config file and then run the Composer install command. This will create a directory structure with the main definition file index.php. This file is where you define your URLs and include external files such as the definition for your database connection and code relevant for specific URLs. This structure should be familiar to anyone who has used modern web development frameworks such as Rails or Django but I would like to stress how unbelievably easy it is to get up and running on Slim.

To finish your Slim configuration you will need to configure your web server of choice to work with Slim. I chose nginx as it seems best suited for an API application but Apache is also a popular choice.

Slim is a great choice for PHP developers that want a super simple and lightweight framework to host an API.

JavaScript Table Sort Library jDynamicSorter

jDynamicSorter is a new repository I have added to my GitHub account. The JavaScript library dynamically sorts Twitter Bootstrap row based tables simply using its custom HTML attributes.

What’s nice about this project?

  • Simple, easy to understand and commented source code
  • No unnecessary formatting of data using custom attributes. You simply specify what type of data is in each column and the library takes care of the rest.
  • The header sort UI is updated alongside the sorting process
  • Handles columns where each column div is wrapped in an HTML “A” link
  • Handles date sorting with any type of separator such as “/” or “-” and one or two digit days/months

Getting Started

To get started simply include jDynamicSorter.js, jDynamicSorter.css and the /img folder into your existing JQuery + Twitter Bootstrap project. You may want to apply other CSS attributes to your table as seen in the example project base.css. Next create a row based table with the required class, data-type and data-desc attributes as shown in the example jDynamicSorter-Example.html.

Possible Future Enhancements

  • Ability to have multiple tables on a single page
  • Handle additional date formats
  • Animations
  • Further simplify the code

View a live demo here.

Here is a screenshot:

jDynamicSorter screenshot

Javascript Pie Chart Project FlotPieChart

FlotPieChart is a new repository I have added to my GitHub account. The project shows how to build a customizable Javascript pie chart based off the Flot Chart library. The pie chart has been assigned custom styles, hover logic and click event logic. It is a nice sample project for those getting familiar with Flot charts and want to dive into some customizable features. This project also uses JQuery & Bootstrap. Here is a look:

FlotPieChart screenshot

Wikipedia Article Search iPhone App

Wikipedia Article Search is a new repository I have added to my GitHub account. This iPhone app searches Wikipedia for relevant articles and then displays those articles upon user selection. The app consists of two screens: one with a search box and table view to show results and then next to show the article’s webpage upon selecting it from the table view.

This app use the Wikipedia API to perform article searches. In future versions I hope to include logic to query DBPedia and Freebase to show how you can use these databases to get additional data about an article. I may also convert the NSURLRequest and NSXMLParser logic into RestKit or AFNetworking code. For now, it’s a nice simple app to get any developer started working with Wikipedia in iOS.

Here is a look:

Wikipedia Article Search iPhone App1


Wikipedia Article Search iPhone App2

Javascript Maps Project Tabbed-JVectorMap

Tabbed-JVectorMap is a new repository I have added to my GitHub account. The project consists of a single webpage which features five JVectorMap based Javascript maps each contained within their own tab. Several different map types have been used, styles have been modified, custom action functions have been created and some zoom tricks have been utilized. The maps contain markers that signify the offices of a firm, with the number of employees listed per office. Hovering on the markers shows the office details and clicking on the markers redirects the user to a new webpage (you must insert the URLs in the Javascript file to control the redirection). It is a nice sample project for those getting familiar with JVectorMap and want to dive into some customizable features. This project also uses JQuery & Bootstrap. Here is a look:

Learning Apple’s New Programming Language Swift

apple swift logo


Swift is Apple’s new programming language for iOS and OS X. Swift had been in development for four years before being unveiled by Apple earlier this year. For now Swift can be used alongside Objective-C for existing or new applications though it is expected to entirely replace Objective-C eventually. Swift has a few new features not available in Objective-C, such as Tuples, but the key selling point of the language is that it is easier to learn and read in comparison to Objective-C. Objective-C should remain the more popular language for iOS and OS X programming for several years to come.

As a curious programmer that already works with far too many languages I decided to take the dive and learn the basics of the Swift programming language. After going through some documentation and tutorials in general I think Swift is a cool language with a lot of potential. With that being said, for the majority of my iOS projects I am leaning towards sticking with Objective-C for now. After talking with other programmers, most agree that new programmers should learn Objective-C first and then eventually Swift.

Here is a list of resources that I am going through to learn Swift. These are mostly from the website, which has been a fantastic resource for iOS developers for years. This should be enough to cover the basics of Swift for any level programmer.

ShellShock Bash Vulnerability Fix Instructions

Computer security researchers have discovered a long standing security risk to Linux and Mac OS X machines. The vulnerability is being termed the ShellShock Bash Vulnerability and lets an attacker run commands via the bash shell. Thankfully patches are already available for many platforms and I’m going to walk you through the process I used to patch my MacBook Pro running OS X Mavericks (10.9) and an Amazon Web Services EC2 AMI instance.


Patch Mac OS X Mavericks

Confirm that your machine is vulnerable by opening the terminal and entering the following command. If your machine is vulnerable it will output the text “vulnerable”:

env x=’() { :;}; echo vulnerable’ bash -c ‘echo this is a test’

My machine is vulnerable:

mac os x mavericks shellshock vulnerable

Next, download this OS X Mavericks (10.9) patch from Apple. Patches are also available for OS X Mountain Lion (10.8) and OS X Lion (10.7). The download is 3.2MB, installs using 3.8MB, takes less than a minute and does not require restarting your computer. After the patch finished installing I ran the same command as before to confirm that that it worked. My machine is now protected:

mac os x mavericks shellshock patched


Patch Amazon Web Services EC2 AMI Instance

SSH into your machine and run the same command as before:

env x=’() { :;}; echo vulnerable’ bash -c ‘echo this is a test’

My machine is vulnerable (ip address masked in screenshot):

aws ec2 ami shellshock vulnerable

I used the command “sudo yum update”, which installed all security and regular system updates to my machine. For patching just the ShellShock Bash Bug you will have to find the specific instructions. RedHat has provided some details here. After running the update my machine is now protected:

aws ec2 ami shellshock patched


Note: Much of the information for this post was found in this article from Engadget.

Updated 9/30/2014: Included links to patch ShellShock for OS X 10.8 (Mountain Lion), OS X 10.7 (Lion) and more Linux patch details from RedHat.

Updated 10/02/2014: It appears that there are still vulnerabilities associated with the ShellShock Bug even after patching. I will keep updating this post as more information and patches become available.