Always Get Better

CSS Sanity: Remember Best Practices When Using New Tools

February 15th, 2010

Now that the rebellion against IE6 has hit mainstream, a brave new world of CSS3 and HTML5 has been opened to web professionals.

Beware Mixing Purposes
CSS is intended to define the appearance of elements, not their behaviour. Be very careful about “overloading” CSS to accomplish tasks best performed by JavaScript.

A popular example of poor CSS usage is drop-down menu lists. Some web programmers use CSS’ :hover selector to instruct the web browser to display sub-navigation when the user hovers over a list item.

ul#menu li:hover ul { display: block; }

This is much better accomplished using a touch of jQuery:

jQuery("ul#menu ul").css({display: "none"}); // For Opera
jQuery("ul#menu li").hover(function(){
jQuery(this).find('ul:first').css({visibility: "visible", display: "none"}).show(268);
},function(){
jQuery(this).find('ul:first').css({visibility: "hidden"});
});

Not only is this example less dependent on consistent web browser support for the CSS :hover selector, we’ve even thrown in a spiffy little roll-out animation.

Keep It Simple
The nth-child selector is one that stands to be abused by overzealous developers. Imagine this: change the display of every nth element as defined through an algebraic expression.

Why is this a bad thing? CSS is run in the same memory space as the general web page – that’s why it’s so fast. JavaScript tends to be isolated; meaning if you make an infinite loop in JavaScript, the web browser will eventually stop it from running. If the same thing happens in CSS, your web session is probably toast.

Separate Logic from Presentation
CSS was a leap forward because it separated presentation from structure; rather than programming font and colour elements, designers were able to explicitly control the way their web page appeared on screen. HTML was being used to serve the purpose CSS was designed to cover.

More recently, CSS has become a crutch to enable functionality better suited for JavaScript. When unsure about which to use, ask yourself: Does this solution affect only the display, or is some action happening?

  • Share/Bookmark

iTunes – The Future, or Just a Toy?

February 6th, 2010

Following iTunes’ development has been an interesting experience. We’re moving toward a world in which physical packages of music is a thing of a past; in the meantime we’re stuck with a middling service.

My complaint goes something like this:

My wife recorded Grey’s Anatomy; when she was watching her tape the next day, she was surprised to find advertisements telling her the story from her episode was being continued in a crossover Private Practice on a different channel. Oops.

So I went on iTunes and bought her the episode she missed. $3.50 is pretty steep for a 40 minute TV show but that’s the price you pay for the convenience. After enjoying the program, my wife decided she wanted to see the rest of the season – so I bought that for her too.

When you buy a season of TV, iTunes warns you that any previously purchased episode will be downloaded again – essentially you’d be paying for it again. I can handle that – it makes sense that an item would be sold individually and part as a collection.

Two problems (both stemming from me not digging deep enough into the literature, but also totally unreasonable):
1. When I was billed for the season, I was billed individually for every episode, at the full $3.50 rate. So there was no reason to double-bill me for the episode I’d already purchased since the billing wasn’t based on a ‘full season’ – why is the system unable to correlate previous purchases and prevent the double-purchase?

2. I thought I was buying a whole season of the show – in fact I only bought the episodes that had already been released. A “Season Pass” (pay for the season and new episodes download as they become available) is something completely different… it would have been nice to have been informed of the difference.

$42 is a lot of money to pay for 11 episodes of TV. I don’t think I’ll be dropping a lot of money into iTunes when I can pay half that amount for a full season on DVD – not to mention get the benefits of hard copy, physical media.

My verdict: iTunes is an interesting model and was a fun experiment for us, but not at all cost effective. Bandwidth can be expensive, but the cost of distributing digital media is essentially $0. I would have thought TV episodes could be sold for less than $1 and still make a healthy profit for the content creators (no manufacturing costs, no distribution, no retail partners — Apple takes a cut and the rest is pure profit). What can I say, I was the one who got suckered into paying double the price for half the product.

  • Share/Bookmark

Wamp Server Crashes Installing X-Cart

January 24th, 2010

When running a default installation, WAMP Server’s Apache crashes when installing X-Cart. The error happens immediately after setting up the MySQL tables and is caused by the curl extension in PHP.

To resolve, click on the WAMP Server icon in the task tray, go to Apache -> Version -> Get More. Download one of the 2.0 series Apache servers and install it.

Repeat the process for PHP; download one of the 5.0 series PHP versions and install it.

Switch WAMP Server to the new versions and run the install again – it should work with no problems.

  • Share/Bookmark

A Simple Makefile for the Go Language

January 19th, 2010

Hey folks, it’s been awhile!

I’ve been playing with Google’s Go language, and will be sharing what I’ve learned over the coming weeks.

First off, which seems like the easier way to compile your source code? This:

6g fib.go
6l fib.6
mv 6.out fib

or this?


make

Personally, I prefer using a Makefile, even for a small project with one source file.

Without further adieu, a simple Makefile for the Go Language:


GC = 6g
LD = 6l
TARG = fib

O_FILES = fib.6

all:
make clean
make $(TARG)

$(TARG): $(O_FILES)
$(LD) -o $@ $(O_FILES)
@echo "Done. Executable is: $@"

$(O_FILES): %.6: %.go
$(GC) -c $<

clean:
rm -rf *.[$(OS)o] *.a [$(OS)].out _obj $(TARG) *.6

  • Share/Bookmark

279 Days to Overnight Success

November 16th, 2009
Victory!
Creative Commons License photo credit: quinn.anya

Chris Guillebeau offers his e-book 279 Days to Overnight Success for free on his blog. This is a great piece of writing that debunks the popular myths about “making it” blogging.

  1. Don’t rely on Google/Adsense as a “get-rich-quick” vehicle – they aren’t
  2. You don’t need millions of visitors and command of Digg to do well
  3. You will have to work hard
  4. Overnight success means ‘months or years’, not ‘days’

See for yourself – download it today.

  • Share/Bookmark

Living With First-Person Shooter Disease

November 14th, 2009

Some ailments have no cure…

  • Share/Bookmark

BrowsrCamp – Test Web Designs on Mac

November 13th, 2009

At last, remote desktop has a practical use!

If you are working on a web design and need to see how it will look on Mac, your only choice up until now has been to buy a low-end Mac. That’s an expensive proposition for occasional use. If you’re a web designer by trade you are probably already using a Mac anyway, but for the rest of us there is finally a better choice.

Head on over to BrowsrCamp – for a pittance ($3 gets you 2 days of access) you get to control a machine running OS X.

You can use VNC to connect to the server; if you don’t have or can’t install VNC, BrowsrCamp offers a web interface so you can access the machine directly from your browser.

It’s such a simple, wonderfully executed concept that should be in any programmer’s bag of tricks.

  • Share/Bookmark

SEO Powered by Platinum SEO from Techblissonline