LinuxGeex.Com: Mild-Mannered Advocacy
Articles Consistent, Cross-Browser "click()" Method Support. March 23rd 2012

Click. I'm not ashamed to say I've used the .click() method a lot.

It's only supported for some elements in Chrome, and wasn't supported in Firefox at various points. Why? Well, that's the topic of some debate... but if you use the jQuery framework, here's a simple way to get .click() for all your elements.

if (!HTMLElement.click) HTMLElement.prototype.click=function(){$(this).click();}

Caveats: Adding a click() method to all elements may cause a lot of extra overhead to the bubbling of click events. If you have a very complex page and think this might have a performance impact, then either don't use it (and suffer the incompatibility issues) or, perhaps, modify jQuery itself to add this method only to elements to which a click event is bound.

Here's a legitimate use of this feature:

click me to make my bg red
* I should be red already!

click me to make my bg red

click me to make my bg red

click me to make my bg red

click me to make my bg red

<div id=&dquot;id&dquot;> <p class=class>click me to make my bg red * I should be red already!</p> <p class=class>click me to make my bg red</p> <p class=class>click me to make my bg red</p> <p class=class>click me to make my bg red</p> <p class=class>click me to make my bg red</p> </div> <script src=&dquot;http://code.jquery.com/jquery-1.4.2.min.js&dquot;></script> <script src=&dquot;http://ukcom.org/l/j/jquery.combined.min.js&dquot;></script> <script> $().ready(function(){ $(&dquot;#id .class&dquot;).click(function(){ $(this).css({background:&dquot;red&dquot;}); })[0].click(); }); </script>

Articles Colour-Key, Box-Warp, Non-Linear Gradient, Transparency... March 23rd 2012

Gorgeous, reusable graphics are just a few clicks away with PHP/GD.

These techniques can be a little heavy on the server, so make sure you use server-side caching (EAccelerator, MemCached, etc) and/or proxying to lighten the load. Here's some examples of what can be done.

It may seem odd, but this is actually the first PHP project I ever wrote. I had to fix a problem with a PHP installation which involved a bug in GD. I had never used PHP or GD before, and after fixing the bug I was intrigued by what was possible with the functions I saw.

Here's some with different gradient backgrounds. You can leave the background transparent, or make it a flat fill too, but that would be boring. ;-)

small button blue small button cyan on shelf more...
Using jQuery Validation Plugin, with working example. 2012-02-01

Client side validation is a whiz with the jQuery Validation plugin. Here's a simple example with some defaults specified in the script section at the bottom of the page source.

Basically, design you form as usual, but bear in mind to keep enough room around your elements for the error notifications. Define your valid datatypes using the type attribute. Some additional features can be enabled by adding certain classes, such as "required". more...

A short story about choices ;-)

Someone once asked me why I would choose Linux over Windows.

To them, it seemed incredible that anyone would want to use anything else, since it's obviously the best platform, "after all, everyone uses it."

The Jewish People have an expression that goes along the lines of "If nine out of ten people believe something, it's probably right. If ten out of ten people believe something, it's questionable." This thinking came about due to millenia of wisdom passed from generation to generation, and the observation of the wisest of their leaders - recognising the fallibility of a group where convention is too readily accepted. When we stop thinking independantly, we become thoughtless.

Windows is for the masses for a variety of reasons, but mostly due to (bah) convention. Some use MacOS because they want a stylish and unconventional product.

The principle irony of the story behind user decisions whether to run Linux vs Windows is that new users are afraid nobody will help them...

more...
Painless Encrypted Cloud Storage - 2011-05-21

Ever lost data? I've suffered disk failures twice and learned my lesson. Now I have a cloud FTP service which runs me about $100 per year, and a USB RAID1 (Western Digital WorldBook) which was $300ish when I got it, now a fair bit less expensive. I use both rsync and duplicity: rsync creates a mirror; duplicity creates a revision history. I have them on crons, you may want to do something else.

# To install the software:

sudo apt-get install rsync duplicity curlftpfs encfs
more...
DWIM-ish programming in PHP and Javascript (article in progress)

Programming in dynamic languages gives us flexibility which in turn provides us opportunities for rapid prototyping and often much faster development times as well.

With all this flexibility comes a cost in performance, and also often a cost in validating datatypes to ensure that we are doing sane things. There's not really any compiler to tell us not to pass an integer as an array, for instance. In the case of PHP it will typecast it to string and then to array, for example '$num=4096; echo $num[0];' will produce '4' as output, without any warning.

more...
Powered by jEdit 4.3.2, the Programmer's Editor. Powered by SiteWrapper 1.0.1, the ultralight PHP CMS. Powered by LG Solutions, the web design professionals