Custom Relative Time with Date Components

Here’s an if chain that figures out the relative time. The current version suites my needs but it’s easy to modify. //print date to countdown_label NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease]; NSDate *fromDate = [NSDate date]; NSDate *toDate = [user filtered_until]; NSDateComponents *components = [calendar components:NSDayCalendarUnit|NSHourCalendarUnit|NSMinuteCalendarUnit fromDate:fromDate toDate:toDate options:0]; NSString *countdown_text = @””; if… Continue reading Custom Relative Time with Date Components

Exporting PDFs in Illustrator

There are a few common issues with saving PDFs in Adobe Illustrator. I experienced these with CS5 (5.1 specifically) but while looking for a fix I saw reports of the same errors from users with CS2, CS3, CS4, and CS6 as well. Commond errors include: “This file cannot be found.” when trying to save a… Continue reading Exporting PDFs in Illustrator

IE8 select element change event not firing with the keyboard

Change events on select elements don’t fire in IE8 when the user confirms the selection with the enter key until the user clicks elsewhere. If your users are waiting on something in particular to happen after updating the select this is a bit of a problem. Here’s my solution: // jQuery syntax for ease of… Continue reading IE8 select element change event not firing with the keyboard

Categorized as Javascript

Getting a particular superview in Objective-C

If you have, for example, a child view of a UITableViewCell and you need to get the UITableViewCell in question you can quickly do something like: UITableViewCell *cell = (UITableViewCell *)the_view.superview.superview; It works but this code is fragile because it requires that the view heirarchy not change (also things like this usually point to a… Continue reading Getting a particular superview in Objective-C

Debugging Javascript with Console

A quick review. Console.log() //how to print a log statement console.log(‘That thing you expected to happen is now happening!’); //how to break production sites in internet explorer console.log(‘anything’); //how to log safer function l(str){if(window.console&&console.log){console.log(str);}} l(‘I can forget this in my code base without breaking anything!’); Console.trace() //how to figure out what’s calling what console.trace(); //console.trace… Continue reading Debugging Javascript with Console