Trigger Events When Elements Are Viewed

jquery lazy load anything

Run Javascript or jQuery when elements come into view of the browser.

    'onLoad': function(e, LLobj) {
        // Put your Javascript/jQuery goodness here

Download at Github

Is this just another “lazy load” plugin for images?

No, not really. It can definitely be used to do lazy load images. In fact, the example on my Github page shows how to use it as an image lazy loader. However, this little jQuery plugin goes a little farther. Certainly there are many useful lazy loader plugins but this can be used to do anything you want when any element of your choice comes into view of the browser.

By simply using a jQuery selector you can specify any elements that come into view of the browser to trigger an event for processing. In the jQuery plugin settings there are also events for executing code before any events take place or after all events have fired. Depending on the plugin settings you can also have the event fire once or every time it comes into view.

I’m not going to go too much into all the settings and whatnot here in the blog. All of the lazy load plugin settings are available on the Github home page. Don’t worry if you don’t use Github, you can just download the code. It is a very light and easy jQuery plugin so you shouldn’t too much trouble customizing it. Please fork the project if you would like to make fixes and add enhancements. I would greatly appreciate that ;)

Tagged with: , , , , , , ,
Posted in Technology

Linux ‘make clean’ is your Friend – MySQL Lenny Backports

Two days ago I had started work to upgrade the database on the development server. We plan to use Amazon’s RDS (Relational Database Server) which only runs limited versions for MySQL. As of this writing they are 5.5.8, 5.1.50, 5.1.49 and 5.1.48. Before I was running MySQL 5.0 on both the development and production servers. As a web developer, I know it is best to use the same MySQL and PHP versions on the development server and the production server. This way, after you have tested and developed your code on the dev box you can rule out any problems you might encounter when you upload your code to production due to different versions of PHP or MySQL. It is also a good idea to match Apache versions but not too important to match Linux kernels or distributions, at least not in my line of work.

I usually use packages to install programs on the Linux boxes as I use Debian. Currently, I am using Debian Lenny (version 5.0) on both boxes. I have used packages to install everything except PHP. The Debian Lenny stable packages for MySQL are only for MySQL 5.0 but I needed to upgrade that so I could match the MySQL version that will be used on Amazon’s RDS. I searched the Debian site and came across Debian Backports. This is an answer to using newer packages that aren’t available to Lenny. I found that Backports has a package for MySQL 5.1.49. I thought, “perfect,” now I can just install MySQL Backports package for Lenny and now my database versions would be the same.

I had to modify my /etc/apt/sources.list to include:

deb lenny-backports main

This was the right thing to do because when I went into aptitude and did a package update I was able to find the MySQL server and client 5.1.49. I went ahead and removed (purged) the old MySQL 5.0 packages and installed the following packages:


Each version was 5.1.49.

During install it asked me if I wanted to overwrite my my.cnf file. I guess I should have let it change it because when it tried to restart MySQL failed to start. I then kept trying to reinstall so it would go ahead and overwrite my old my.cnf file. I had to find an example MySQL conf file which can be located in /usr/share/doc/mysql-server-5.1/my-*.cnf. These files are example MySQL conf files for various size database servers. I chose the medium configure file as that best matched my old conf file. Doing so seemed to work as I was able to get MySQL running again.

I then went to access phpMyAdmin and it brought up a warning about how the PHP client didn’t match the MySQL version. So I knew I had to recompile PHP. I had used packages for everything except PHP because I had to customize PHP so much. I opened up a PHP dev file that uses the function phpinfo(). There I had the complete ./configure line that I used to originally compile PHP. After I ran the configure again, I ran make && make install. This went pretty fast but I didn’t think much of it. When I went to access my website I kept getting this error:

mysql_connect(): Headers and client library minor version mismatch

This one was the doozy. I searched and searched all over the internet to find an answer. I found a few things here and there which didn’t help. Everything I found is stuff I already did. I knew I had installed MySQL correctly with aptitude. I thought I was compiling PHP correctly. I couldn’t figure out why the PHP compilation was not using the new MySQL header code.

So after literally 8 hours of web searches, trial and error, and chatting on IRC with the nice guys at Cerberus who offer a CRM toolkit, I finally got my prayer answered. Yes, I said prayer. I prayed about it while in the bathroom. While chatting, I had asked how to remove something that was installed via a compile. He said to,

try make clean.

I tried it, it seemed to remove some things. Wouldn’t you know it, while running make && make install, it took considerably longer. I figured something new must be happening here. Apparently, that did the trick. I guess it recompiled the header files this time all the way around and overwrote the old ones that were left behind from the very first compile I did while I had MySQL 5.0 installed.

I really, really hope this post saves someone else a day’s work. If so, hit me up!

Tagged with: , , , , , , , , , , , , , , , , ,
Posted in Technology

Greek Letters in a Captcha

Most of us hate them, especially hackers and script kiddies. Captchas are used to thwart automatic form submissions to websites by bots and scripts. Security is important but the captchas have gone way too far. It’s one thing to distort the letters and use non-words but to use letters and characters not available on the standard keyboard just isn’t right. Almost all computer users have absolutely no idea how to access characters beyond what is on the keyboard. It requires holding down the Alt key and then pressing the number sequence on the number pad. For example, to type in the Spanish enya, ñ,  you have to hold Alt then type 1-6-4 then let go of Alt. I agree that internet security is import for webmasters, developers and admins but we can’t make it locked down so tight that even common folks can’t get in.

Here is an example of a captcha on site I was on the other day:

The second “word” – if you want to call it that – has two extended characters. The first is Sigma, Σ, Alt + 228. The third letter is the Euro, €, Alt + 0128. At the time I had to enter this on the page I just used a capital E which still seemed to work and maybe that is the point. But it threw me for a loop for a minute and I was a bit taken by it.

For a nice list of Alt codes. Check out this site: There are more codes you can access on the right navigation of this site which lets you see language and currency alt codes.

Tagged with: , , , ,
Posted in Technology

Flowertown Festival Summerville SC Odd Review

My wife and I went to the Flowertown Festival in Summerville yesterday. We came late at around 4:15pm. They posted on their site that it closes at 5pm. Most of the vendors were still rockin past that well into 6pm. The event was from Friday April 1st to Sunday April 3rd 2011.

At the entrance was a replica of the Hunley submarine which you could see inside.


Just a little far off in the distance you could hear a “Sweet Home Alabama.” On down the road there was a fun little mariachi band shown below (sorry about the dark pic).


The vendors seemed to be mostly local folks but I am not sure because we did not have time to talk to them. Most of the stands were selling crafts of some sort. The photo below is a picture of the main strip. This is Main St Summerville.


The photo below is a section that went perpendicular to the main strip. It was just a dirt path. I’m assuming this wasn’t the prime real estate spot for the vendors. I must have caught the kid there in mid sentence.


One of the vendors was selling fried artichokes which smelled absolutely delicious. We should have tried them because when we had walked back, they had already shut down.

There was another shop that was selling empty wine and liquor bottles that were melted flat that could be used as a serving tray. Some included the butter knife.

There were a few local painters and musicians selling their art and music. One musician went all out and had a ton of his CD’s with his music blasting. It sounded like an ameteur Yanni mixed with Celtic music.

Another vendor was selling aluminum beer mugs which you could fill up for free all day long with various flavors of root beer. One of which was sarsaparilla. It was a cool looking stand too. The front of which was all wood and had the beer barrels sticking out that poured the beer.

There was no alcohol stands that I could see but I guess I wasn’t looking for them.

I saw a bizarre vendor’s product which was crystal finger nail filers. Looked cool…I guess. I didn’t know crystal finger nail filers were so popular. It was a man selling them and I got to thinking, maybe he was a person who worked with glass. One day, he used an etched piece of glass to file his nail down and got the idea. I dunno, see, I should have gone early and spoke to some more folks. If he was a true salesman, I’m sure it would have been a better story.

There was another artist doing portraits as you might find at any festival of high caliber. These weren’t just any portraits, I think the dude might have been trippin on acid because the faces looked melted and droopy. It definitely did not rain on them if that is what you might have wondered.

Unfortunately, there were no rides that I could see around. Maybe next year.

The Shriners were there. I was surprised to see a young guy with a very ornate “one of those hats” on. Usually you see a bunch of old cronies wearing them but this guy could not have even been 40.

Of course you had the stores with clothes and jewelry. Nothing particular caught my eye. Maybe because I’m a dude and not into that stuff too much. Neither is my wife so she didn’t point anything out.

There was a kettle corn stand and a Bar Bee Que stand I wanted to try but my diet said “no.”

My wife and I did buy some food. We, of course, went to the booth with the largest banners. I got a lamb gyro and she got lemonade and a funnel cake. The gyro was a complete mess and dripped all over the place. I had asked for it without the bread because I am on a low carb diet and the dude, in kind of a Greek ancient, said, “how would I make a gyro?” Haha, I can only hope I wasn’t the first jerk to ever ask him that stupid question. They poured a ton of nasty ranch on it. It just wasn’t very good. My wife’s funnel cake was good but it was completely covered in powered sugar. Now I know…this is just festival food and I shouldn’t be so critical. Agreed, I am just doing this for the blog ;)

The BEST stand I think was the mini doughnuts. Not only were the doughnuts mini but so was the doughnut frying machine. The whole thing was about the size of two keyboards and was complete with an automatic doughnut flipper halfway down the fryer. If you haven’t seen a doughnut frying machine you got to check one out. Then size it down to about 4 feet wide. It was so cute. Made you want to buy a doughnut just for the novelty of it. There was I sign that said, “Don’t bump or shake the table.” Understandably so mister mini doughnut man who wasn’t very mini at all.

Now that I am writing all of this, I really wish I took my pictures. I am an ameteur blogger so maybe next time will be better.

Below is a picture of a pretty path that was close by. It looped around and had a nice white bridge going over a small stream. I didn’t see any fish in there.


El fin.

Tagged with: , , , , , , , ,
Posted in Events, Food

Yahoo App Sucks

I have been using Yahoo mail for a long time now. I prefer Yahoo email on my desktop browser because I am able to use tabs that they make available via javascript.

I recently got a smart phone. I got an HTC Inspire Android. Up until just 3 weeks ago, yes I know, pathetic for a web programmer, I had a crappy Samsung flip phone which was only ok at the about 6 years ago. So naturally I got the email Yahoo app.

My biggest complaint, and really the only one, is that the email browser window cannot resize using two fingers like most other app windows do like in the FireFox app. You also cannot move the window diagonally. You have to wait until the screen is locked until you can move it in a perpendicular position.

Yahoo please fix.

Posted in Technology

Cholula Chipotle Hot Sauce Review


I recently picked up a bottle of Cholula’s Chipotle hot sauce. I have to say that is is pretty good. I have always liked Cholula since I was introduced to it at my local Mexican Restaurant. I am an amateur connoisseur of hot sauces but Cholula has a classic good taste. Not too hot and plenty of flavor. The chipotle (smoked jalapeño) has a real nice taste and is not overpowering. I had it on some baked chicken and it tasted great. If you understand the taste of chipotle and like it – meaning you aren’t just enchanted by the word – I definitely recommend it. If you aren’t familiar with the chipotle taste, give it a try. It is a good example of the unique chipotle taste.

Tagged with: , , , , , , ,
Posted in Food

Best PHP Mail Class

I wrote this class. It works great! You can send just about as many attachments as you like and include HTML in the message. The only bug is that every email looks like there is an attachment. Hope this helps.

class Email {

// Public Variables
public $To = "";
public $Title = "";
public $Message = "";
public $From = "";
public $FromName = "";
public $ReplyTo = "";
public $ReplyToName = "";
public $ReturnPath = "";
public $ReturnPathName = "";
public $Headers = "";

private $Boundry = "";
private $Attachments = array();
private $FinalData = "";
private $EOL = "\r\n";
private $FinalHeaders = "";

* Send - Send Message based on Populated Class Vars
* Will return false, and fail to send message, if required fields are empty.
* @access public
* @return bool True on Success, False on Failure
public function Send() {

if ($this->To && $this->From) {
// Build Email

// SEND IT!!!
return mail( $this->To, $this->Title, $this->FinalData, $this->FinalHeaders );

} else {
throw new Exception('"To" and "From" properties (email addresses) must be set before sending email');


* AttachFile - Include file to be sent as an attachment
* @access public
* @param string $filename
* @param string $contents
* @return bool True on Success, False on Failure
public function AttachFile( $filename, $filetype, $filedata ) {

$this->Attachments[] = new Attachment($filename, $filetype, $filedata);


/* -- Private Functions -- */

* Put the email string all together
* @access private
private function BuildEmail() {
// Set boundary
$this->Boundry = md5(uniqid());

// Build main headers

// Start first boundary
$this->FinalData .= "--".$this->Boundry.$this->EOL;

// Assemble message

// Assemble attachments

* IncludeMessage - Includes message into FinalData string
* @access private
private function IncludeMessage() {
$this->FinalData .= "Content-Type: text/html; charset=\"iso-8859-1\"{$this->EOL}";
$this->FinalData .= "Content-Transfer-Encoding: 7bit".$this->EOL.$this->EOL;
$this->FinalData .= $this->Message.$this->EOL.$this->EOL;
$this->FinalData .= "--".$this->Boundry.$this->EOL;

* IncludeAttachments - Include previously attachmented files into FinalData string
* This method should never be called explicitly, as it is called from within the
* `Send` function.
* @access private
private function IncludeAttachments() {

foreach ($this->Attachments as $attachment) {
$this->FinalData .= "Content-Type: ".$attachment->filetype.$this->EOL;
$this->FinalData .= "Content-Transfer-Encoding: base64".$this->EOL;
$this->FinalData .= "Content-Disposition: attachment; filename=\"{$attachment->filename}\"".$this->EOL.$this->EOL;
$this->FinalData .= chunk_split(base64_encode($attachment->filedata));
$this->FinalData .= "--".$this->Boundry.$this->EOL;


* BuildHeaders - Compile headers from member vars
* This method should never be called explicitly, as it is called from within the
* `Send` function.
* @access private
private function BuildHeaders() {

$headers = "";

// From
if($this->FromName) $headers .= "From: ".$this->FromName." From.">".$this->EOL;
else $headers .= "From: {$this->From}{$this->EOL}";

// Reply-To
if(!$this->ReplyTo) $this->ReplyTo = $this->From;
if($this->ReplyToName) $headers .= "Reply-To: ".$this->ReplyToName." ReplyTo.">".$this->EOL;
else $headers .= "Reply-To: {$this->ReplyTo}{$this->EOL}";

// Return-Path
if(!$this->ReturnPath) $this->ReturnPath = $this->From;
if($this->ReturnPathName) $headers .= "Return-Path: ".$this->ReturnPathName." ReturnPath.">".$this->EOL;
else $headers .= "Return-Path: {$this->ReturnPath}{$this->EOL}";

// Message-ID
$headers .= "Message-ID: ".$this->EOL;

// X-Mailer ... dunno wut foh
$headers .= "X-Mailer: PHP v".phpversion().$this->EOL;

// MIME-Version
$headers .= "MIME-Version: 1.0{$this->EOL}";

// Content-Type, DO NOT CHANGE, must stay for attachments and whatnot
$headers .= "Content-Type: multipart/mixed; boundary=\"{$this->Boundry}\";{$this->EOL}";

// Append additional headers although there probably shouldn't ever be any
$this->FinalHeaders = $headers . $this->Headers;


class Attachment {
public $filename;
public $filetype;
public $filedata;

public function __construct($filename, $filetype, $filedata) {
$this->filename = $filename;
$this->filetype = $filetype;
$this->filedata = $filedata;

Tagged with: , , , , , , ,
Posted in Technology

Get every new post delivered to your Inbox.

Join 214 other followers