Archive for the ‘Uncategorized’ Category

Launch at Login Controller for your Mac Cocoa App

Thursday, March 25th, 2010

Ever needed your Cocoa/Objective-C application to Launch at Login? And also have your app appear in your users System Preferences > Accounts > Login Items list? Want this integration to be super-mega-piss-easy?

Well now you can.

We’re going to wrap LSSharedFileList to get our App to start at login – a Cocoa solution – as opposed to other solutions that use Carbon or having to edit XML system pref files.

Take a look at Github – Launch at Login for the source. Don’t forget to look at the readme for assistance for implementation.

Basically copy the LaunchAtLoginController.h/.m files into your project then either you can implement with Code or with Interface Builder.

Code

Will app launch at login?

LaunchAtLoginController *launchController = [[LaunchAtLoginController alloc] init];
BOOL launch = [launchController launchAtLogin];
[launchController release];

Set launch at login state.

LaunchAtLoginController *launchController = [[LaunchAtLoginController alloc] init];
[launchController setLaunchAtLogin:YES];
[launchController release];

IB

Easy right?

So what are you waiting for? Grab the code from Github – Launch at Login

iPad User-Agent String

Tuesday, February 23rd, 2010

At least just for my own notes here’s some iPad/iPhone user-agent string:

iPad 3.2 beta 2 (7B320c)

mozilla/5.0 (ipad; u; cpu os 3_2 like mac os x; en-us) applewebkit/531.21.10 (khtml, like gecko) version/4.0.4 mobile/7b320c safari/531.21.10

iPhone 3.1.3 (7E13) – Simulator

mozilla/5.0 (iphone simulator; u; cpu iphone os 3_1_3 like mac os x; en-us) applewebkit/528.18 (khtml, like gecko) version/4.0 mobile/7e18 safari/528.16

BlackBerry and their Video Playback Capabilities

Tuesday, February 2nd, 2010

Here’s a list of BlackBerry Smartphones, their model, name, screen resolution and their video playback capabilities.

H.264 notes

It’s often difficult to determine the specific H.264 profiles that a BlackBerry can support, such as what’s the max bit-rate the device can handle? Looking at the specification pages for each model can assist; such as Bold 9700 specs

It’s a pretty safe bet to encode for baseline profile for a video, otherwise you might see a blank screen when you try and play it back. Take a look here for more on ffmpeg encoding for BlackBerry.

BlackBerry Models and capabilities

Blackberry® Model Resolution
BlackBerry 8100 240×260 MPEG4 Pearl
BlackBerry 8110
BlackBerry 8120
BlackBerry 8130
BlackBerry 8220 240×320 MPEG4 Pearl Flip
BlackBerry 8230
BlackBerry 8300 320×240 MPEG4 Curve
BlackBerry 8310
BlackBerry 8320
BlackBerry 8330
BlackBerry 8350i
BlackBerry 8520 320×240 H.264 Curve
BlackBerry 8530
BlackBerry 8800 320×240 MPEG4
BlackBerry 8820
BlackBerry 8830 320×240 H.264
BlackBerry 9000 480×320 H.264 Bold
BlackBerry 9500 360×480 H.264 Storm
BlackBerry 9530
BlackBerry 9550 360×480 H.264 Storm 2. OS 5.0
BlackBerry 9520
BlackBerry 9630 ? H.264 Tour
BlackBerry 9700 480×360 H.264 Bold 2. OS 5.0

Blank values mean they carry down from the model prior.

Using ffmpeg for BlackBerry Bold playback

Tuesday, February 2nd, 2010

Sometimes ffmpeg just doesn’t play like you’d hope it would. I was trying to re-encode video clips for a BlackBerry Bold (the Bold supports H.264 playback) but every encode would have a blank black screen for video, and the audio would be fine (more on audio later).

I’m currently using SVN release r19352 (and also tested with r21566 (2010-01-31)).

ffmpeg arguments for BlackBerry H.264

ffmpeg -v 0 -y -i input.mp4 -f mp4 -aspect 2.409 -vcodec libx264 -vpre default -vpre baseline -s 480x200 -r 24 -b 220k -acodec libmp3lame -ab 24kbit/s -ac 1 output.mp4

So lets break down these arguments:

-v 0 = Set verbosity level
-y = Overwrite existing file
-i input.mp4 = The file you want to convert
-f = Force the video type
-aspect = The magical number to get the resize right
-vcodec libx264 = We're going to use x264 for video codec
-vpre default
-vpre baseline = Magical presets. And ensure BlackBerry compatibility
-s = The final dimensions of the clip
-r = Video frame rate
-b = Bitrate per second (the larger number the better the video)
-acodec libmp3lame = See Audio heading below
-ab = Audio bitrate
-ac 1 = Number of Audio Channels
output.mp4 = The output file

-vpre isn’t working for me (and I’m on Windows)

ffmpeg isn’t a Windows only application and looks for its presets in /usr/local/share/ffmpeg/ so if you create a folder structure on your Windows computer c:\usr\local\share\ffmpeg\ and copy all the *.ffpreset files into said folder you won’t have problems with -vpre anymore

Audio issues (AAC)

In later releases of ffmpeg AAC (or libfaac) was disabled; I assume due to AAC being patent encumbered. There’s ways around turn libfaac back on, or you could just switch to using libmp3lame or the like.

Bandwidth: Rackspace Cloud Server vs Rackspace Files

Friday, November 20th, 2009

I’ve recently been looking at hosting a complex JBoss/Apache project at Rackspace Cloud as opposed to our own servers+pipe at work.

I had changed the application to deliver the files from a CDN (in this case Rackspace Files) but thought “well Rackspace Cloud might be on the same pipe(s) as Files and could kill two birds with one stone”.

Essentially I wanted to know the pipe difference between Rackspace Cloud Servers and Rackspace Files and if Cloud was fast enough do away with Files.

The Test

Here’s some very rudimentary results where I download a 9.6 MB zip file.

Rackspace Cloud – Average download speed: 335 kb/s – Time: 27 seconds.
Rackspace Files – Average download speed: 1154 kb/s – Time: 8 seconds.

I used curl -O http://.../content.zip for the download test.

Conclusions

Rackspace Cloud doesn’t use the same “pipes” as Rackspace Files (I’ve never read that Rackspace claim, “Cloud is as fast as Files” I wasn’t expecting the same results, just curious).

A dedicated CDN is the best way to go for delivery of large files quickly. (Rackspace Files uses the Limelight Network). I’ve heard rumours that Rackspace has Australian edge(s) and this seems to be the case.

I will still want to use Rackspace Files for large content delivery.

Misc

I use TPG ADSL2+ at home and never seen downloads faster than 1250-1300 kb/s. Using a 2.16GHz Macbook Pro.

At the time of writing: Rackspace Cloud Server is a cloud server hosting infrastructure. Rackspace Files is a Content Delivery Network.

Fixing Visual Studio’s error ‘The project location is not trusted’

Tuesday, September 29th, 2009

Scenario: My base machine (mac) hosts all my source code as I want a single code point to backup. My Windows development environment is in a Virtual Machine using VMWare Fusion. (I believe this issue will apply to VMWare Workstation, Player and Fusion).

I am using the VMWare built in “Share Folder” option, and I’m sharing only the “win” folder in my ~\src\ folder.

Screen shot 2009-09-29 at 10.19.55 PM

Issue: When trying to open source using Visual Studio 2008 I’m presented with the dreaded “The project location is not trusted” error.

Solution: Open a Command-Line box (Start > Run > cmd > OK)

cd \Windows\Microsoft.NET\Framework\v2.0.50727
caspol -m -ag 1.2 -url \\.host\* FullTrust

If you’re not using VMWare or have a share elsewhere substitute “\\.host\*” for your shared folder.

References: The project location is not trusted dialog box and The project location is not trusted dialog box when trying to use a Network Location

Sql Compact and Fluent NHibernate

Thursday, August 6th, 2009

I wanted a drop dead simple Fluent NHibernate connection to a Sql Compact (.sdf) file and was able to use:

?View Code CSHARP
private const string DbFile = "firstProgram.db";
 
return Fluently.Configure()
    .Database(MsSqlCeConfiguration.Standard.ShowSql().ConnectionString(c =>
        c.Is("data source=" + dbFile))
        )
    .Mappings(m =>
        m.FluentMappings.AddFromAssemblyOf<Program>()
        )
    .ExposeConfiguration(BuildSchema)
    .BuildSessionFactory();

Whereas the Sqlite connection was:

?View Code CSHARP
private const string DbFile = "firstProgram.db";
 
 return Fluently.Configure()
    .Database(SQLiteConfiguration.Standard
        .UsingFile(dbFile)
        )
    .Mappings(m =>
        m.FluentMappings.AddFromAssemblyOf<Program>()
        )
    .ExposeConfiguration(BuildSchema)
    .BuildSessionFactory();

When Googling I wasn’t able to find any samples so I hope to fill that void.

Super easy UIViewControllers and their nib/xib

Thursday, May 21st, 2009

I don’t like initialising my UIViewControllers and their associated nib explicitly using a string

FlipsideViewController *viewController = [[FlipsideViewController alloc]
 initWithNibName:@"FlipsideView" bundle:nil];

But would rather my UIViewControllers know how to load themselves. This reduces the possibilities of typos, allows for only 1 place in code where your nib is referenced by name, and just looks better.

For example in FlipsideViewController.m I would add:

- (id)initWithNibName:(NSString *)nibNameOrNil 
bundle:(NSBundle *)nibBundleOrNil {
  if ((self = [super initWithNibName:@"FlipsideView" bundle:nibBundleOrNil]))  {
    // Initialization code		
  }
  return self;
}

Now you can simply initialise the ViewController using

FlipsideViewController *viewController = [[FlipsideViewController alloc] 
init];

Who’s Ben Clark-Robinson?

Wednesday, May 20th, 2009

Mozketo blog is written by Ben Clark-Robinson about Cocoa development, Apple and my adventures in .net. (A strange mix, yes).

Ben Clark-Robinson

I am a c# .net software engineer by day, though once the sun sets low below the horizon and the Apple startup sequence chimes I am transformed into a Cocoa & Cocoa Touch engineer.

I have a diploma in IT and a degree in IT major Software Engineering.

Bits and pieces i’ve worked on

Websites: Mozketo (this site) or WGA.

Web applications: Servizio (Windows Mobile)

Desktop application: Membership

mrp01_s

Home computer setup

Macbook Pro with external 22″ Benq LCD, bluetooth wireless Apple keyboard, MS Notebook Mouse 5000, and my well loved iPhone 3G.

Favoured Apple Software

CSSEdit
TextMate
Transmit
Aperture
Voodoo Pad
LittlesnapperQuicksnapper profile

Server related

Using a Joyent shared hosting server and Wordpress with a custom Mozketo template.

Bluetooth Mouse for Mac OS X

Thursday, March 12th, 2009

I’m trying to find the best Bluetooth Mouse for Apple Mac OS X. I really like being able to just turn on a mouse and boom it works without having to plug in a dongle. So I’ve compiled a mini-review of the Bluetooth mice I’ve tried to date and hoping you could help me expand the list. (more…)