|Safari for Windows Debug Menu|
|by Jon on Monday, June 11, 2007||file under: Technology|
In an interesting turn of events, Apple released Safari for Windows. Well, they didn't quite release it, its still a beta but in general works very well (this post is being made from one of Safari 3's resizable text fields).
If you're a web developer, Safari's Debug Menu is a necessity. Fortunately for those of us stuck in Windows, Safari's Debug menu is still available, however, it appears you have to get your hands dirty to enable it.
On a Mac, you'd open a Terminal and type:
As far as I can tell, Windows doesn't have Apple's
Before the closing
|Unix is Easy|
|by Jon on Tuesday, May 1, 2007||file under: Technology|
You just need to know what to tell it.
|by Jon on Wednesday, April 25, 2007||file under: Technology|
A few weeks ago I purchased a Nokia N800 from a floundering Comp USA in the Phoenix Metro area (from my vantage point, it appears that all CompUSAs in Phoenix Metro are closing). I always liked the idea of the Nokia 770 when it came out, and the N800 seemed to be enough of an upgrade for me to consider it very compelling... compelling enough to take the leap.
I was looking for several things:
Let me expand on those three things. Currently, Kortney and I have a nearly 4 year old TiBook that's still kickin' it hardcore. Its a great laptop, with a nice rugged, metal frame, beautiful display, and it still has enough power for what we do day to day. My only complaint is that when I'm carrying two big text books for class, it adds quite a bit of weight to my bag. Plus, when I take it, that leaves Kortney without a Mac (but with a dual-screen Linux box!), and without the computer configured for her most efficient use.
I wanted a device which would allow me to leave the laptop at home when I went down to school, but wouldn't require me to a) carry a full size notebook computer with me, and b) give up any of the functionality of a "real" computer.
I also wanted a small device because I thought it would help me keep track of all the stuff I need to do for school and at home. Kortney and I both keep everything in iCal and subscribe to each other's calendars. I have a laundry list of to dos and all my contacts arranged (many with pictures), in Address Book. I wanted something that would let me take those repositories with me, and allow me to edit them remotely, and sync back up when I got home. My phone can already do that (sans to dos), but adding a calendar entry with a numeric keypad is an exercise in frustration.
Finally, I wanted something that would allow me to get on the internet. A device that would allow me to
When the Palm TX was released, I thought that was the device that was going to do all those things for me, but it had one problem: it came with an aging version of Palm OS that I probably wouldn't be able to update when Palm decided they couldn't milk that cow any longer. When the 770 was released that replaced the TX as the device of interest, and when the N800 came out this past winter, I was ready to pull the trigger (well, the device release, and the fact that CompUSA had slashed the price).
So, does it live up what I was looking for?
With the addition of a Bluetooth keyboard, I think the N800 would work great as a short range laptop replacement. It already has a fairly large application library thanks to the 770. The screen is bright and crisp, for a Unix-geek, all of the standard utilities are there, and for a non-Unix geek you can get most everything you need, including word processors (AbiWord) and spreadsheet programs (Gnumeric). I'm a bigger KDE fan then Gnome, so its unfortunate that the majority of applications are Gnome ports, but there are several people who have full KDE stacks running on their N800's, so that may be a possibility down the line.
As a PDA, the N800 has some room to grow. If you are just using the N800 to keep track of appointments, contacts, and tasks, or if you are using Linux as your primary desktop, the GPE PIM suite will probably work for you. However, if you are looking for something that will sync with iSync and all of the Apple apps like I am, the N800 is like a little island. I have had success pushing calendars to to the device, but in a read only capacity, and have had no success getting modifications back from the device.
Like most open source apps there is also a divide in how things should be done. The N800 comes with an address book repository which other pre-installed apps use, but third party apps all seem to use their own contact database, providing no way to sync between them. I know the GPE PIM suite was developed tangentially to the Nokia Internet Tablets, but when they were ported, they should have used the Nokia address book. There way may have been infinitely better, but as a user, I don't care, I just want everything to use the same data. If anyone does work on creating an iSync plugin for the N800, I'm guessing they'll also have to choose a collection of applications to support. Which means it may not support the programs I'm using on the N800. As a PDA, the N800 may be useful to some, but has a way to go before it will be useful for me.
Fortunately, as an internet appliance it excels. I can get on the internet practically anywhere I get phone service (using my phone as a Bluetooth modem). My home screen has the weather forecast for the next 5 days and the latest RSS feed entries. I can stream internet radio to the device, including BBC. YouTube videos are shaky, but watchable. And the Opera browser is fantastic. I am surprised Nokia went with Opera when they have been using WebKit on their Symbian phones, but really, Opera does a great job.
The N800 still has a long way to go, but is a relatively young platform. The package manager is great at keeping apps up to date, but it seems that essentially every app has its own repository. Coming from a Gentoo, FreeBSD/MacPorts background, its really nice being able to install any application from a single repository.
The device also seems to have an identity crisis when it comes to being operated by stylus or fingers. Many of the buttons are much to small to accurately hit with even my tiny fingers, but there are other facilities that literally enlarge to facilitate thumb navigation. I would like to see finger navigation expanded in future releases of the platform software.
Overall, the N800 is a fun little device with a lot of potential. I have a fear that in June, however, any of its merits will be overshadowed by the iPhone. I've read that usability is high on Nokia's list for its next software release, but they are up against the kings of usability. On the open source front, developers need to start thinking like Apple: open source is a great foundation, usability is the ultimate goal.
|On Web Scaling|
|by Jon on Tuesday, April 24, 2007||file under: Technology|
At the beginning of the year I was doing a lot of web scaling work, which wasn't dissimilar to the web scaling work I had been doing about a year prior to that. There's a general problem that every semi-successful web developer is going to have to face at some point during their career: a small fraction of web users want your content, but, there is a gigantic number of web users.
The app I'm working on at the moment gets around 50,000 requests per server during peak traffic hours (including static and dynamic content). Its currently spread across multiple servers with a hardware load balancer in front of it. When I came back to this project (I had moved to other things and this project had certain upcoming opportunities that interested me) all of the servers in the cluster were pegged, with a load equal to the number of CPUs in the system. (For the non-Unix guys and gals, your load average shouldn't get above the number of processors you have in your system. For most systems that would be 1.0, but servers are generally higher then that.)
I combed through the app looking for bottle necks, and was able to significantly reduce the load on the servers by just specific ways the app was written. No hardware was changed to drop the load significantly. With a few changes, one server in this cluster could now handle all of the traffic (of course, for redundancy reasons, there are multiple servers). So how can we go from take an app from snail to a cheetah? Lets find out.
A few more details, this project was written in PHP, which can scale very well, if you don't bog it down. Many of the techniques, however, are applicable to any app.
Those are just a handful of pointers which have served me well over the past few years. These all might seem basic to you, but a large amount of professionally written code I come across never takes performance or salability into account. The general excuse is that it works for the amount of traffic at the moment. One day you'll get popular though. You'll get posted to Digg or Slashdot, and you'll be happy your code scales. Either that, or you'll be trying to put up a static page which apologizes that your content has gone missing.
Automate iSync with
|by Jon on Friday, March 2, 2007||file under: Technology|
Back in July, I wrote about scripting iSync so it would automatically sync my phone every night via a cron job. The solution wasn't perfect, but it worked pretty well.
Since then I've become fond of Launchd. I've written LaunchDaemons to keep run my nightly backups and keep Darwin Ports in sync. While reading the Launchd entry in Wikipedia yesterday, I came across this section on LaunchAgents:
Let me back up a little bit. While my AppleScript +
That's where LaunchAgents come in. LaunchAgents have the ability to run a task at a given time or given event, can be run as a specific user, and can run tasks which require a user interface. Bingo!
I've modified the script slightly since the last time I posted it, so here it is again. The major change is now the script uses iSync's return status as an exit code instead of just returning the value.
Again, I saved this to
Instead of scheduling this with cron, lets create a LaunchAgent for
I'll quickly highlight the various fields in the plist.
Take that plist, modify it to your liking (or use Lingon to create one for you) and save it to
Now run it to make sure it works:
If everything worked correctly, iSync should pop open, sync whatever it is you want to sync, and quit iSync. Now that the job is loaded, it should run at the interval you assigned.
That's just the tip of the
Update: I've received a few emails mentioning whitespace issues when copying and pasting the above AppleScript, so I've uploaded a binary here.
|PHP 5 Type Hinting|
|by Jon on Tuesday, February 20, 2007||file under: Technology|
Since PHP 5.1, developers have been able to add "type hints" to function and method declarations. This is a huge boon for OO development in PHP, and promotes use of defined objects instead of hashes, arrays, and invariants as well as helps find errors which may otherwise go unnoticed.
In the past, a variable of any type was able to be passed to a PHP function. Say you wanted to pass a database connection object into a function, you might declare something like this:
That's a relatively simple function. But wait, what if
That's safer; the function above ensures we're getting an
We want all the safety of the above code, with the benefit of allowing subclasses to be accepted as well. We can get that by a slight modification to the original method:
All that was added was the
What do you mean we no longer have to worry? To be frank, you're program will end with a fatal error if this function is called with an incorrect data type. That might sound like it sucks at first, but it means that your program will die quicker, meaning you can find bugs quicker. It also means the stack trace you get will include the line of code which called the type hinted function, not some line in the middle of the function which provides no hints to what called it with the incorrect type to begin with.
What happens if we call
That's great! We die early so bugs show themselves sooner, we declare parameter types, so callers know exactly what they should be passing in, and we save quite a bit of manual error checking required to make our methods safe.
This also allows you to define and use classes like C structs (a class which contains only public members) for passing data to methods and functions in place of arrays and hashes, which is so commonly done in PHP. Creating and passing a struct to a type hinted function or method ensures that you know exactly what fields and methods are available to you. You also don't have to worry about misspelled string hash keys. You can let the interpreter do all that work for to ensure you're accessing valid fields and methods.
Are there any drawbacks? Unfortunately, the only native type that PHP allows hinting for is
This is also a feature of PHP 5.1 or later and is not compatible with earlier versions of PHP. This could potentially make you're apps less portable. There are also many hosting providers still running PHP 4, which has no support for type hinting at all.
Finally, there is no facility for hinting return types, meaning even if you know you're input to a function is good, you don't necessarily know the output is as well.
If you are running PHP 5.1 or later, type hinting can be a great way to find an eliminate bugs, before they bite you. It can also allow simpler and safer functions and methods that are also self describing. If you have no backwards compatibility requirements, you might want to give type hinting a shot!
|I'm a Big Fan of C++|
|by Jon on Monday, January 22, 2007||file under: Technology|
When you read Digg, you're bound to find nonsense, and I try not to bite, but sometimes you get irked. An article written by Jeff Atwood appeared on Digg over the weekend which links to a two part interview with the designer and original implementor of C++, Bjarne Stroustrup.
I have long defending C++ as a great programming language, especially to Java programmers who seem to only appreciate the flexibility of C++ when the features, which they previously derided, are added to Java.
In Jeff's post he has a big block quote from Bjarne and then proceeds to blast C++ on two points which are aren't really valid. His first, C++ is fast but unforgiving, is only that people don't have any more brain capacity but computers have quite a bit more computing capacity, so lets waste some of that computing capacity to save the poor programmers. I was thinking aloud this weekend why my current computer is seventy-two times faster then the computer I cut my teeth on, but doesn't 'feel' any faster.
His second point is that C++ is designed to be extremely flexible. Wait, that sounds like a benefit, not a drawback? He then goes on to say that it can be used to write operating system kernels and device drivers. He might not realize it, but everything in the KDE stack is C++. I don't know of any websites that are built in C++, but I don't believe it would be as dangerous as he presupposes because of the great data structures included in the Standard Template Library. Buffer overflows? Who's using
C++ offers features that most other OO languages don't: access to pointers and the ability to manage memory, among other things. I'm astounded when I read or hear people thinking these are disadvantages. If you don't want to deal with memory management or pointers, pass objects by value or reference and allocate all of your objects on the stack (i.e. don't use the
For some reason I allow myself to become uptight when Java programmers celebrate a recently added feature of Java, when it has been long since available in C++. A relatively recent example (the past few years), has been "generics", which we called templates in C++ before generics were available in .Net or Java. Meanwhile, Java developers sit by while useful features like first class functions and operator overloading (if Sun can do it, why can't I?) escape the grasp of Java programmers everywhere.
I often read that C++ is difficult to learn and use, but must be missing something. I've written projects large and small in C++. I've always thought it was a very natural extension to C, which isn't a very difficult language to learn in the first place.
Best quote from the interview:
This is one of the most telling statements in the article:
and unfortunately its all to true. I'm sure most Java programmers would feel right at home developing in C++ and if they sprinkled in a few "delete" keywords at the end of their methods and learned about destructors, not only would they have portable code (just a recompile away), but code which is much faster than their Java counterpart.
I've left behind Java, Perl, C#, and Bash because I have no compelling reason to use them. Anything I can write in Perl or Bash I can write in Ruby, which I'll find much more enjoyable and find easier to read if I need to come back to it later. And personally, I have no need that Java fills (except, perhaps a paycheck!). If I want something fast and compiled, I'll write it in C/C++. If I need to write something quickly, I'll do it in Ruby!
I'm sure other languages work great for other people, but I'll stick with C++ while keeping my feelers out for anything better (D is intriguing, but I still don't see any compelling
|iPhone in the Times|
|by Jon on Wednesday, January 10, 2007||file under: Technology|
The New York Times has a great article which highlights what I like about Apple the most: their dedication to detail, their commitment to things that work like you'd expect them, and their discipline in not releasing anything which doesn't meet their extremely high standards.
Oh yeah, the article mentions the iPhone, too. I just hope there is a way to get one without a Cingular contract. It seem to be the mobile device I have been looking for (and it just happens to be a great phone as well!).
|Automated Blog Tagging|
|by Jon on Monday, January 1, 2007||file under: Technology|
In the middle of december, I finished my first "real" semester of graduate classes at ASU. One of the more interesting projects I completed was a method of assigning multiple classes to blog posts, using a modified version of Ben Kamens' Bayesian Tournament Algorithm, which itself is an expanded version of the standard two class Bayesian spam algorithm described by Paul Graham.
Kamens expanded on Graham's algorithm by moving it beyond a two class problem. With the Bayesian Tournament algorithm, instead of only classifying things as something or not something (typically spam or not spam), one of several categories might be chosen. For example, you might train it to sort your email into work, family, and spam.
That's all well and good, but tagging is catching on like wild fire, and typically a piece of media is given one or more tags. I couldn't really find anything having to do with classifying things with more than one category, so I thought I'd give it a whirl, and the results seemed to be largely successful.
To go along with the project, I created a "blog editor" which was a mocked up and simplified version of where you might enter a blog post, which was hooked up to a classifier I wrote which was trained posts from the The Unofficial Apple Weblog. Here's a screencast showing how the editor classifies your post as you type.
The screencast doesn't have any audio, so here's some commentary. It first shows a shot of a post from TUAW along with its tags (Software, Cool tools, Productivity, Internet Tools). It then pans over to my editor, showing how it classifies as you type, with an author entering the text of the post shown previously. In the end, the classifier chooses Internet Tools, Productivity, Cool Tools, Analysis/Opinion, and Software as the tags for the post, pretty close to the tags chosen by the original author! For the record, this post was not in my training set, and those tags were completely chosen by my classifier.
The paper was rushed, but gives an overview of the implementation for anyone interested. It was a lot of fun building a working classifier.
|by Jon on Tuesday, October 10, 2006||file under: Technology|
I've posted a few times about adding color to console apps in OS X, so I thought I'd post another tidbit I found this past week. The GNU version of
To get this functionality every time you use grep, you can make an alias:
and put that in your ~/.bash_profile, or if you are an admin on your system, in /etc/profile. run
To set the color, add:
to the same file you added the alias to, replacing
|Newer Posts||Page 3 of 26||Older Posts|