A Post after many drafts

The title really looks weird to me right now, but that is the truth. I have started many posts since the last published post but I was not able to carry the same motivation with which I started them and that resulted into an increment to the number of drafts on my blog (I hope this one goes through).

Anyways, a lot has changed since my last post on March 7th. I am no more working with any company and I am not living with my family anymore. This doesn’t mean that I am jobless and homeless but I have moved to Germany and this is why I had to quit from my job in Karachi.

I have come to the beautiful and small city of Weimar for my Masters. After working as a Software Engineer for 3 years I have now started my M.Sc. in Computer Science and Media from Bauhaus Universität, Weimar. It has been more than 2 months now, and I have experienced many things that I shall write about (very soon). I think such experiences are worth sharing like my first international flight, the unexpected warm welcome by a bunch of great Pakistanis already in Weimar, my observations about Germany and comparisons of similar things in Pakistan, my trip to Hamburg and a few more. I am hoping to gather enough motivation next time to start writing all these.

Markt Platz, Weimar

How to unlike a facebook page with timeline

All the fan pages/brand pages on facebook which are using timeline now don’t have an apparent unlike link so this is a quick tip to find that link.

Locate the settings link, just under the cover photo of a page besides message button, click on this link and you shall find the unlike button in the dropdown.

I have highlighted this in the screenshot below.

How to test Credit Card numbers using Luhn’s algorithm

Almost all credit card numbers used are generated using Luhn’s algorithm. Luhn’s algorithm is a simple checksum formula to validate variety of numbers. We can use the same formula for checking whether a given credit card number may be valid or not.

This can be used as a good technique to validate the credit card number in your web application. I found a simple function which validates any given number according to Luhn’s formula and gives the result to be true or false. The function is implemented in PHP and the primary source of this function is here.

<?php
function is_valid_luhn($number) {
  settype($number, 'string');
  $sumTable = array(
    array(0,1,2,3,4,5,6,7,8,9),
    array(0,2,4,6,8,1,3,5,7,9));
  $sum = 0;
  $flip = 0;
  for ($i = strlen($number) - 1; $i >= 0; $i--) {
    $sum += $sumTable[$flip++ & 0x1][$number[$i]];
  }
  return $sum % 10 === 0;
}

This small function is very useful if you want to check the validity of the credit card number being provided before passing it to your payment mechanism.

Sample Credit Card Numbers for testing

When I implemented this in my code, I also wanted to have some sample credit card numbers to test this. Sample credit card numbers are also very useful in many cases so here are the credit card numbers that I found.

Credit Card Type Credit Card Number
American Express 378282246310005
American Express 371449635398431
American Express Corporate 378734493671000
Australian BankCard 5610591081018250
Diners Club 30569309025904
Diners Club 38520000023237
Discover 6011111111111117
Discover 6011000990139424
JCB 3530111333300000
JCB 3566002020360505
MasterCard 5555555555554444
MasterCard 5105105105105100
Visa 4111111111111111
Visa 4012888888881881
Visa 4222222222222Note : Even though this number has a different character count than the other test numbers, it is the correct and functional number.
Processor-specific Cards
Dankort (PBS) 76009244561
Dankort (PBS) 5019717010103742
Switch/Solo (Paymentech) 6331101999990016

Original Source for these numbers is this.

I have just tried to sum up all the info that helped me with credit card numbers in one post. I hope this saves some time for other people.