Ruby Nation / Best Practices

2010-03-18 20:00:00 -0400

I’ll be attending this year’s Ruby Nation conference in Reston, VA April 9-10, and I’m quite looking forward to it. The list of speakers and talks is absolutely fantastic, and includes the excellent Nick Sieger, whom I had the pleasure of first meeting at Ruby Fringe in 2008. There are still a couple of open registration seats left if you haven’t signed up yet. If any of the Ruby heads out there want to meet up, I’ll be in town from the evening of April 8th to the morning of April 11th. You can find me on Twitter as @billymeltdown.

I’ve been spending a little time revisiting some of the core concepts and industry practices with Ruby, and recently Bret Morgan of DBL Systems pointed me in the direction of Gregory Brown’s newly published book, Ruby Best Practices. The first chapter alone is excellent, a kind of sermon for Test-Driven Development, and I highly recommend it.

Saying Goodbye to PingMe

2010-03-17 20:00:00 -0400

We have some sad news to deliver to users of the PingMe reminder service. Starting today, we will be blocking new registrations on PingMe, and we have decided to turn off the system permanently starting on April 23rd.

So long, and thanks for all the fish

We believe in working on projects that are sustainable. When we built PingMe, we had very high hopes for it. It was designed from the ground up as a system that was more dynamic and flexible than anything else out there.

We have maintained PingMe for free for as long as possible for all the people that have been depending on it. We love to get email from people who have found the service to be an enormous help in their lives, and it’s partly a sense of responsibility to them that has helped us to keep it up.

Unfortunately, it’s just not a sustainable service in the long-term for several reasons:

  1. PingMe requires continuous maintenance and constant vigilance against abuse by spammers, malicious users, and even inadvertent mistakes. Recently, direct and accidental system abuse cases have been on the rise, to the point that we have almost daily incidents to deal with.
  2. PingMe is a difficult system to support, because of various problems with external SMS gateway providers, cellphone carriers, and email systems. These issues are mostly out of our control, and make it difficult or impossible to troubleshoot and resolve even common problems.
  3. Despite the fact that PingMe is widely used and well liked, it hasn’t grown to the point where we can monetize it or effectively compete with other systems.
  4. We’re a small team, and maintaining PingMe has become an undue burden on other projects that we have brought to market

Switching to Another System

There are plenty of other reminder systems and task managers out there. Each has their own way of doing things. While we can’t recommend any particular system, we encourage you to try out a few and see what else you like.

In order to help you get your data out of PingMe, we’ve added an export feature so you download an Excel/CSV or XML-formatted export of your reminders. We’ve also posted a reference guide to the export data here on our blog.

What does this mean for Zetetic and your other products?

PingMe is the only system we are shutting down. Tempo Time Tracking, Strip Password Manager, Codebook Secure Notepad, etc, will be completely unaffected. We are doing very well as a company, continuing to grow, and approaching our 6th year in business. In fact, the most important reason we are turning off PingMe is so that we can continue to give proper focus to our other products and services.

Thank you

Finally, we want to say thanks to all of our PingMe users for trying the service, providing feedback along the way, and helping to spread the word. We really appreciate it and sincerely apologize for any inconvenience this may cause.

Exporting Reminders From PingMe

2010-03-17 20:00:00 -0400

Last night we made a small update to the PingMe reminder service to make it possible for you to export a listing of your reminders, should you decide you’d like to switch to another service. If you click on the Profile Tab, you will see an “Export” section at the top of the page:

Pingme Export

The export options are straightforward, but I want to describe the CSV and XML formatted output and describe what exactly each of the fields describes, to help anybody looking to massage the data for another system.

CSV Output

CSV (comma separated value) output is suitable for opening in a Spreadsheet program like excel, but it can also be opened with any standard text reader. Field data will be correctly escaped when necessary according to the CSV spec (for instance, when a field contains a comma, line-break, or quote character). The data is UTF8-encoded (not ASCII), but if you try to open the file directly in Microsoft Excel, it may munge the UTF8 characters that extend beyond the ASCII set. Other spreadsheet programs should be able to handle this for you, and help you convert into an actual Excel workbook.

Here’s some example output, with a header row:

172,false,false,22-Jul-2008 17:34,22-Jul-2008 17:34,true,false,check check,22-Jul-2008 17:45,one-time,daily,false,Gmail,0,"",Billy

XML Output

This will produce an valid UTF8-encoded XML document. The root element is <pings type="array" />, and it contains, you guessed it, a list of pings as XML! Type-hinting attributes are turned on, but should be easy to ignore. This is what it generally looks like:

<pings type="array">
<created-at type="datetime">2008-07-22T17:34:04Z</created-at>
<id type="integer">172</id>
<is-active type="boolean">true</is-active>
<is-done type="boolean">false</is-done>
<is-recurring type="boolean">false</is-recurring>
<message>check check</message>
<require-confirmation type="boolean">false</require-confirmation>
<updated-at type="datetime">2008-07-22T17:34:10Z</updated-at>
<is-pestering type="boolean">false</is-pestering>
<pester-interval type="integer">0</pester-interval>
<start-date type="datetime">2008-07-22T17:45:00Z</start-date>

Export Field Guide

created_at – Creation timestamp. Excel format used in CSV output. All timestamps are in UTC.

id – The unique integer identifier of the ping. There are many others like it, this one is yours!

is_active – Boolean determining whether the ping is still “active” in the system. This is only really set to false by the system, not the end-user.

is_done – Whether the ping has been marked by the user as “done”. You can interpret is_active = false and is_done = true to mean the same thing.

is_pestering – Boolean indicating whether or not the reminder is supposed to bug you at a particular interval until you respond.

is_recurring – Determines whether the ping will be rescheduled after it sent at it’s start_date.

message – The contents of the reminder itself

pester-interval – The interval in seconds that a ping should be re-sent until a response is received from the user. Only valid if is_pestering == true.

recurring-frequency – The schedule to be used when is_recurring == true. Can be:

  • daily
  • weekly
  • monthly
  • yearly
  • biweekly
  • mon-fri
  • quarterly

require_confirmation – Boolean setting that, when true, makes the ping a kind of “to-do.” Normally, if a ping has been sent at it’s scheduled time, and it’s not up for rescheduling, it is marked as “done” by the system. However, if require_confirmation is set to true by the user, the ping will not be marked “done” until the user replies to confirm that the task has been completed. This causes the ping to stay on your homepage on PingMe, instead of being archived.

schedule_type – Convenience text describing what kind of ping this is: pestering, repeating, or one-time. Pings that are combined pester-repeat pings are simply marked as “pestering”, so you may wish to consult is_pestering and is_recurring directly.

start_date – The date at which the ping should be scheduled for delivery.

tag_s (tags in CSV output) – A comma-separated list of tags assigned to this ping.

targets_s (targets in CSV output) – A comma-separated list of the targets assigned to this ping (names only).

updated_at – Timestamp indicating when this ping was last modified, by the user or the system scheduler.

users_s (users in CSV output) – A comma-separated list of the users this ping was assigned to, listed by login name. This exists because pings can be shared with more than one user.

Codebook is in the App Store!

2010-03-16 20:00:00 -0400

Codebook IconTime for a little business, friends! We have a new application in the iTunes App Store, and we call it Codebook: A Secure iPhone Notebook for People with Secrets!

Download it now in the iTunes App Store for only $2.99.

My bias being what it is, I recommend that you replace your other notes apps with this elegantly simple notebook that keeps all your data private, and just gets out of the way. Codebook is perfect for attorneys, physicians, journalists — anybody who needs to keep their notes confidential.

Codebook is built on the same rock-solid encryption engine we use for STRIP, SQLCipher. It’s perfect for storing sensitive meeting notes, terrible poetry, anything you want to keep secret should you lose your iPhone or iPod Touch. ALL data stored in Codebook is stored using the robust and peer-reviewed 256-bit AES encryption implementation in OpenSSL.

Screen1 Login

I used to use Apple’s included Notes application a lot myself, but I’m getting less and less comfortable storing stuff in there. Here’s my use-case, since I’ve been using Codebook for a few months now:

Screen3 Edit

I, for one, have a penchant for thinking up lots of bad “lyrics” for my band. I’ll be on the subway reading some radical article in Harper’s, and BOOM, I get this great idea! I fire up Codebook, tap in my password real quick, and tap out my idea. If I want to add it to a previous bit of my wondrous witticisms, they’re incredibly easy to find via the Search feature, or just by going back in time and scanning the titles.

Screen2 List

It may not be totally evident in the screens here, but we opted to use the first line of each note as its title (an idea we got from John Gruber’s writings about the untitled document syndrome, and the Simplenote app), so you don’t have to think of one. It’s just there, it just works.

One last thing we made sure we included: Email forwarding of individual notes. You just might want to mail something out and we wanted to make that easy to do.

Stephen and I started work on this back in February of 2009, and have basically sat on it since while we put priority on Strip. Recently, I took some time to clean it up and get it ready for a proper release. Feels good to finally have it out there in the store. If you give Codebook a spin, let us know what you think!

Hold and Copy in UIKit

2010-02-23 19:00:00 -0500

This article has been cross-posted at, our favorite place to get news and tips about iPhone/iPad development.

Recently, I wanted to implement an interface where a user holds down on a UIView class or subclass to reveal a copy menu. Basically, I didn’t want to have to present the user with a UITextField just to provide the ability to copy some data to the pasteboard. In this case, I’m working with a UILabel, but a similar paradigm already exists in many Apple-supplied apps where one can hold down on an image and be presented with the Copy menu option.

Going in it seemed pretty straight-forward, but it ended up taking me the better part of an afternoon of trial and error alongside the Event Handling section of iPhone Application Programming Guide to work it all out, so I believe a tutorial is in order. A reference project with sample code is available on Github.

Getting a Hold of a Hold

One can easily calculate the length of time a touch was held when the touch ends (by calculating the difference between the timestamp properties of the passed UIEvent and UITouch objects), but I found making this the point of responding to the event less than ideal because it means responding to the user’s interaction after the user lifts her finger, rather than while she is holding down on the screen. I’d rather respond while the user is still holding her finger down to let her know that the instruction was received. If the software will only respond after the user lifts her finger, she has no idea how long she has to hold her finger down, which is a nuisance, really.

Old Cocoa pros and experienced UIKitters probably saw the solution from a mile away: we intercept the touches began event for the view we’re interested in, and tell some object to do something after a long enough delay (the minimum time we want a user to have to hold to do something). We then cancel the request if any of the other touch events fire before our delay hits. That looks something like this, depending on your needs:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *t = [touches anyObject];
if ([t locationInView:someViewWeAreInterestedIn])
[self performSelector:@selector(showMenu) withObject:nil afterDelay:0.8f];

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showMenu) object:nil];

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showMenu) object:nil];

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showMenu) object:nil];

There may be better ways to do this, but this seems pretty solid. In the sample code you can see this at work in the view controller, which shows a hidden image once a user holds down on another image for long enough. Just under a second (0.8s) seemed to feel right to me.

Copylabele Tut Image

- (void)holdingView:(id)view {
[hiddenView setHidden:NO];

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet *imageTouches = [event touchesForView:imageView];
if ([imageTouches count] > 0) {
[self performSelector:@selector(holdingView:) withObject:imageView afterDelay:0.8f];
[super touchesBegan:touches withEvent:event];

Copylabel Tut Showmenu

Implementing a Custom Copy

I feel like there’s real pun-potential for this subtitle, but reasonably groan-inducing text is eluding me. In any event, now that we can detect when a user has held our view long enough to warrant a response, we need to make a move: presenting the UIMenuController with the Copy option and actually copying something in response. I’m sure there are various approaches that can be taken, but my approach was to start by subclassing UILabel, curious to hear other ideas.

First, I wired the subclass to intercept touch events, and to save that touch-down for the extra point (ho!):

- (BOOL)canBecomeFirstResponder {
return YES;

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if ([self canBecomeFirstResponder]) {
[self becomeFirstResponder];
UITouch *t = [touches anyObject];
holdPoint = [t locationInView:self];
[self performSelector:@selector(showMenu) withObject:nil afterDelay:0.8f];

// (other touches* methods implemented to cancel perform) ...

Showing the menu itself is a touch awkward, you need to provide a “target rectangle” (CGRect) to UIMenuController to tell it about where on the screen you want the menu to appear (it can appear above or below this point, depending on proximity to the screen bounds).

- (void)showMenu {
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(reset) name:UIMenuControllerWillHideMenuNotification object:nil];

// bring up editing menu.
UIMenuController *theMenu = [UIMenuController sharedMenuController];
CGRect myFrame = [[self superview] frame];
CGRect selectionRect = CGRectMake(holdPoint.x, myFrame.origin.y - 12.0, 0, 0);

[self setNeedsDisplayInRect:selectionRect];
[theMenu setTargetRect:selectionRect inView:self];
[theMenu setMenuVisible:YES animated:YES];

// do a bit of highlighting to clarify what will be copied, specifically
_bgColor = [self backgroundColor];
[_bgColor retain];
[self setBackgroundColor:[UIColor blackColor]];

Note that I’m registering for a notification: I basically wanted to know whenever the menu disappeared, because that would mean it’s time to stop high-lighting the text in the label, and restore the original background color. Totally not required for getting the menu on screen.

Next we have to make it clear to the UIMenuController that we mean serious business, and what kind of business we intend to conduct. In my case, I was only interested in Copy, but other options are available:

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
BOOL answer = NO;

if (action == @selector(copy:))
answer = YES;

return answer;

And in my case, the data I’m looking to copy is simply the text of the label itself, and I just want to put it on the general pasteboard so the user can paste it into another app, or wherever:

- (void)copy:(id)sender {
UIPasteboard *gpBoard = [UIPasteboard generalPasteboard];
[gpBoard setValue:[self text] forPasteboardType:@"public.utf8-plain-text"];

Secret Image

That’s it!

Zetetic is the creator of the encrypted iPhone data vault and password manager Strip and the open source encryption-enhanced database engine SQLCipher.