Blog

99¢ Sale

The Cartographer iPhone App Google Maps The Cartographer is on sale for a limited time for 75% off its regular price. 99¢ is all it takes to travel the world with personalized, annotated, customized Google maps! Go forth and be frugally itinerant!

Tagged , , , , | Leave a comment

Sparrow users beware: Bug sends prior draft instead of latest email version

Update: The Sparrow guys tell me they’ve found and nailed the bug, and will release the fix in 1.4 in late September.

I’ve just discovered a critical issue with Sparrow that I thought others should be warned of. It just bit me, big-time, when in the middle of an important negotiation with a third party, an earlier unpolished draft was sent out instead of the final email, when I experienced a momentary Internet connection dropout.

Sparrow has an issue where hitting “Send”, in unreliable network conditions, on a draft message that has been modified, results in a prior copy of the message being sent, rather than the latest version.

To replicate this issue reliably:

  1. Create a new message (Cmd-N)
  2. Specify a recipient (oneself), subject, and some body content (say, the letter “A”)
  3. Hit “Save”, to save the draft
  4. Change “A” to “B”, then disconnect the network connection (in my case, turning off the radio on my external WiFi adapter), then hit “Send”. Sparrow will report a failed connection, and will keep the outgoing message with state “Pending”
  5. Restore network connection. Upon detecting the restored connection, Sparrow will proceed to send the message
  6. Check email. Received test email will have “A” in the email body.

Scary stuff. I hope they’ll fix this soon, but it’s going to make the app difficult to trust in future!

Update: I should mention, a probable workaround for this is to never, ever hit “Send” until you’ve saved the draft, and verified that the save operation has completed (perhaps even restart the app first).

Tagged , , , , | 2 Comments

Seamlessly manage portrait and landscape view controller layouts

A headache-inducing scenario: I’m working on a view controller, and I realise that in order to support landscape and portrait modes, I’m going to need to provide two different layouts.

So, I create two different views within the nib, one portrait, one landscape, each with the same view hierarchy, but with a different layout.

When the orientation changes, I set self.view to the appropriate view. I initialise both views on load, and keep both of them synced to properly reflect the app’s state — basically, I’m double-handling everything, which bloats my code and increases the chance I’ll make a mistake.

So, here’s an easier way: Rather than maintaining two separate view hierarchies and switching between them when the orientation changes, why not just change the layout of one single view hierarchy? The only changes between the portrait and landscape views are layout changes, so if we can extract just the layout information from each view, then we don’t have to worry about maintaining both view hierarchies.

Basically, we’re talking about using each view version as a layout template only.

That’s what TPMultiLayoutViewController class does. It’s a drop-in UIViewController subclass that automatically manages switching between different view layouts for portrait and landscape orientations, without the need to maintain view state across two different view hierarchies.

It works by defining portraitView and landscapeView outlets which it traverses upon loading the nib. It matches each subview element to its counterpart in the other layout (based on tag, target/action, title, etc.), and stores just the layout attributes of each element.

Then, when the orientation changes, the view hierarchy is traversed and these layouts are applied to each subview.

To use it,

  1. Set the superclass for your view controller to TPMultiLayoutViewController.
  2. In Interface Builder, create two different views: one for portrait orientation, and one for landscape orientation.
  3. Attach your portrait orientation root view to the “portraitView” outlet, and the landscape orientation root view to the “landscapeView” outlet.
  4. Attach one of the views (whichever you prefer) to the “view” outlet, and connect any actions and outlets from that view.

Grab it from the TPMultiLayoutViewController GitHub repository, and let me know what you think.

Tagged , , , , | 4 Comments

Personalising AddThis’s Tweet Button

AddThis is a quite useful WordPress plugin for adding a host of sharing options to your blog posts.

By default, the “Tweet” button that AddThis provides will append “via @AddThis” to the end of tweets, which seems to me a little uncool, given that it’s your content.

So, here’s a little plugin that lets you specify your own Twitter account name instead of @AddThis.

The principle is simple: AddThis were kind enough to define their own filter for the plugin’s output. The plugin plugs itself into this filter, and makes an adjustment to the Tweet button.

To use it, put addthis-modifier.php into your wp-content/plugins folder, open it up and set your twitter name where indicated. Activate it, and you should be good to go.

Download the plugin: AddThis Modifier Plugin

For extra marks: Here’s some code you can use to replace line 14 (the $twittername = … line) to provide a different Twitter account for each post author. Is that not awesome?:

    $accounts = array('Michael'   => 'MichaelTyson',
                      'Katherine' => 'NellieWindmill');
    $twittername = $accounts[get_the_author()];
Tagged , , , , | 2 Comments

Supporting WordPress shortcodes and captions in MarsEdit preview

I noticed that WordPress these days uses a shortcode to define image captions, of the form:

[caption id="" align="aligncenter" width="630" caption="Image title goes here"]<img src="http://domain.com/imgpath/../image.jpg" width="630" height="420" />[/caption]

I’ve recently redone our blog template at Technomadics, and while setting up the new preview template in MarsEdit, thought I’d take a stab at implementing support for captions, too, via some javascript in the template.

I was successful! Here’s how I did it:

Added the following to the “head” section:

<script type="text/javascript">
var prior_content;
function watch_for_changes() {
  var check = function() {
    var elt = document.getElementById('content');
    if ( elt.innerHTML != prior_content ) {
       elt.innerHTML = apply_filters(elt.innerHTML);
	   prior_content = elt.innerHTML;
    }
    setTimeout(check, 100);
  };
  setTimeout(check, 100);
}
 
function apply_shortcode(source, name, callback) {
   return source.replace(new RegExp('\\[' + name + '\\s*([^\\]]*)\\]((.|[\s\n])*?)\\[/' + name + '\\]', 'g'),
                         function(match, paramString, content) {
                           params = new Object();
                           reg = /([a-z]+)="((:?="[^"]+"|[^"])*)"/gi;
                           while ( (match = reg.exec(paramString)) != null ) {
                             params[match[1]] = match[2];
                           }
                           return callback(params, content);
                         });
}
 
function apply_filters(html) {
  html = apply_shortcode(html, "caption", function(args, content) {
     return '<div '+
               'class="wp-caption ' + (typeof(args.align) != 'undefined' ? args.align : '') + '" '+
               'style="width: ' + args.width + 'px;">' + content +
             '<p class="wp-caption-text">' + args.caption + '</p></div>';
  });
 
  return html;
}
</script>

…changed to ‘body’ tag to…

<body onload="watch_for_changes();">

…And wrapped a div around the main “#body#, #extended#” content with an id of content:

<div id="content">
#body#
#extended#
</div>

Basically, it polls the content area for changes, and when triggered, runs it though a filter. The above is extensible, and by adding additional “apply_shortcode” calls from “apply_filters“, more shortcodes can be simulated.

Tagged , , , | Leave a comment

Loopy 2.0.1 coming soon, with noise gate/expander, more

Loopy 2.0.1 Screenshots We just submitted Loopy 2.0.1 to the App Store!

Update: It’s now available!

The new version includes:

  • Full-featured noise gate/expander, with auto-calibration
  • Bigger panel and clock controls
  • Document support: Import loops from Mail and other apps
  • Play/pause button on main screen (great for breaks)
  • Option to add track to Loopy’s SoundCloud group when publishing
  • Many more improvements and bug-fixes

Expect it to land in a week or so. Now, off to work on the next version..

Tagged , , | Leave a comment

Hey Just J reviews and demos Loopy

Here’s a review and great little demo of Loopy version 2 by looper Hey Just J:

Tagged , , | Leave a comment

Dub FX and Loopy 2

Check it out:

Tagged , , | Leave a comment