Home | Account | Search  
Mac :: Run software update from the command line
This has been around awhile, but is new to me.

Run software update in Terminal so you don't get a popup.

sudo softwareupdate -i -a

This will install all available updates.
Appcelerator :: Renaming your application
It's not a straightforward process to modify the name of your Titanium application. Here's a workaround that makes the pain go away:
  1. Copy info.plist from your build/iPhone folder to the project root.
  2. Edit the string value for CFBundleDisplayName to be the desired title for the app on the device.
  3. Delete the files (not subfolders) in the build/iPhone folder 4. Re-launch the app in the simulator (forcing a rebuild)
  4. Check the (regenerated) info.plist file in ‘build/iPhone’ contains the updated CFBundleDisplayName key value.
Flex :: Connecting to the Debugger
There are occasions where debugging from the Flex/Eclipse IDE isn't possible. When this occurs, instead of resorting to Alert or logs, you can attach the debugger to a running application (standalone SWF). The debug version of the Flash player is required for this to work (Debuggers located here).

Click the arrow next to "Debug", go to "Debug Configurations" and create a new launch configuration. Uncheck and delete the default value in “URL or path to launch” and enter a non-existent URL like “http://localhost/foo.swf”. Now click “Debug” at the bottom right of the dialog box. A browser will open and result in 404. You can now go to or launch the standalone SWF, right click and "connect to debugger" at localhost. The IDE should then link up into your code and you'll have a debugging session. Set your breakpoints and have a happy coding session! =)
Java :: Use goo.gl URL shorten from Java
Google API news: the company recently announced an API for its URL shortening service "goo.gl". Developers can use the API to integrate shortened goo.gl URLs into their own projects. It's a RESTful JSON API (documentation is here). I couldn't find an example written in Java, so here is my contribution:

private String googUrl = "https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/fbsS&key=<YourAPIKey>";

public String shorten(String longUrl)
    String shortUrl = "";

        URLConnection conn = new URL(googUrl).openConnection();
        conn.setRequestProperty("Content-Type", "application/json");
        OutputStreamWriter wr =
                     new OutputStreamWriter(conn.getOutputStream());
        wr.write("{\"longUrl\":\"" + longUrl + "\"}");

        // Get the response
        BufferedReader rd =
                     new BufferedReader(
                     new InputStreamReader(conn.getInputStream()));
        String line;

        while ((line = rd.readLine()) != null)
            if (line.indexOf("id") > -1)
                // I'm sure there's a more elegant way of parsing
                // the JSON response, but this is quick/dirty =)
                shortUrl = line.substring(8, line.length() - 2);

    catch (MalformedURLException ex)
                                         Level.SEVERE, null, ex);
    catch (IOException ex)
                                         Level.SEVERE, null, ex);

    return shortUrl;

iPhone :: Disable autocompletion on UITextField
In Interface Builder, in "Text Input Traits", set "Correction" to NO.

To achieve the same using Obj C:
theUITextField.autocorrectionType = UITextAutocorrectionTypeNo;
iPhone :: Get the UUID
Here's how to get the device's unique identifier:

UIDevice *device = [UIDevice currentDevice];
NSString *uniqueIdentifier = [device uniqueIdentifier];
iPhone : Skip the multitasking and exit your application
iPhone multitasking is added complexity for some applications. To keep your application from participating in the psuedo-multitasking on iOS:

1) Open your info.plist file
2) Add the key UIApplicationExitsOnSuspend or select "Application does not run in background"
3) Set the new key to yes

applicationWillTerminate will be run when the user clicks the home key, and your app will terminate.
Java :: Fibonacci Numbers
I was recently asked to generate Fibonacci numbers based on a given index in an interview and wasn't able to come up with the answer off the cuff.

Using Recursion
public int fib( int n ) 

if ( n < 2 ) return n;
return fib( n - 1 ) + fib( n - 2 );

Using Iteration

public int fib( int n )

int prev1 = 0;
int prev2 = 1;
int savePrev1;

for( int i = 0; i < n; i++ )
savePrev1 = prev1;
prev1 = prev2;
prev2 = savePrev1 + prev2;

return prev1;
Flex :: Get Unix Timestamp
private function getTimestamp():Number
return Math.round(new Date().getTime()/1000);

Adobe vs Apple
I'm admittedly very biased, but this Apple vs Adobe benchmark is pretty interesting.
Google Fonts
Another awesome contribution to the web world from the Google.

Jamie Oliver's TED talk about our eating habits
Dump your MDD generated Hibernate classes
Flex (soon to be "Flashbuilder") has model driven development utilities, which generate Java/Hibernate byte code, but, in order to facilitate model deployment without server restart, they are not persisted to disc. If you need to see the generated classes, add the following markup to the annotation section of your model (.fml) definition:

<item name="JavaClassDirectory">/Applications/tomcat/modelGeneratedClasses</item>

On server restart, the generated files will be physically written to the specified location.
IPhone Development :: Unity3D Indie is now FREE!
I'm looking at the Unity3D interface!! If it is as amazing as all the information I've read, I'll buy the Pro version. It is really nice to be able to spend some time with it first, before making a sizable investment in the tool. Kudos to Unity3D for making this available!
Fedex Tracking App
Over the past year, I've been working on some very exciting and bleeding-edge Flex/LCDS projects with R&D at Fedex with Adam Mollenkopf. One of those concepts has been presented at several conferences. It demonstrates the real time data push capabilities of LCDS combined with a useful enterprise business requirement and was recently demonstrated at AdobeMAX in the day 2 keynote (runs from 16:50 - 24:00)

Dan Pink on the surprising science of motivation
One of my favorite videos from TED - Dan Pink on motivation
iPhone Dev :: No provisioned iPhone OS device is connected (again)
If you updated your iPhone firmware to 3.1 (7C144), you might see the same problem with XCode that 3.0.1 presented (described in this link).

To resolve this, open the Terminal and:
cd /Developer/Platforms/iPhoneOS.platform/DeviceSupport

Then create a link back to the 3.0 SDK:
ln -s 3.0\ \(7A341\) 3.1\ \(7C144\)

You should then see a green indicator instead of a yellow one in the Organizer and should be able to deploy to your device again.
My 30 ft tall Flex Application
One of the recent applications I developed on was presented by Adam Mollenkopf at the 2009 ESRI user conference. It was very cool to see work I was involved with on such a huge display!

Tomcat, Snow Leopard, and the -d32 option
If you've installed the new Mac OS and have found Tomcat failing to push BlazeDS/LCDS messages or just not functioning like it was previous to the upgrade, try adding the "-d32" flag to the Java call inside catalina.sh.
JAVA_OPTS="$JAVA_OPTS -Xms256m -Xmx512m -d32"

This tells the JVM to use the 32-bit model, if available. Also, since we get Java 1.6 with Snow Leopard, don't forget to update your JAVA_HOME in setclasspath.sh to:
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"

Adobe is aware of the -d32 problems ~

iPhone Dev: Keep the iPhone from going to sleep

Use this code to prevent the iPhone from dimming its screen. Note that keeping the device un-dimmed increases battery consumption...

[UIApplication sharedApplication].idleTimerDisabled = YES;