How to Format JSON in TextWrangler [#iosdev, #json, #webdev]

If you’re a TextWrangler user and you wanted to be able to format a block of JSON, you can do it yourself by following the instructions at Java Dev on Mac OS X: Format JSON in TextWrangler

1. Create text (Python) file called “Format JSON” in the following location:

~/Library/Application Support/TextWrangler/Text Filters/Format

2. Add the following Python code to take care of the formatting:

import fileinput
import json
if __name__ == "__main__":
  text = ''
  for line in fileinput.input():
    text = text + ' ' + line.strip()
  jsonObj = json.loads(text)
  print json.dumps(jsonObj, sort_keys=True, indent=2)

One thing that tripped me up is that you need to select a block of text before running the macro. Otherwise it works great.

Thanks for the tip!

I’m not sure if it was due to installing newer versions of Xcode or Mountain Lion, but I noticed that I was getting an error when attempting to run the script.

Evidently the first line:


Might need to be:


…or maybe you could create a symbolic link as well, but for me, since I’m not a Python guru, modifying the script was the easiest way to fix the problem.

Top Minimalist Website Designs – Trends and Examples – Design Festival

I haven’t been writing a bunch of topics lately about web design but this one caught my eye:

Top Minimalist Website Designs: Trends and Examples » Color, Layout » Design Festival

When you think of minimalism, you may conjure up images of black and white color schemes, overly-??simple layouts, maybe a splash of color here and there. The actual concept in context of web design is about stripping out anything unnecessary. While this can produce boring design, there is a LOT of creative freedom within this framework.

Seems like the principles apply to other areas (read: “app design”) as well. Thanks to SitePoint for the referral, and thanks to Design Festival for the content…

Google introduces Dart: “a language for structured web programming”

Google introduces Dart: “a language for structured web programming” 

Dart: a language for structured web programming – The official Google Code blog

Today we are introducing an early preview of Dart, a class-based optionally typed programming language for building web applications.

Dart’s design goals are:

  • Create a structured yet flexible language for web programming.
  • Make Dart feel familiar and natural to programmers and thus easy to learn.
  • Ensure that Dart delivers high performance on all modern web browsers and environments ranging from small handheld devices to server-side execution.

Dart targets a wide range of development scenarios: from a one-person project without much structure to a large-scale project needing formal types in the code to state programmer intent. To support this wide range of projects, Dart has optional types; this means you can start coding without types and add them later as needed. We believe Dart will be great for writing large web applications.

SitePoint’s new “HTML5 Development Center”

HTML5 Logo

I didn’t know if this would be helpful but SitePoint has been putting together an “HTML 5 Development Center”

The only thing that made me “raise an eyebrow” was that the banner on the page says “Developed in part for you by Internet Explorer 9” and evidently Microsoft has been assisting in the project.


But the good news is this statement on this page:

Browser Neutrality
The HTML5 Dev Center is browser neutral, these are growing technologies and the browsers are always evolving and updating.

In general I really like SitePoint’s reference material, so hopefully they will live up to the browser neutrality policy… ;)

There and Back Again… When iOS Apps Go to The Background

Recently, I was trying to understand what happens when an iOS app goes into the background and then re-emerges later in various ways. It actually wasn’t as straightforward as I thought it would be. This may have already be documented somewhere, but it was a useful educational exercise nonetheless.

The driving reason for exploring the sequence was that I needed to suspend an NSTimer-based process when the app went into the background, and then start it back up when the app returned from suspended animation. Additionally, I needed to refresh a list from a web service when the app emerged, and the issue is that I needed to have it occur just once.

I needed to discover the events that occur and in what order when an app is active in the foreground and the following things happen:

  • User presses Home button
  • User Locks the device

I was also interested in seeing what happens when the reverse scenarios happen:

  • User re-launches app when in background
  • User unlocks the device
  • Initial launch of the app

Turns out the sequence wasn’t quite what I was expecting — but it was very instructive. The following table illustrates my results. The numbers just indicate sequence of events (what happened first and second).

Will Resign Active Did Become Active Did Enter Background Will Enter Foreground
App in FG + Home Button 1 2
App in FG + Lock 1
App in BG + Relaunch 2 1
App in FG + Unlock (after locking) 1
Initial Launch 1

The good thing about creating this table is that it was very helpful in activating and deactivating the NSTimer-based process and also triggering the list refresh when the application submerged and then emerged.

Let me know if anyone is interested in code for this…

#iosdev iPad UISplitViewController QuickTip for shouldAutoRotateToInterfaceOrientation

I wasn’t having a problem, but I was just curious about the question of whether or not it was necessary to make all your shouldAutorotateToInterfaceOrientation:interfaceOrientation overrides jive when using a UISplitViewController.

Sure enough, as is mentioned here in this Stackoverflow thread:

All of your view controllers INSIDE the split view controller have to override [shouldAutorotateToInterfaceOrientation:interfaceOrientation]… To make it rotate to all orientations, return YES in all overrides.

Makes sense to me. Thanks to Krumelur.

Git: The difference between Pull and Fetch

I really appreciated how Greg Hewgill summarized the difference between the two Git functions “Pull” and “Fetch” on Stackoverflow:

In the simplest terms, “git pull” does a “git fetch” followed by a “git merge”.

You can do a “git fetch” at any time to update your local copy of a remote branch. This operation never changes any of your own branches and is safe to do without changing your working copy. I have even heard of people running “git fetch” periodically in a cron job in the background (although I wouldn’t recommend doing this).

A “git pull” is what you would do to bring your repository up to date with a remote repository.

Easy Audio Playback With AVAudioPlayer – Tutorial [Mobile Orchard]


Can you guess what I’ve been doing lately?

Here’s another great tutorial from Dan Grigsby of Mobile Orchard, this time on playing audio with the AVAudioPlayer in the iOS SDK…

Tutorial: Easy Audio Playback With AVAudioPlayer

The iPhone SDK’s AVFoundation framework includes AVAudioPlayer, an easy, feature rich, Objective-C based way of playing audio files.

This tutorial demonstrates how to use AVAudioPlayer. When you’ve finished the tutorial you’ll have created a simple app that plays an MP3 audio file in a loop when the app starts.




NineOneOne: First App Submitted to iTunes AppStore!

After weeks/months of work I have submitted my first app to the iTunes AppStore!

So, now we wait for the approval/rejection to occur (hopefully not the latter)…

In truth, the amount of work can actually be measured in hours or perhaps days, with the actual building of the app being the least time consuming part since this is a very basic application.

I had no idea going into this the amount of time that would be spent on the preparation of the application for submission. At this point it is probably the most daunting aspect of the process — the development of the product was the simple[r] part. I expect that it will get easier the more apps I create, and having gone through the process once already, at least now I know what’s involved and what some of the potential gotchas are.

It’s tough to go it alone, but for now that’s what I have to stick with, having a day job and no capital to back up my projects or to hire other staff, much as I would like to be able to focus on this alone. It seems to me like you really need a team of three (+/-) people to make a really decent app in a timely fashion. Ideally, I think  I could get by on a relatively lean three-person team and would consist of:

  • Me. (duh)
    • product design and specification
    • UX/interaction design
    • iPhone development/programming
    • Web site programming (if required)
  • graphic designer (my graphic design skills are limited, and I’m really slow at what I do…)
    • iPhone interface eye candy
    • Icon design
    • Web site design
  • Deployment/distribution (and marketing) engineer
    • Manages distribution for testing, arranging and managing alpha and beta tests.
    • Handles all iTunes AppStore preparations (SKUs, marketing materials)

That last one is kind of squidgy, but it was the stuff that really made me insane on this first go-round, and having someone – even just part time – to collect the resources and manage the iTunes part of the equation would be really helpful. This persone would be someone who has done it a number of times and knows all the little gotchas. There are many.

Thankfully, I chose to create an app that was very small and not real complicated to construct. Otherwise, this app would never have gotten submitted! However, since it was an app that I personally needed (but didn’t realize until after I needed it), I felt pretty strongly about just getting it DONE!

I will announce when the app is approved, if it is approved. In the meantime I will be planning out the next update for NineOneOne, in addition to the next app in line…