Problems with FTP

July 14th, 2008

While I believed SFTP to be more secure, I had no idea about the various shortcomings of FTP. Definitely switching all my Transmit bookmarks to use SFTP right now.

I updated to rubygems 1.2, which fixed the bulk update problem that plagued me on my 256mb slice. It also, however, broke SQLite. Fortunately it’s a known problem and small permissions fix does trip.

Just posted this to ensure others can fix it if they need to.

FF3 and Safari 3 compared

June 15th, 2008

Another reason to like the Mac community is this comparison of Safari and Firefox 3 rendering styles. The fact that there are people that care this much about title bar gradients shows why Mac community’s emphasis on look and feel contribute to the overall user experience.

This, and the exciting future features in WebKit are reason enough for me to use Webkit.

From an article on iPhone inroads into the Enterprise

“I have nothing against iPhone. It’s great,” says Manjit Singh, CIO at Chiquita Brands International Inc. “But we’re a BlackBerry shop, and I don’t think iPhone brings anything new to the table. It has a great user experience, but that’s all.”

Really? How can people seriously forgo a great user experience by choice?

The big moose we need to put on the table is that people have learned to ignore information on the web that is irrelevant to their task at hand. Google Adwords work because people are actively searching, and the ad units sometimes add value. When updating our profiles on Facebook or watching videos on YouTube, we simply have no reason to give ads any attention. That’s why at least one fellow blogger called Facebook “the worst traffic on the net.”

So says challengedividend.com who well illustrates his underwhelming experience with Facebooks ads.

I agree…I see no compelling reason why people would suddenly start clicking on ads from a social networking site. They are there to interact with their friends, not searing for information or products. It’s hard to see Facebook (and the like) as viable long-term.

With the advent of mod_rails, I can finally port some sketchy PHP sites over to Rails. I ran into a gotcha that I can’t explain but would still like to share so others don’t make the same mistake:

I was wanting to override the to_param method in a model so a slug would appear in the URL instead of the integer id. I also still wanted to be able to access the pages by id without having to change the controller code. So I put this in my model (inspired by James Edward Gray II’s Rails tip #1):

class Page < ActiveRecord::Base  

  def self.find(id)  
    find(id) rescue find_by_slug(id)  
  end  

  def to_param  
    slug  
  end  
end

This caused some problems. About 3/4 of my page loads would produce blank pages. The log/production.log file suggested everything was fine, but the Apache error logs said “unexpected end of headers.” Frustratingly, however, the pages would work occasionally.

After much troubleshooting and Googling, I couldn’t find any reason it wasn’t working. So I changed the method to:

  def self.find(id)
    find_by_slug(id)
  end

and it works fine.

I’d rather have an explanation that not, but for now, I’m just glad to have it working.

mod_rails was released recently (I submitted a voice sample to narrate the demo screencast, but they went with the über-helpful Ryan Bates), giving hope to not-big-enough-to-require-a-dedicated-server Rails developers everywhere. Deployment has long been the biggest complaint against Rails, and hopefully this gem will facilitate getting Rails apps up and running on servers everywhere.

Not everyone is happy, mind you. What’s the complaint? That now Rails may be too easy to deploy. And once something becomes easy, then it is put into the hands of those who may not know what they’re doing. Then newbies come out of the woodwork to ask the questions that serious and seasoned developers have known for years. Before you know it, everyone is using Rails and the old-timers just aren’t as special anymore.

I’ve read some Ruby purists who complain that Rails has polluted the Ruby user pool. What was formerly a niche language has now entered the mainstream, pulling ignorance behind it. Now a few Rails developers are raising the same concerns (Of course, since there’s been a Rails for Dummies book for over a year, it seems to me Rails entered the mainstream a while ago).

The best part about PHP is that you can host it cheaply just about anywhere and don’t need a CS degree to create a basic dynamic site. The worst part about PHP is that you can host it cheaply just about anywhere and don’t need a CS degree to create a basic dynamic site. Fortunately Ruby has many advantages over PHP, and I don’t think the user community will be ‘polluted’ as much.

So what is it? Do you want easy deployment, broader exposure, and all that brings or do you want a niche language?

I, for one, welcome our new Rails underlords (or newbies).

acts_as_asp.net

April 4th, 2008

I caught this one a little too late, but thought it deserved some pub. After being exposed to the .NET world for the last few months at my new job, I, too, have come to appreciate some of the niceties that the .NET framework provides. Fortunately I’m not the only one who notices this shortcoming, and a Rails plugin has been developed to give it .NET functionality. The short description is definitely worth reading.

And don’t let the release date fool you. This is actual code with an included sample application. The only April Fool is the one who neglects to use .NET goodness in his Rails app…

Simplicity in Software

March 16th, 2008

Improved Beyond Use. That’s the phrase that Paul used in the comments of an excellent comic on http://stuffthathappens.com.

Simplicity in Software

I was just talking to a user who was bemoaning Word Perfect’s feature creep and explained that was why he was using an old version. He only used Word because he has to now. I’m amazed at how little thought goes into many apps and sites. My wife is a travel agent, and she deals with some horrific PC software just in order to do her job (a poster on the original post linked to a horrific software UI which I can only hope is fabricated). It’s been improved so much, that it’s unusable.

Hopefully with the continuing development of Web 2.0 and appropriate use of AJAX, simplicity can be valued and improved. I’ve enjoyed using Basecamp because of their simple interface without sacrificing functionality. Good stuff. I liked this comparison of Twitter’s interface improvements. Twitter was always simple but it has gotten better through time.

On the other hard, whenever I’ve used Microsoft Express Manager to administer MSSQL, I want to cry.

The comic’s Apple example obviously highlights the iPhone/iPod touch. I’ll be interested to see how the UI is utilized by developers. Those commenters (and the comments are worth reading) who complain are definitely part of the problem. Just because you’re data needs are complex doesn’t need you require a horrible UI.

A GrowlMail replacement

March 14th, 2008

Rather than have an annoying sound effect interrupt my silence when an email comes, GrowlMail offered an excellent notification alternative (and not just for Mail but for many other apps. If you’re a Mac user and somehow not using Growl, check it out). The only thing that I’ve missed since upgrading to Leopard is that GrowlMail crashes Mail. Apple recognizes this and disables GrowlMail in its 10.5.2 upgrade. That’s unfortunate.

While the Growl folks are working on an update, opbarnes has come up with an alternative. Use Applescript to call growlnotify, a command-line tool to create your own growl notifications, when a new mail message arrives.

Now GrowlMail can work in Leopard and looks great with the iPhonesque theme.

Magic 8ttp Ball

March 7th, 2008

The ever helpful Jamis Buck has released a fantastic magic eightball for web nerds. Check it out:

http://8ttp.jamisbuck.org/

You ask a question and get an answer in the form of an HTTP error code. I asked “Is this site sweet?” and received the answer “203 Non-Authoritative Information”. Hmm…

I wanted to use tabs as a navigational tool and load page content based on those tabs without a page load but in a way that would gracefully degrade. The technique is shared here in hopes that it helps others out who are considering the same thing.

This code is taken from a site I wrote for work.

Here’s the nav bar in basic XHTML. The class=”activeLink” is used for the current page and is styled identically to the a:hover pseudo class.

<ul id="nav">
    <li><a href="index.html" class="activeLink">Overview</a></li>
    <li><a href="technology.html">Technology</a></li>
    <li><a href="advantages.html">Advantages</a></li>
    <li><a href="learning.html">Objectives</a></li>
    <li><a href="video.html">Video</a></li>
</ul>

The content we want to change is in a div with the id of content. Each of the five pages above contains the same container div with this id.

The javascript is easy and clean, thanks to the magic of jQuery which is powerful and lighter than competing frameworks. After including jQuery (this example uses 1.2.3, but it does not rely on any recent functionality). The following javascript is all that’s needed for the effect:

// when the page has finished loading...
$(document).ready(function() {
    // links for the nav tabs.
    // clicking on an anchor hides the content, loads new content, and fades the new in.
    // this function also changes the class of the tabs and prevents the browser from loading the href
    $('#nav a').click(function(event) {
        $('#content').hide().load($(this).attr("href") + ' #content').fadeIn(1000);
        // remove active link class for all links then change the class of the link
        $('#nav a').removeClass("activeLink");
        $(this).addClass("activeLink");
        // used in place of 'return false;' as suggested by http://docs.jquery.com/Events_%28Guide%29
        event.preventDefault();
    });
});

The comments should help, but let’s break it down:

// when the page has finished loading...
$(document).ready(function() {

This is jQuery’s ready function that executes after page load and avoids the tricky window.onload issue that needs works around.

$('#nav a').click(function(event) {

Take the anchor links from within the #nav and add a click event to them. This applies the function to each of the links (5 in this case) and prevents cluttering the source code with onclick attributes. We pass event (a click in this case) as a parameter to be used later.

$('#content').hide().load($(this).attr("href") + ' #content').fadeIn(1000);

This line chains useful events together. It selects the content div, which contains unique data for each page. Then that div is hidden to prepare it for the new content. The handy AJAX method .load fetches content from another page. To determine which page we want to load, we’re going to use the $(this) variable, which refers to the current object (an anchor tag in this case), and by accessing the attr function, retrieve the href attribute. This means that click on Video link will return video.html. The second part of the attribute in the .load function (the + ’ #content’ part) allows you to select a sub-section of the page to extract. In this case, we’re wanting to retrieve all the HTML from the element with the id of content from another page. Finally, we call the fadeIn function to display the div again, with an adjustable speed (1000 milliseconds in this case).

// remove active link class for all links then change the class of the link
$('#nav a').removeClass("activeLink");
$(this).addClass("activeLink");

The removeClass and addClass functions are also straightforward. First we remove the activeLink class (the one that emulates the a:hover pseudo class) from all anchor elements in the nav bar (though only one will have it). Then we add that class to the current anchor tag, defined by the $(this) variable.

// used in place of 'return false;' as suggested by http://docs.jquery.com/Events_%28Guide%29
event.preventDefault();

Finally, we ignore the default value of the event (passed in the .click function) to prevent a click on the link from going to the target of the link. This allows the page to work in browsers without javascript and keeps our code clean and tidy.

The pages in this example are static, but it could easily be generated from any page. As long as the page link in the href attribute of the link returns a page with an identifiable div, it will work. There are some nice features of this approach:

  • Since the individual pages are kept, they can be linked to individually and all can act as a base page for AJAX reloads.
  • The page fading effect is a nice visual touch for reloading the content.
  • Our markup remains clean and tidy (save for the class=”activeLink” which I’d prefer to emulate in jQuery by adding a pseudo class to the links rather than a separate class).
  • By using jQuery, the rest of its functions can be leveraged in other parts of the site.

Hope it’s helpful to someone. I’d appreciate any comments or suggestions!

As a freelance web developer, and someone who does development in my current job, I’ve had my share of frustration with Internet Explorer’s rendering bugs. IE 5.0 and 5.5 were bad. IE 6 wasn’t much better. IE 7 made great promises, but only got us halfway towards compliance (I still enjoy Dan’s predictions).

Finally, it seems, Microsoft has bowed to the pressure and will finally support web standards in IE 8. On some of the more complicated site designs I have done, my work with CSS has been 3-4 times longer than it has needed to be just trying to fix IE’s quirks. The fact that there are entire websites dedicated to workarounds for IE’s quirks is a testimony to the web developer’s frustration with the biggest brother who frequently played by his own set of rules.

The article on doctypes on A List Apart is a great read for web developers by the way. So is Zeldman’s links to articles of the issue.

I was glad when Microsoft rolled out IE 7 as an update on February 12th (though more than 18 months after it was first promised) because that reduced the number of IE 6 users. I can’t wait until more and more people move closer to web standards. It will make lots of lives easier.

Finding unused CSS styles

February 22nd, 2008

I inherited a hideous stylesheet and was trying to determine which styles were unused. I was about to write a Ruby script or something to go through all the pages in the site and find which styles weren’t used in any of the pages. Fortunately, someone already came across this problem. The Dust-Me Selectors Plugin for Firefox will do this for you. It lets you surf to as many pages in a site as you want to check on or it will read Google sitemap files and do the work for you.

What a fantastic (and free!) way to rid the web of outdated styles.

Adobe on OS X *(&@!#

February 14th, 2008

Adobe, I’ve generally been a fan of yours for 15 years or so, but I’ve got a few complains:

  • The Adobe Updater application is evil. It pops up at the most inopportune times, tries to quit open applications without permission (I received a warning about Safari closing because the Updater was doing its own thing in the background) and seems to have updates for arcane Adobe utilities that I don’t use (or even remember are on my system). If only a Mac developer created an easy-to-use updater that didn’t require a performance-wasting separate updater application.
  • Flash on OS X is horrible with resources. Apple’s decision not to include Flash support on the iPhone confirms this, as well as my blazing hot laptop if I leave a site with a flash movie open, even in the background.
  • Your Acrobat Reader application on OS X is a hideous memory/performance hog and way too bloated for its own good. I think you’re trying to do too much with PDF files with adding video embedding, page transitions, and interactive forms. Take those features out of PDF files and put more attention into making Dreamweaver a better product.