I found this little gem in a template in my company’s application today. It was written in 2011 by someone with the title of Senior Software Engineer. Seriously. I’m not even kidding. This is real. It should come as no surprise this brain dead hack doesn’t work with Mobile Safari and that’s what I’m tasked with fixing. I opened the template in my editor and saw this! One hundred and fifty-six non-breaking spaces. I had to cut some out for the purposes of this post.
<% else %>
<% end %>
I hung my head in exasperation for a couple of minutes before looking back up. It was still there. Somebody actually put this into a template in 2011. CSS exists for a reason. You might think a Senior Software Engineer who claims over 15-years of experience would ask someone if there was a better way to do this before pasting 156 times.
If you ever wanted to know where on your Mac the iOS Simulator application is located it’s here.
/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator
Unless you’re working with Xcode 4.3.2 or later of course. Recent version of Xcode is now a regular application in the Applications folder and related utilities are bundled in with the app package. You need to right-click Xcode.app and select ‘Show Package Contents’. Then the path to the simulator is here.
/Applications/Xcode.app/Contents//Developer/Platforms/
iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app
Once iOS Simulator is running you can move its position in the Dock in order to make it stay in the Dock after you quit it. Then you can run the iOS Simulator by itself that way without going into the Xcode package. Of course, there may be other ways by creating aliases but the Dock is the way I’ve done it for now.
It’s also called iOS Simulator despite the fact ‘iPhone’ exists in the path. You can always launch the iOS Simulator as a stand alone application with Spotlight. This can be useful for testing websites in Mobile Safari without having to look over/down at your device all day.
Microsoft Word is cumbersome, inefficient, and obsolete. It’s time for it to die. - Slate Magazine -
A Word file is the story-fax of the early 21st century: cumbersome, inefficient, and a relic of obsolete assumptions about technology. It’s time to give up on Word.
(via my new Ace Boo from NOLA, Derek)
If the trailer for Wrath of the Titans were lengthened a bit and made the official music video for Marilyn Manson’s Sweet Dreams it would be awesome music video. However, as a movie, I have no interest in it.
Lion’s Auto Save: If it ain’t broke, fix it -
This article does a great job of pointing out some of the problems with Lion’s autosave feature. I very much agree there’s no reason for autosave and the Save As menu item to be mutually exclusive. The Duplicate menu item just doesn’t cut it for me.
Another problem is how autosave is integrated with versions. I would very much like to just work in a document and not have to think about saving. At all. Period. But as soon as you start typing the title bar changes to have ‘Edited’ at the end. If I press ⌘S now what really happens is the current state of the document is tagged as a ‘version’. However, I don’t use versions and having ‘Edited’ in the title bar really bothers me. It makes me feel like the document is in an inconsistent state and I need to do something make it right. Like pressing ⌘S. It’s uncharacteristically inelegant for Apple software and something I really hope they address in Mountain Lion.
As simple as it may seem it may not be immediately obvious how to add a subview to a view and have that subview be backed by a nib file. Naturally, I created a dead-simple demonstration of exactly how to add a sub view to a view in an iOS application where the sub view is connected to a nib file.
Note, you can use a UIView object as a sub view but not a UIViewController object. First, create a UIView class. Unlike UIViewController subclasses you won’t have the option to create a nib file to go along with it. This is fine. Create the nib file by itself as a separate step. Open the nib file and go to the Identity Inspector for the top-level view object. Change the custom class to the corresponding view class you just previously created. For this example, place a UILabel in the view and create an outlet for it in the corresponding view class. Now you can place this as a sub view in any view you want to and can change the label programmatically as well.
// Create an instance of UIView (FooView).
FooView *fooView = [[[NSBundle mainBundle] loadNibNamed:@"FooView" owner:self options:nil] objectAtIndex:0];
// Tell it where to go. Otherwise, it'll appear in the upper left corner.
fooView.frame = CGRectMake(10, 150, 300, 90);
// Modify the text of the label.
fooView.fooLabel.text = @"Modified Label Text";
// Actually add the subview.
[self.view addSubview:fooView];
Using a nib file may be overkill if it contains nothing but a UILabel but you can image how something more complex might be used in a real application. If you want to see this code in action check out the GitHub project.
I don’t do Apache configuration very often so when I do it I like to document what I did for future reference. Today I was asked to set an Expires header on some content so browsers wouldn’t hold onto old copies for so long. First, you’re going to need to know how to view content headers in Safari 5.1 if you’re using Safari.
Enable the mod_expires module if it isn’t already. The path may be different depending on your installation.
LoadModule expires_module /usr/lib/apache2/modules/mod_expires.so
I put this inside a directory block on my site’s configuration. This way it’ll only affect the files within a specific directory. If you use .htaccess files then this configration would go in that.
ExpiresActive On
ExpiresDefault "access plus 30 minutes"
For other ExpiresDefault options see Apache’s documentation.
Apple changed where you go to view HTTP headers with Safari 5.1.
Apparently, I’m working blue this evening.
Databases have the ability to enforce data integrity rules for a reason. One application is not the only thing that can affect data in a database. If you depend solely on application logic to enforce data integrity you’re setting yourself up for problems later.