Tag Archive load

Installing a PhoneGap App On an iOS Device Using iTunes

Preliminary Steps

To produce an iOS build using the PhoneGap Build web site, one must have created a signing certificate and provisioning list for the devices that the app is allowed to run on. These notes assume that this has been done, and there is a successful build on the PhoneGap Build web site.

Loading into iTunes

The first step, and the first potential roadblock, is loading the app into iTunes.

  1. Plug in the iOS device into the computer and select the device.
  2. Download the .ipa file from the PhoneGap Build site.
  3. Drag and drop the .ipa file onto iTune.

This is where the first “gotcha” may turn up. The .ipa file does not have Apple’s blessing. By default OS X will refuse to load any un-blessed apps.


This can, however be changed in the Security preferences.


Use the lock symbol to allow for changes to the security settings, then choose “Anywhere” in the “Allow apps downloaded from:” section.


OS X will give a final warning about the dangers of doing this, and that the setting will revert to after a certain amount of time.



Now the app should show up in the list of apps to load onto the iOS device, and will be loaded when you sync the device.

Hydration Hanging

Hydration is a wonderful development tool that will automatically fetch the latest version of the app from the PhoneGap Build web site. (It must be removed before submitting the app to Apple for review.) However, when one starts the app,  it will sometimes hang.

To kill the hung app, the Apple support web site has an excellent tip.

Tags, , , , , ,

Display a Server-Supplied Drop Down List Using AngularJS

These are my notes on displaying a list of server-supplied objects in a drop down list using AngularJS.


I have a server that supplies lists of lookup objects that are used in an AngularJS-based single-page application (SPA). The SPA obtains a list through an API call to the server. The server returns an ordered list of JSON objects. Every object in every list includes a key value, a display value, and supplementary data. For the purposes of this article, only the key and display values are of any concern.

For example, the SPA needs a list of units of measure. The server supplies a list of objects along these lines. They key value is called code and the display value is called display:

[javascript light=”true”]
code: "L",
display: "L",
description: "litres"
code: "ML",
display: "mL",
description: "millilitres"
… etc …

In the SPA code, each lookup table is wrapped in its own Angular service.

From List of Objects to Dropdown Using <select>

Angular can be told to create a dropdown list using an array of objects thus:

[html light=”true”]
<select ng-model="product.uom"
        ng-options="u.display for u in units" />

Here ng-options tells Angular to build the dropdown list showing the display attribute of each object. Whenever the user chooses an item, the entire associated object is stored in $scope.product.uom (uom means units of measure). For my purposes this is very handy since I want access to the entire object.

Defaulting to a Value

This works beautifully until an edit page is shown. When displaying data from the server, the dropdown shows a blank selection even though $scope.product.uom contains an object with all the correct values!

The problem is that Angular matches based on object references, not object contents. This can be illustrated thus:

var a = {foo: "bar"};
var b = {foo: "bar"};
var c = a;

Variables a and b contain two separate objects that by chance have attributes with the same values. Variables a and c contain the same object pointer.

In the example above, Angular will recognize the value in $scope.product.uom only if it points to an object in the master list $scope.units. The fact that the server-supplied object has identical attributes is irrelevant — Angular only cares whether the object pointers are identical.


There are a couple of ways around this. If there is a unique key on the object, one can use the AngularJS track by clause to tell AngularJS to compare the keys. Continuing the above examples, each object has a code attribute that has a unique string which JavaScript can compare.

[html light=”true”]
<select ng-model="product.uom"
ng-options="u.display for u in units track by u.code" />

[Original Article]

Otherwise,  when an object is loaded from the server for editing, the lookup values are replaced with pointers to the corresponding objects in the dropdown list. An unsophisticated but functional bit of code to perform this substitution might be:

// Wrapper function to retrieve a product
// from the server, keyed on productId.
apiProduct.lookup(productId, function(product) {
$scope.product = product;

// Replace the server-supplied lookup value
// with the matching value
// in the $scope.units array.
$scope.product.uom = lookup_by_code(product.uom.code, $scope.units);

function lookup_by_code(code, data) {
for(var i=0; i
if(data[i].code == code)
return data[i];

return null;


There is a JSFiddle that demonstrates the value/reference problem concisely.

Tags, , , , , ,

Improve Mac OS X performance under load by disabling spindump.

I push my Mac real hard at times. When the disk is thrashing hard, I’ve noticed a program called spindump that’s running. Here’s what the man page says:

spindump is a tool used by various system components to create hang reports and notify the user of application hangs. … For normal application crashes spindump will display a dialog to alert the console user to the crash and offer the choice to view more details about the crash and/or report the crash to Apple.

On Yan Pritzker’s blog I found some great tips. Patrick suggested the following. (Please ensure it’s all on one line.)

sudo launchctl unload -w  /System/Library/LaunchDaemons/com.apple.spindump.plist

After running this, I don’t see spindump, and the disk isn’t thrashing as hard. Yeah, I’m running two heavy virtual machines that are hammering their virtual disks, but it appears that I’ve gained something.

Thanks, guys!

2009-03-27 Update: Fixed typo. A huge thanks to Rob for catching that.

2011-02-23 Update: It was suggested that I also mention how to reverse this. Use load instead of unload.

sudo launchctl load -w  /System/Library/LaunchDaemons/com.apple.spindump.plist

Tags, , , , , , , ,

%d bloggers like this: