The following articles were authored by Joseph Yancey

For you Grandpa

For as long as I can remember, my Grandpa has always been there for me. When life was unstable (which my almost always was), my Grandpa was the one consistent person around. From the time that I was about two, Grandpa always came to the house and picked me up for church every Sunday mornings. He taught me the importance of giving. If I didn’t have money for offering, he always had a dollar for me to give. After church, we would go to eat at the local cafe. We sat and talked for hours at that cafe. Sometimes the talk revolved around family, sometimes around fishing, but mostly we talked about God. Grandpa was always a religious person.   We sat and shared our views on the bible at that little cafe.  I really did learn a lot from him.

Anything that my Grandpa did, he did very well.  Before I knew my Grandpa, he was a Police officer.  He protected people.  I think that speaks magnitudes about his character.  For most of my life he was a handyman of sorts.  Mostly he hung wallpaper and painted houses.  He made peoples homes look better.  Between both of these jobs and odd projects on the side, my Grandpa has had his share of downfalls.  He has been shot, stabbed, ran over, electrocuted, had multiple open heart surgeries, and battled leukemia.

On December 26th 2010 my Grandpa passed away.  I just wanted to write this post to show what my he meant to me. He was a father when I had none and a leader when I needed one.

Grandpa, thank you.

New Directions

As most of you already know, I will be taking a big step in life this week.  I am moving to another state.  My wife and I arrived at this decision after much thought.  We are both from Arkansas and we love this place.  Arkansas is beautiful and natural.  Why would anyone ever want to leave?  It really comes down to two things.

Number 1: As beautiful as Arkansas is, there is no tech industry here.  Arkansas tends to move at a little slower pace then the rest of the world.  That’s not a problem if you grow rice or make potato chips but for technology, it’s like shooting yourself in the foot.  I have already peaked in this area.  I don’t want to be a big fish in a small pond with no room to grow.  I want to learn and grow at my own pace be it fast or slow.  I want to control my destiny.

Number 2: My wife’s parents will live minutes away from us.  Amara is very close to her mom and I am too.  I couldn’t have hoped for better in-laws.  This isn’t one of those “honey, get your mom to stop nagging me” kind of situations.  I really do love her parents and I feel closer to them then I do to my own family.  I mean no offence to my family but we just aren’t close.  My family fits Arkansas.  They will probably be buried within 50 miles of the place where they were born.  I feel the need to carve my own path through life and my family doesn’t.

There are some negatives to moving.  My son will probably not know much of his grandmother (would he have anyway?)  I have gotten very close with some of my friends here in Arkansas.  I will miss them greatly.  I do feel that we will be able to maintain a close friendship across any distance but you always loose something with distance.  We are techie so we will make sure that we stay in contact.  I’m not worried about that.  It’s just that when your whole family starts to become friends with another whole family, you’re going to miss just having dinner together.  The same goes for my wife’s sister’s family.  We have grown very close to the O’neils and we will be very sad to leave them.  My son and his cousins are very close in age and I wish that he could grow up knowing them.  Maybe he still will.  Only time will tell.

I am excited about this specific job.  I will be making more, have more room for growth, less upfront responsibility, and the people running this company actually know what is going on.  My old job was not a bad job.  I actually enjoyed the work.  It was the management that was the problem.  They had no clue how to successfully run a company.  This was a creative environment, not a factory.  Programmers and Designers are not “Resources”.  The company will be nothing without them.  They will understand that very clearly when they have no “Resources” left.  When your employees are so afraid that their checks will bounce that they all race to see who can get to your bank first to make sure that they can get cash to go deposit into their bank you obviously have a problem.  I may be the only one moving across the country but I will not be the last to leave.  I am just glad that I got out when I did.  Do you remember Roosevelt’s proposed second bill of rights?  Well, that’s what I’m shooting for.

Viva la Revolution!

MySQL Joins

I hated joins as a young developer.  I just want the world to know that.  Once I found out exactly how they worked, I didn’t hate them at all.  Joins can be your friend.

Joins simply relate rows in one table with rows in another table.

Take these tables for example:

Books
+---------+-----------+
| book_id | author    |
+---------+-----------+
|   1     |     joseph|
|   2     |     john  |
|   3     |      sue  |
|   4     |     NULL  |
|   5     |     john  |
|   6     |     sam   |
+---------+-----------+

Authors
+---------+-----------+
| author  | sex       |
+---------+-----------+
|   joseph|     male  |
|   john  |     male  |
|   sue   |     female|
|   lucy  |     female|
|   sam   |     NULL  | <- lets just pretend we don't know
+---------+-----------+

In MySQL, there are three important types of joins.  There are:

  1. Inner Joins
  2. Left Joins
  3. Right Joins

Inner Joins

Inner joins combine rows that have matches in both tables.  There will be no nulls left in the resulting table at all.  This query would be written like:

  • select * from Books, Authors where Books.author = Authors.author
  • or
  • select * from Books inner join Authors on (Books.author = Authors.author)

You will get back:

+---------+---------+-----------+
| book_id | author  | sex       |
+---------+---------+-----------+
|    1    |   joseph|     male  |
|    2    |   john  |     male  |
|    3    |   sue   |     female|
|    5    |   john  |     male  |
+---------+---------+-----------+

Left Joins

Left joins take all results from the left table and combine the matching results from the right table. This query would be written like:

  • select * from Books left join Authors on (Books.author = Authors.author)

You will get back:

+---------+---------+-----------+
| book_id | author  | sex       |
+---------+---------+-----------+
|    1    |   joseph|     male  |
|    2    |   john  |     male  |
|    3    |   sue   |     female|
|    4    |   NULL  |     NULL  | <- because there isn't an author to match
|    5    |   john  |     male  |
|    6    |   sam   |     NULL  | <- because we don't know sam's sex
+---------+---------+-----------+

Right Joins

Right joins are exactly like left joins but they will give all results from the right table while matching the left table to it. This query would be written like:

  • select * from Books right join Authors on (Books.author = Authors.author)

You will get back:

+---------+---------+-----------+
| book_id | author  | sex       |
+---------+---------+-----------+
|    1    |   joseph|     male  |
|    2    |   john  |     male  |
|    5    |   john  |     male  | <- john is here twice because there are 2 matches in the left table
|    3    |   sue   |     female|
|    NULL |   lucy  |     female| <- because this is a right join and lucy is in the right table
|    6    |   sam   |     NULL  |
+---------+---------+-----------+

Find files in PHP

There is a super easy way to get all files matching some particular pattern in PHP. In comes “glob”. It sounds like some slimey green goop but really it is quite handy. Glob will return an array of files that match a pattern. Handy huh?

  1. $files = glob("*.txt");
  2. foreach ($files as $filename) {
  3.     echo "$filename size " . filesize($filename) . "\n";
  4. }
  5.  

jQuery – Mouseover Fade

This one is really simple. You just make sure that you have jquery included on the page. Then you create a div like this:

  1. <div id="whateveryouwant"" onmouseover="$(this).fadeTo(‘fast’, 1)" onmouseout="$(this).fadeTo(‘fast’, ’0.33′)">
  2.    Content
  3. </div>
  4. <script type="text/javascript">
  5. $(document).ready(function(){
  6. $(‘#whateveryouwant’).fadeTo(‘fast’, ’0.33′);
  7. });
  8. </script>
  9.  

That code should be very easy to understand.

In sit amet nulla. Curabitur ligula metus, bibendum nec, ullamcorper sed, ullamcorper sed, ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis luctus laoreet leo? Praesent euismod accumsan turpis. Curabitur non diam. Curabitur condimentum, leo ut tincidunt feugiat; massa lorem blandit metus, a volutpat augue tortor nec sem. Suspendisse ac leo nec quam suscipit mollis. Fusce iaculis accumsan nunc. Nam viverra, urna sit amet molestie pretium, ante tellus volutpat neque, quis tristique felis elit sed magna. Nulla condimentum. Etiam vitae lacus in est laoreet egestas.
Nulla porta orci pulvinar tellus. Ut lorem purus; consequat ut, bibendum vel, sagittis sit amet, mauris. Etiam elit sem, rhoncus lobortis, dapibus vitae, convallis eu, enim. In ipsum augue, volutpat pulvinar, molestie non, accumsan eget, turpis. Sed porttitor tincidunt purus! Nunc fringilla, ipsum id cras amet.
In sit amet nulla. Curabitur ligula metus, bibendum nec, ullamcorper sed, ullamcorper sed, ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis luctus laoreet leo? Praesent euismod accumsan turpis. Curabitur non diam. Curabitur condimentum, leo ut tincidunt feugiat; massa lorem blandit metus, a volutpat augue tortor nec sem. Suspendisse ac leo nec quam suscipit mollis. Fusce iaculis accumsan nunc. Nam viverra, urna sit amet molestie pretium, ante tellus volutpat neque, quis tristique felis elit sed magna. Nulla condimentum. Etiam vitae lacus in est laoreet egestas.
Nulla porta orci pulvinar tellus. Ut lorem purus; consequat ut, bibendum vel, sagittis sit amet, mauris. Etiam elit sem, rhoncus lobortis, dapibus vitae, convallis eu, enim. In ipsum augue, volutpat pulvinar, molestie non, accumsan eget, turpis. Sed porttitor tincidunt purus! Nunc fringilla, ipsum id cras amet.

My life Changed

On November 20th 2009 at 4:50pm my life changed. My son was born. At 7 pounds 6.5 ounces and 21 inches long he is a long skinny little guy. He has a head full of hair and looks like his daddy. I always wanted a family of my own and now I have it. My wife, my son, and I now make up my happy little family. He is quite perfect. I have pictures posted here.

Bit.ly API function

Everyone knows about the bit.ly url shortening service. I have created a php function to automatically shorten a url passed to it. First, you need to go to bit.ly and signup for an account.  You will need your api key and your username.  With my function, you simply insert your api key and username and it will return a shortened url to you.

If you notice, this function will retry 5 times before it gives up.  That is because bitly will only allow 3 concurrent requests per IP.  My function also will only make the request to bit.ly once per page per session.

  1.  
  2. function getTinyURL($url, $counter = 0){
  3.    global $_SESSION;
  4.  
  5.    if($_WP_SESS[‘bitlyurl’][$url]){
  6.       return $_SESSION[‘bitlyurl’][$url];
  7.    }
  8.    $counter++;
  9.    if($counter > 5){
  10.       return $url;
  11.    }
  12.    $login = ;
  13.    $appkey = ;
  14.    $bitly = ‘http://api.bit.ly/shorten?version=2.0.1&amp;longUrl=’.urlencode($url).‘&amp;login=goywp&amp;apiKey=’.$appkey.‘&amp;format=xml’;
  15.    if($response = file_get_contents($bitly)){
  16.    //Debug::printvar($response);
  17.       $xml = simplexml_load_string($response);
  18.       if($xml->results->nodeKeyVal->hash){
  19.          $result = ‘http://bit.ly/’.$xml->results->nodeKeyVal->hash;
  20.          $_SESSION[‘bitlyurl’][$url] = $result;
  21.          return $result;
  22.       }else{
  23.          if($xml->results->nodeKeyVal->errorCode == 1206){
  24.             return $url;
  25.          }else{
  26.             return Request::getTinyURL($url, $counter);
  27.          }
  28.       }
  29.    }else{
  30.       return Request::getTinyURL($url, $counter);
  31.    }
  32. }
  33.  

reCAPTCHA

reCAPTCHA ExampleI’m sure that you have seen a captcha somewhere on the web.  A captcha is an image that you have to type the contents of to continue on in a form.  We use them at work from time to time.  I’ve been interested in but never used the reCAPTCHA system.  Recently purchased by google, I get the feeling that they will see alot more use in the coming months.

reCAPTCHA is a system that solves two problems in one.  Optical Character Recognition has always had the issue of hard to read words.  Computers simply can not read quite like humans.  This is precisely why captchas work so well.  To defeat a captcha and spread spam, a bot would have to be great at OCR.  reCAPTCHA takes scans of old books and presents them to users.  One of the words presented is known and the other is unknown.  When a certain number of people answer the same on the unknown word, it is considered known.  Using the reCAPTCHA system, we are digitising books one word at a time.Sample OCR

Bank Routing Number (ABA) Algorithm

At work, I have recently had to work on some validation for bank routing numbers.  Through much research, I have discovered the algorithm.  Check

The number that I am talking about here is the ABA Routing Number.

We’ll start with a routing number like 231381116. Here’s how the algorithm works. First, strip out any non-numeric characters (like dashes or spaces) and makes sure the resulting string’s length is nine digits,

2 3 1 3 8 1 1 1 6

Then we multiply the first digit by 3, the second by 7, the third by 1, the fourth by 3, the fifth by 7, the sixth by 1, etc., and add them all up.

(2 x 3) + (3 x 7) + (1 x 1) +
(3x 3) + (8 x 7) + (1 x 1) +
(1 x 3) + (1 x 7) + (6 x 1) = 110

If the resulting number is an integer multiple of 10, then the number is valid. To calculate what the checksum digit should be, follow the above algorithm for the first 8 digits. In the case above, you would come up with 104. Thus, to make the total number an integer multiple of 10, the final check digit must be 6.

Enough with the details, on with the algorithm!

PHP5

  1. function validateABA($number){
  2.    //strip everything but numbers (dashes and whatnot)
  3.    $number = ereg_replace("[^0-9]", "", $number );
  4.  
  5.    //check the length of the number
  6.    if(strlen($number) != 9){
  7.       return false;
  8.    }
  9.  
  10.    //split the number into an array
  11.    $number = str_split($number);
  12.  
  13.    //run the number through our algorithm
  14.    $rval = $number[0] * 3;
  15.    $rval = ($number[1] * 7) + $rval;
  16.    $rval = ($number[2] * 1) + $rval;
  17.    $rval = ($number[3] * 3) + $rval;
  18.    $rval = ($number[4] * 7) + $rval;
  19.    $rval = ($number[5] * 1) + $rval;
  20.    $rval = ($number[6] * 3) + $rval;
  21.    $rval = ($number[7] * 7) + $rval;
  22.    $rval = ($number[8] * 1) + $rval;
  23.  
  24.    // check if it is an integer multiple of 10
  25.    if(is_int($rval/10){
  26.       return $rval;
  27.    }else{
  28.       return false;
  29.    }
  30. }

Gmail HTML Signature

Update:

This can all be accomplished directly in gmail now under Settings->General->Signature

gmail html signature

Those of us that use Gmail know that adding an HTML signature can be a pain in the behind.  Typically, Gmail only allows standard plain text signatures.  I have discovered a  great Firefox plugin named Blank Canvas Gmail Signatures.  This plugin allows you to easily add signatures to each sending address within your account.

Simply compose a message and click “Create Signature”.  Once you have done that for the sending account that you want, your screen will look something like the image on the right.  From now on out, any email that you send from Gmail on that computer will have whatever HTML signature you want.

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin