Coda Coolness

So I downloaded and tested out Coda a little bit today. My initial impression is that I’m very impressed. It could be the new standard. A few like Alex King point out that it uses Safari as the default engine. I don’t think that’s so bad. Nothing stops you from using 2 windows one being Firefox (obviously running Firebug). I think the editor itself is rather well polished and very refined. The use of Bonjour to allow for collaboration makes it perfect for multi-developer environments. And yes, you can have more than two developers collaborating in 1 document.

My typical workflow is very abrupt. I tend to have Firefox, IE, and an IDE open at all times when coding pages. Not to mention a KVM switch to go between platforms. This still consolidates several things, and with a much nicer UI.

I’ll need to try it (for actual development purposes) for a few days before I could tell if it really works as well I hope. Panic is one of my favorite Mac developers. Really well polished products are their specialty.

Time Sucks

One of the hardest things to program is the Date and Time. This is especially true when your doing it on the web. Why is that? Using a unix timestamp is immensely helpful and resolves many of the complexities, but it does have some issues (besides the Y2K38 bug). Well lets take a look at some of the “typical” things you need to be aware of:

  • Your server is in one timezone, your users are in 23 others.
    Users don’t care what the time is at the site. They want things in their time.
  • Does your server even know your users timezone?
    You could do this with JavaScript, and send it to the server, but that’s a mess. Or send a timestamp to the client, and let JavaScript print it out. But that’s still messy.
  • Timezones aren’t obvious (think Indiana).
    Did you know some even use :30 such as UTC-3:30 for Newfoundland Standard Time.
  • Looking back in time (or forwards) is difficult (how many hours between X and Y accounting for leap years, and DST changes)?
    This is a mess, enough said. And just in case you have a formula, did you account for the conversion between Julian and Gregorian calendars? Don’t forget not everyone switched in 15 October 1582 / 4 October 1582. Going forward remember we’ll eventually have another leap day, since the Gregorian calendar isn’t perfect.
  • Your server observes DST. Does your user? When?
    Get the picture? Remember most states do, except for Hawaii (yea, that’s another Timezone) but Arizona doesn’t either, except for Navajo Nation. Again Indiana!
  • The Politics of Time…
    If you call UTC+2 Israel Standard Time, you upset visitors from Muslim nations like Egypt. Call it Central Africa Time, or Egypt Standard Time and your considered anti-semitic. Same goes for UTC+8, is it Chinese Standard Time or Hong Kong Time? Most avoid this by just listing UTC±N. Unfortunately this confuses people, especially Americans who only refer to timezones as “Eastern” (UTC-5), “Central” (UTC-6), “Mountain” (UTC-7) “Pacific” (UTC-8). Note these American names aren’t so common in all of North/South America.
  • Daylight Savings Time for 2007+
    Then you have a bunch of clowns who voted for the Energy Policy Act of 2005, creating the Y2K7 bug. The idea was an extra hour of daylight in the evening would reduce electrical use. What they didn’t realize is that it cuts daylight from the morning. My guess would be a follow up bill may fine the sun for failing to provide adequate light, and eventually include economic sanctions. :-P

I thought a while back this could suck. Think about all the time/money that goes into updating and testing systems for these few extra weeks of DST. What a drag.

Swatch Internet Time was an obvious bust, but perhaps we could all just use UTC?

Komodo Convert

After reading about Myk’s use of Komodo, I decided to give it a try. I’ve yet to find the truly perfect IDE, so I’m always open to good alternatives.

For years I used BBEdit Lite, which was good enough for my somewhat basic needs, TextWrangler came and I moved over. On the Windows side of things, I had tried numerous editors for years, ultimately using Eclipse, ConTEXT, and (on a few occasions) jEdit. Mainly on the Windows side it has been ConTEXT, since it didn’t have the restrictive feel many IDE’s have. On the downside, it didn’t do much.

At work, I’ve been using Macromedia HomeSite. Overall it’s not too bad, but it does have it’s quirks. There’s definitely a bug in FTP that causes it to occasionally not show all the subdirectories when you nest to deep. Then it sometimes randomly throws errors at you. Most of the time they can be safely ignored, making me wonder if they are still errors when nothing bad happens.

So I downloaded Komodo Edit (free) on my Windows Laptop, and my Mac Mini, installed it on both, and played around. First order of business was playing with some local files. End result was that it handled things very well. I didn’t have to fuss around to much to get things accomplished… I like that. Next step was to try the FTP functionality (SFTP and SCP as I don’t like FTP). It worked, I was able to edit a few files and it performed rather well. Also nice was that it let you know it read the directory from cache. Most will hide this info from you.

In the end I decided a few things were missing. The most notable thing missing and preventing it from replacing HomeSite was the sidebar file manager. I work on many files, so I need a quick way to get to them. File –> Open wasn’t going to work. I decided to file a bug and request a similar feature as an enhancement. Other editors do a similar sidebar file tree, this wasn’t something revolutionary.

Ends up there is an Remote Drive Tree Extension that provides the functionality I desire. Sweet! The usual install process, restart and I’m going. Works perfectly. Only thing missing is drag/drop support so I could easily add files or move them around, renaming would also be helpful. Perhaps those features will come in the future.

So after a little time with it, I’ve decided I’m ready to try it for a week, and see if it handles my needs for the week. It has now qualified for testing.

I think I like it so far. I do have a few pet-peeves though:

  • FTP support is still a little buggy.
  • Slow startup time.
  • Prefs feel somewhat awkward and not as intuitive as one would hope.

But it’s still beta, so there’s time for it to grow.

xmlHttpReq.overrideMimeType() in IE7

This is just a little note for anyone doing xmlHttp work. I just encountered this situation this morning. As most web developers know IE7 introduces support for the native scriptable XMLHttpRequest object. The big advantage here is that ActiveX is no longer necessary to use ajax applications on IE. One thing I did note is that there is a slight difference in their support for the XMLHttpRequest object. Take the following code:

// Mozilla/Safari/IE7+
if (window.XMLHttpRequest) {
    xmlHttpReq = new XMLHttpRequest();
    xmlHttpReq.overrideMimeType(‘text/xml’);
}
// IE6-
else if (window.ActiveXObject) {
    xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpReq.open(‘POST’, strURL, true);

That seems to break for me on IE7. A little experimentation shows that it doesn’t support the overrideMimeType() method. A simple fix for this is to simply check before invoking it as follows:

// Mozilla/Safari/IE7+
if (window.XMLHttpRequest) {
    xmlHttpReq = new XMLHttpRequest();
    if(xmlHttpReq.overrideMimeType){       
        xmlHttpReq.overrideMimeType(‘text/xml’);
    }
}
// IE6-
else if (window.ActiveXObject) {
    xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpReq.open(‘POST’, strURL, true);

This is just FYI for anyone who happens to encounter this error. It’s a simple fix. This somewhat goes without saying, but make sure your request returns from the server as text/xml or you’ll likely still encounter issues.

Asynchronous Processing With PHP

Several weeks ago I was looking on line for a way to have PHP execute a background process, so that the page didn’t hang while some functionality happened. One way to do that is to use fsockopen() to open a url to exec what you want. But I wanted to see if there was another way. This is what I came up with.

I should note that this isn’t that well tested. I ran it on a Windows and Linux system without incident to test it, but I haven’t given it a very thorough exam. Also note $call is completely unsanitized. If you’re using this and accepting anything from the web, you need to make really sure that $call is completely sane and free of evil.

Continue reading

Enhancing Security With Nonce

A little while back I read about how WordPress was implementing Nonce to help enhance security. What I like about this technique is that it doesn’t rely on referrer checking (which is faulty at best).

Today I implemented that on a project I’m working on, rather similar in style to WordPress. I think overall it’s a better approach to referrer checking. It seems the nonce approach is actually quite popular on the web looking at commercial sites, but not a technique often talked about.

Well done by the WordPress team. My implementation is pretty similar to theirs (my variables and salting is a little different based on the app) since it was pretty hard to improve upon. Not sure how long to make the Nonce, so I stuck with 10, which is what I believe they did as well. Not sure if I should go with something longer.

One of the great things about open source is the discussion of best practices and techniques. It also benefits closed source projects who can gain influence and knowledge from those discussions.

In Search Of The Epoch Child

The UNIX Epoch is 00:00:00 UTC on January 1, 1970. That’s essentially the beginning of time for UNIX based systems. You know, “In the beginning when Ken Thompson and Dennis Ritchie created the /usr and the /etc1.

I’m curious if anyone has tracked down someone (preferably a geek) who was born on the Unix Epoch. I guess we can’t be too exact since the question would be “are you born when your head is out, or when your butt is out? Can the cord still be attached or do you need to be unplugged?” or something to that effect.

All kidding aside, it would be interesting to know if anyone has come to the realization that they are the Epoch Child. I’m not sure (any calendar scholars can help me out here), but it seems the last child to have a time standard’s origin coincide with their birth may have been Jesus (and obviously any other child born that night). In that case, it seems they likely it was rounded as best they could (see Wikipedia discussion of Jesus’s Birth Year and Date).

Remember to account for the timezone. For example if your born in New York, that’s -5:00. So anyone feel like finding him/her? Obviously some proof would be necessary to prove your the epoch child.

It would also be interesting to find some others, but this seems to be the most interesting.

1 Yea, lame Genesis joke.

No pain no gain, lots of little stuff

I’ve coded quite a bit the past few days on an old project I’ve had sitting in the vault for some time. I really want to get this thing done soon. In the process I’ve gotten to write things that I’ve never really done before. Nothing quite as fun as a problem you’ve never approached before. Lots of code, little time… so much I want to get done, and I want it done yesterday ;-) . I really want to push this thing into production quality soon (because that’s when things really become fun).

Oh yea… my foot hurts. Here’s a tip for anyone doing yard work this spring (well summer soon). When using a shovel, don’t settle for an old pair of sneakers, use boots. Stepping down on the top of the shovel to dig it into the somewhat hard ground today, I hit a large-ish rock, shifting the shovel, and causing my foot to hit it about the inner part of my foot, right under arch as well as slightly up the side, not bad, but no fun. Now I’ve got some minor swelling, and has me limping slightly around the house.

I’m starting to get that addict-like urge to do some upgrading around here… thinking about another stick of RAM for my Thinkpad (T43), to max it out, and a 1GB upgrade for my Mac Mini.