Change the status message of a HP LaserJet printer

January 22, 2007

This is an old trick, but always fun. It’s easy to change the status message on a networked HP printer; just telnet to the printer’s IP address on port 9100, and type the following:

@PJL RDYMSG DISPLAY="YOUR MESSAGE HERE"

Press enter, and you’re done; the new status message will stick around until you change it back, or someone restarts the printer.

Feed Me A Cat

If you want to put some effort into it, maybe make an agent to change the message at a random interval, you can also write an application to accomplish the same thing. See here for an example in C#.

Memory management regular expression search for Cocoa

January 15, 2007

From Domain of the Bored:

/^retain$|^(alloc|new)|[cC]opy/

ObjectAlloc can be a useful tool for detecting memory leaks, but a simple search is just as good (and probably easier) for catching the really stupid memory management mistakes. (via CocoaBlogs)

Display dynamic referrer URLs in Google Analytics

January 15, 2007

Reuben Yau tells us how to make Google Analytics report the full URL for dynamic referrers. In other words, the referrer will show up as /forums/showthread.php?t=1234 instead of /forums/showthread.php (which is more or less useless). This is a good trick if you use Google Analytics; lack of dynamic URL reporting was a major reason why I switched to Mint last year.

More on iPhone software development

January 12, 2007

More on third party iPhone development, from The New York Times:

“We define everything that is on the phone,” [Jobs] said. “You don’t want your phone to be like a PC. The last thing you want is to have loaded three apps on your phone and then you go to make a call and it doesn’t work anymore. These are more like iPods than they are like computers.” The iPhone model, he insisted, would not look like the rest of the wireless industry. “These are devices that need to work, and you can’t do that if you load any software on them,” he said. “That doesn’t mean there’s not going to be software to buy that you can load on them coming from us. It doesn’t mean we have to write it all, but it means it has to be more of a controlled environment.”

Going by the last paragraph, it’s a pretty wide-open answer; you might be able to buy additional applications from Apple, that may or may not have actually been developed by Apple? In any case, it’s not looking good for the “indie” OSX developer. Disappointing; since as I said before, I would really like to try writing handheld software using Cocoa.

Marware iPod Nano cases

January 11, 2007

Looking at Marware’s iPod Nano products today, I can’t helped but be a little impressed. I already own the Sportsuit Sensor+ (which lets you use the Nike+ kit with any pair of running shoes), and I’m probably going to purchase one of their Sportsuit cases soon. Unlike just about every other armband-style case I’ve seen, these are worn around the forearm or the wrist. This makes sense, because that’s really the only way you’re going to use a Nano without stopping; trying to look at a Nano’s screen while running when it’s strapped to your upper arm just doesn’t work well at all.

MacFUSE

January 11, 2007

A lot of people are talking about MacFUSE, released today for OSX. From Ars Technica:

FUSE was originally developed in the Linux world as a filesystem (like what you browse in the finder, or over the network from your Windows machine) that's implemented in userspace. This means that you can load and unload new filesystems without having to deal with messy kernelmode stuff. The pluggable nature and its accessible API means that it's super simple for programmers that aren't rockstars to write filesystems for, well just about anything. There are even ways to write modules in the best programming language of all time, Python!

MacFUSE supports many filesystems, notably NTSF, remote FTP and remote SSH. For a lot of people this is more than enough to be excited about, but I’ve always been fine with SMB, Transmit and scp; lack of filesystem support has never been on my list of complaints about OSX.

The part that interests me is that a FUSE filesystem doesn’t really need to represent actual files, it can be any sort of data store. I haven’t looked through all the plugins yet, but a few examples are connecting to Flickr or Gmail. Take it a step further, and there’s no reason you couldn’t make a plugin to interface with an SQL database, or Active Directory objects, all directly through Finder. I haven’t decided yet if it would actually be useful, but this type of integration is certainly cool. It’s just up to the plugin developers to find good uses for it.

My understanding right now is that MacFUSE isn’t completely stable yet, and you can expect to beachball finder once or twice if you decide to try it. It’s still not bad at all for a first release, and it will be interesting to see what comes out of this in the future.

iPhone Software Development?

January 09, 2007

The big news at MacWorld today is, of course, the new iPhone. The keynote certainly didn’t disappointed, and there’s a lot to talk about and speculate over in the coming months before it’s released to stores. From a user’s point of view I’m certainly eager to try one out first hand, but what really interests me is development. Not only will the iPhone run OSX, but it will support “desktop class” applications, and seems to have some pretty powerful hardware behind it.

Now, it’s really unknown what you will and won’t be able to do with the iPhone, but assuming it supports third party development at all, it’s not unreasonable to expect it to use a Cocoa development environment. Given all the hardware behind it, I doubt there would be much you couldn’t do on an iPhone that you could in a normal, desktop Cocoa application.

The more I think about this, the more excited I get. I’ve been meaning to get back into developing mobile applications, but the complexity of writing software for the Windows Mobile OS ((The .NET compact framework does make developing WM applications a lot easier than with the WinCE API, but there’s still a bit of a barrier to getting started.)) and the fact that I’ve been busy with OSX software has really kept me from doing anything significant. I have a few ideas for some mobile applications I haven’t seen anywhere else, and it would be great to be able to implement them in Cocoa.

Even for Cocoa developers who don’t have much of an interest in handheld software, it would be extremely easy to port a lot of existing applications. Imagine buying Delicious Library, and having the option to install an iPhone version along with the desktop app. Your library would be kept synchronized of course, and the iPhone version would still have all the features, graphics and refinements in the desktop version, including barcode scanning with the built-in 2MP camera.

That’s the kind of thing I’m really looking forward to.

Update:

tuaw reports the iPhone won’t allow third party applications. Disappointing if it’s true, but it’s really far too soon to know anything for sure yet.

Turn on font smoothing in Xcode

January 05, 2007

Using TextMate the past month, I’ve come to realize that I like font smoothing turned on when writing code. Although there’s a setting for font smoothing in System Preferences, Xcode doesn’t seem to respect it if you’re still using the default editor font, Monaco 10pt. The problem isn’t actually with Xcode; OSX uses a separate setting when dealing with fixed width fonts like Monaco. You can change this by running a terminal command:

defaults write .GlobalPreferences AppleSmoothFixedFontsSizeThreshold 4

Replace 4 with whatever minimum font size you like. Of course, you could use the same setting to turn off font smoothing, if you like the jagged look with large font sizes. You can make this setting specific to Xcode by replacing .GlobalPreferences with com.apple.Xcode.

Forget Me Not

December 29, 2006

I found Forget Me Not 3.0 for Safari (free) today via Daring Fireball. Forget Me Not saves the current set of tabs when you close Safari, and re-opens them the next time you launch it. It’s not a huge deal, just one of those little things I’ve been missing in Safari ever since I started using it with Firefox on Windows.

MacSanta

December 22, 2006

MacSanta is the latest OSX software promotion, offering 20% off a very large list of applications from some great developers. If you haven’t seen it already, it’s worth taking a look at. In addition to offering a few great applications I already own, there’s two or three I’ve been meaning to purchase for a while now.

How to learn Cocoa

December 18, 2006

Every so often on forums or mailing lists I see someone ask the question, “how do I learn Cocoa?” There’s no short answer, and rather than try to type out a reply each time the subject is brought up, I’m going to expand on it a bit here. Even though there’s no right path for everyone, I can give some tips and advice from my own experience. Read on if you feel overwhelmed, or just don’t know where to begin.

Do the Currency Converter Tutorial

Before you write a single line of code you need to get familiar with the basic tools for programming in OSX. If you’ve never set foot in Xcode or Interface Builder, Apple’s Currency Converter tutorial is just the thing you need. It will also introduce you to those [ ] braces that seem so weird at first if you’re coming from a different language.

Learn about Memory Management

Whether you’ve dealt with memory management in other languages or not, Objective-C’s retain release pattern probably isn’t going to be familiar. It’s not something to worry about though, memory management in Objective-C is easy to learn, and works well in practice. Most tutorials are going to be roughly the same, but you can go here or here for starters.

Know your Resources

Part of programming any language is knowing where to go to get help and information. In addition to the built-in API documentation there are some great community resources out there, and I’d suggest visiting them each time you sit down to code, if not daily. A few that have been indispensable to me are Apple Developer Connection, the CocoaDev Wiki, and the Cocoabuilder Mailing List Archive.

It’s also a great idea to become active in the Cocoa developer community. In addition to providing interesting daily reading, you’re bound to pick up useful little tricks and hints that aren’t publicized elsewhere. Apple’s Cocoa-dev Mailing List, and OmniGroup’s MacOSX-Dev Mailing List are both active centers for discussion. Blogs, from both small and large development companies, are also a good source of information (although I assume if you’re reading this, you already know that). Take a look around Cocoa Blogs for starters.

If this is your first introduction to programming, you might want to read through CocoaLab’s Become an Xcoder e-book, which covers the basics using the OSX environment. Also, Cocoa Dev Central’s Tutorials are extremely helpful and well-written, for beginners and experienced programmers both.

Forget about Bindings

Maybe you’ve heard about these neat new technologies like Bindings and Core Data, and you’re thinking you don’t have to worry about things like data source methods because they’re the “old fashioned” way. Well, forget it. Bindings saves you a lot of work, but it’s no replacement for understanding how things work at a lower level. In fact, once you start writing a real world application using bindings, you’ll almost always need to use a trick or two to get them working, and that requires an intimate knowledge of key value coding and object handling. Learn the basics first, and save bindings and Core Data until they’re really needed.

Buy Hillegass’ Book

Cocoa Programming for Mac OSX is one of the best Cocoa books you can buy. Even though most programmers recommend it as the first step in learning Cocoa, I’m leaving it towards the end here. It’s not because Hillegass doesn’t teach you the basics of Cocoa programming, but because the majority of the book focuses on more advanced topics such as writing a subclass of NSView, or working with the responder chain. If you already know the fundamentals behind Cocoa and are enthusiastic about using those skills to write a real application, you’re going to get a lot more out of this book than using it as your first and only resource.

Explore the Frameworks

Believe it or not, Cocoa programming doesn’t just involve Cocoa. There is a lot of functionality hidden away /System/Library/Frameworks that isn’t included in a new Cocoa project by default. You can find everything from CD burning to working with Open GL, and they can do a lot of the heavy lifting for you. Best of all, there are no restrictive licensing issues or huge price tags involved.

Write your own Dream App

You can read as many tutorials and books as you want, but there’s simply no substitute for writing code. It doesn’t matter if your idea sucks, the code you write is terrible, or if the end result doesn’t always work correctly (assuming you finish it at all). As long as you’re working on something, you’re going to end up running into new challenges, gaining experience and learning new concepts. And in my experience, that’s simply the best way to improve your skill set, no matter what language you’re working in.

TextMate as Xcode editor replacement?

December 17, 2006

I’ve been writing code in TextMate the past two days, trying to see if it could replace Xcode as my primary editor for Objective-C. I’ve always heard good things about TextMate, and since it’s been getting a lot of publicity lately I decided to give it a shot. I wasn’t expecting too much from it; I don’t have any real complaints about Xcode’s editor, and I figured trying to separate the editor from Xcode would introduce a lot of extra work whenever I want to start a build or start a debugging session.

Despite this, I haven’t had too many problems. There’s no getting around using Xcode, but TextMate does do a decent job of replacing the just the editor portion. You can manage the two in different ways; I prefer to use TextMate’s tabbed project mode for all the source files in the project, although you can also set TextMate as Xcode’s external editor, which opens a new editor each time you click a file in Xcode’s project window. For the actual build process you can save everything and switch over to Xcode’s build window, or use the tools from TextMate’s Xcode bundle. I find myself doing a little of both, depending on the situation.

I expect to go back to Xcode’s editor sooner or later. There are just too many small things I miss when I’m using TextMate, and although it’s a good source code editor, it doesn’t really have any one big draw to keep me using it (especially with Xcode 3.0 on the way). There’s no reason not to give it a try though; it’s probably the best alternative out there if you don’t want to use the built in editor.