Thursday, December 16, 2010

Dual Mod 10 Check Digit

Check Digit Calculation - Note: The Last number of a CC Number is its check digit
  1. Start from the last digit and move to the first digit.
  2. Every other number is doubled.
  3. If it is a two-digit number, add the digits together.
  4. Keep a running sum.
  5. At the end, get the rightmost digit of the sum.
  6. Subtract that number by 10
  7. The rightmost digit of that number is the check digit
Example Calculation:
Number:  00123456789
Digit: 9 * 2 = 18 = (1 + 8) = 9
Sum: 9
Digit: 8 * 1 = 8 = (0 + 8) = 8
Sum: 17
Digit: 7 * 2 = 14 = (1 + 4) = 5
Sum: 22
Digit: 6 * 1 = 6 = (0 + 6) = 6
Sum: 28
Digit: 5 * 2 = 10 = (1 + 0) = 1
Sum: 29
Digit: 4 * 1 = 4 = (0 + 4) = 4
Sum: 33
Digit: 3 * 2 = 6 = (0 + 6) = 6
Sum: 39
Digit: 2 * 1 = 2 = (0 + 2) = 2
Sum: 41
Digit: 1 * 2 = 2 = (0 + 2) = 2
Sum: 43
Digit: 0 * 1 = 0 = (0 + 0) = 0
Sum: 43
Digit: 0 * 2 = 0 = (0 + 0) = 0
Sum: 43
Digit: * 1 = 0 = (0 + 0) = 0
Sum: 43
Rightmost Digit of Sum: 3
Check Digit: 10 - (3) = 7
Javascript Code to Calculate Check Digit:
function dualMod10(str,checkDigit){
                str=str+''; //Convert to string
                var weight=2; /* weight to apply to digit being checked */
                var sum=0; /* sum of weights */
                var digit; /* digit being checked */
                /* compute the sum */
                for (var cnt = str.length; cnt>0; cnt--){
                                digit = weight * (str.charAt(cnt-1));
                                /* add tens digit to ones digit to the sum */
                                sum = sum + Math.floor(digit / 10) + (digit % 10);
                                weight=weight==2?1:2;
                }
                /* subtract ones digit of the sum from 10 return ones digit of result */
var mod = (10-sum%10)%10;
                return (mod==(checkDigit*1) );
}
PHP Code to Calculate Check Digit:
function dualMod10($str,$checkDigit){
                $weight=2; /* weight to apply to digit being checked */
                $sum=0; /* sum of weights */
                /* compute the $sum */
                for ($cnt = strlen($str); $cnt>0; $cnt--){
                                $digit = $weight * ($str{($cnt-1)});
                                /* add tens digit and ones digit to the sum */
                                $sum = $sum + floor($digit / 10) + ($digit % 10);
                                $weight=$weight==2?1:2;
                }
                /* subtract ones digit of the sum from 10 return ones digit of that result */
                $mod = (10-$sum%10)%10;
                return ($mod==($checkDigit) );
}

Saturday, November 20, 2010

Password Generator

I've started using a random password generator for anything I don't have to remember, but that I will have in a file for webpage or something to use. I have it set for the max Godaddy database password's can handle. Godaddy says passwords must start with a letter though.

Javascript Decimal Error

(59.97-29.98-12.32-17.67) says it is off by -3.552713678800501e-15. Somehow it is off on the 15th decimal place. Weird. Happens all the time in Javascript. This article explains why: http://javascript.about.com/od/hintsandtips/a/Floating-Point-And-Javascript.htm

Friday, October 16, 2009

IE Trusted Sites not working

I was playing with Trusted Sites in IE. I set the security settings: Internet to High and Trusted Sites to Medium. I added youtube to the Trusted Site. I went to watch a video and it said I had the javascript turned off, which shouldn't have been true since I added it to the Trusted list. What I didn't add to the Trusted list was the domain that the Javascript and CSS files were coming from, which was http://s.ytimg.com. In case you were wondering, I viewed the source of the site to find where the JS and CSS files were coming from. I added it to the list and viola, worked. Had the same issue with NFL.com but same solution worked.

Monday, October 5, 2009

Six Flags Over Georgia

No Backpacks. Fanny Packs are OK.

Price to get in about 40.

Price to not wait in line an extra 43. I think it is the only way to go. Instead of doing about 5 things you get to do 13. Might as well just say it costs $85.

Move Outlook 2000 PST File

Move the file to the location you wish.

When you reopen Outlook it will say that your file can't be found. Browse to the new location. Do NOT open default folders if prompted to do so.

Close Outlook. Reopen. You will get a message saying the location has been changed for your folders, blah, blah, blah. Select Yes/OK to that.

That's all there is to it.

Found @ http://www.computing.net/answers/office/move-pst-file-outlook-2000/4768.html

To find PST

  1. In the Folders’ Navigation Pane, right-click Personal Folders or the name that appears for your .PST file, and then click on the Properties in the context menu.

    Note: This folder will always be a top-level folder in the Navigation Pane, in Mail.

  2. Click Advanced.
  3. In the Filename text box, the complete path and file name of the .PST file will be shown.

Tuesday, June 16, 2009

Table Dimensions

Ping Pong Table dimensions 9 ft × 5 ft × 30 inches high

Pool Table dimensions and room size minimums

I often wonder so I figured I would put it here so I could easily find it.