Create The Internet… It's What I Do EVERY Day – Joseph Yancey

21Nov/092

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.

Filed under: Uncategorized 2 Comments
16Oct/090

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&longUrl='.urlencode($url).'&login=goywp&apiKey='.$appkey.'&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.  
Filed under: Uncategorized No Comments
16Sep/090

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

Filed under: Uncategorized No Comments
30Aug/091

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. }
Filed under: Uncategorized 1 Comment
26Jul/090

Gmail HTML 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.

Filed under: Uncategorized No Comments
18Apr/090

First Post!

Just switched to WordPress...  Still in twitter mode.  Posts shall be short!  By the way,  WordPress is pretty cool.  The backend could be labled a little better.  Has anyone ever heard of using the title tag on a link to explain what the link is?  Guess not...

I'm out...

Filed under: Uncategorized No Comments
   

Buy Me a Beer

Well not really a beer
More like a Dr Pepper...