Friday, November 28, 2008

[Tip] CSS: Multiple classes in an element

When one knows this one, it seems obvious. But when one doesn't it comes as welcome as a breath of fresh air that one can use more than one class to style an element.

Example:

<p class="MyMainCssClass AnotherCssClass">The paragraph's content here.</p>

Remember that the cascading effect still applies. Properties in AnotherCssClass will override those same properties in the MyMainCssClass class.

PS: Our CSS course is getting ever more popular. This is good as I really would like to encourage designers to use more CSS and do it smarter. See our course schedule for the next course.

Characteristics of a True Programmer

While programmers come in all shapes and sizes and from just about any ethnic group with no gender, race or age boundaries, there are common characteristics all programmers share. These are:

1. Works long hours
I have not come across a competent programmer that doesn’t work extra hours. Even the weekend programmer puts in a lot of time on weekends. This one seems always to be true. Ask the spouses and friends of real programmers. Even though this one is a pity in some ways – it seems that a “programmer” that does not follow this characteristic will not be much of a programmer even after years of training.

2. Does lots of research
All real programmers I have encountered spend a significant amount of time researching. They are always looking for new and better ways to do things or simply finding out how to do some task he/she doesn’t know how to do.

3. Is curious
Programmers are constantly curious about new things and techniques.

4. Tries to solve own problems
Sometimes, irritatingly so, programmers don’t want to be helped. They only ask for clues to a problem. After that they want to solve it themselves.

5. Experiments with new ideas and techniques
True programmers frequently have something new to show. The programmer might be a show-off or not. You might have to prise the idea out of him/her – but it will be there. Even new programmers show this characteristic early on.

6. Problem solver
A true programmer is a problem solver. While this may not extend into his/her personal life, it is certainly true for his/her programming challenges. The problem solving is not always in a straight line. Other techniques like lateral and predictive thinking are crucial techniques in a programmer’s life.

By the way, the above is true even for the week old programmer. If these characteristics don’t show up early on, then you don’t have a real programmer in the making.

Monday, November 10, 2008

[Tip] JavaScript: How to do a Ctrl-Click

You may want to make a link (or some other element) work when you hold down the Ctrl key before clicking the link.

This is possible in modern browsers and is done as follows:

document.onmousedown = clickElement;
function clickElement(e) {

var ctrlPressed = 0;
var evt = (navigator.appName=="Netscape") ? e : event;
ctrlPressed = evt.ctrlKey;
if (ctrlPressed) {
// Place code to run when Ctrl-Click done
}
return true;
}

Take note the above code works on the whole page and I have tested this on all top browsers:
IE 7, Firefox 3, Chrome, Safari and Opera 9.

Hope it helps someone.

Hectic Week

In case you have been wondering when my next post is coming... Well, I am back.

I had rather hectic week last week. I ran both an evening class and a day class. To make things even more hectic, the day class was on the other side of Pretoria - a two hour drive from my office.

So needless to say, last week was rather tiring.

But both courses went very well. The students were really happy and learnt a lot:-)

This week is the ASP.NET Course. I even have a student all the way from Port Elizabeth! Wow! Welcome, Andrew and thanks for taking the trouble to come so far.