Archive for November, 2008

Interesting Google Technique

Friday, November 21st, 2008 By: brian

As I was browsing today, I noticed an interesting technique in use on the Google search results page. The innocent and plain logo at the top left is actually a single image file made up of multiple images which then are made visible by the CSS for each placement:

This is presumably for optimization. Every little bit counts when you serve up 20 bazillion hits a minute.

Zebra Striping with jQuery

Tuesday, November 18th, 2008 By: Wes Bangerter

Zebra Striping a table with jQuery is ridiculously easy. This code will add even and odd classes to every row in all tables:

$(document).ready(function(){
  // Zebra stripe our tables
  $("table tr:odd").addClass("odd");
  $("table tr:even").addClass("even");
});

You can make it more selective by changing the table part in $("table tr:odd") to something like table.stripe, so it will only apply to tables with a stripe class.

Of course you’ll have to throw in some CSS so the even and odd classes actually do something:

table tr.odd {
  background-color: #fff;
}
 
table tr.even {
  background-color: #f3f3f3;
}

SSH Host Aliases

Tuesday, November 18th, 2008 By: Wes Bangerter

If you use SSH from the command line you can save yourself some typing by aliasing the servers hostname to something shorter. There’s a bunch of different ways to get similar results, but I prefer to use the built in SSH functionality for this. Create a ~/.ssh/config file. The syntax is:

Host server
HostName server.example.com
User username
 
Host another
HostName another.example.com
User username

Now you can just ssh server instead of ssh username@example.server.com. SCP also works great with these aliases, just scp file.txt server:/path

You can leave the User part out of the config file if your local and remote usernames are the same.