Ink Spout

Ink Spout has evolved into Ink Spouts now. It is available at a new address now. www.inkspouts.com We have rebooted it and It's back with lots of stuffs . :D Just go and check it out.

Featured Posts

Ink Spout has evolved into Ink Spouts now. It is available at a new address now. www.inkspouts.com We have rebooted it and It's back with lots of stuffs . :D Just go and check it out.
Showing posts with label techjargon. Show all posts
Showing posts with label techjargon. Show all posts
Sunday, June 10, 2012 3 comments

Guest Post by Bill

In this tutorial, I will be describing a more effective way to validate credit cards when accepting payment on your site. This method provides smoother and more compact way of verification, eliminating the use of larger scripts. The plug-in I will be describing will help you so that you can check a credit card number you are given for correct checksum values as well as correct format before submitting for processing.


To begin, we will describe how this plug-in works. This plug-in takes details about a credit card and returns true or false depending whether the card passes checksum and date verification. It requires the following arguments:

Number: A Credit Card Number               
Month: The Credit Card's Expiry Month
Year: The Credit Card's Expiry Year

Variables, Arrays, and Functions

left                    Local variable containing the first 4 digits of number
cclen                 Local variable containing the number of digits in number
chksum             Local variable containing the card’s checksum
date                  Local date object
substr()            Function to return a portion of a string
getTime()          Function to get the current time and date
getFullYear()     Function to get the year as a 4-digit number
getMonth()        Function to get the month

This function first ensures that all three parameters passed to it are strings by adding the
empty string to them, like this:
number += ' '
month += ' '
year += ' '
Next, each argument is processed through a CleanupString() to ensure that they are in the formats required:

number = CleanupString(number, true, false, true, true)
month = CleanupString(month, true, false, true, true)
year = CleanupString(year, true, false, true, true)

After this, the variable left is assigned the first 4 digits of number, cclen is set to the
card number’s length, and chksum is initialized to 0:

var left = number.substr(0, 4)
var cclen = number.length
var chksum = 0

Now with several if() ... else if() statements we check that left contains a valid sequence that matches a known brand of credit card and, if it does, that the card number length in cclen is correct for the card type. However, If left doesn’t match a known card, or it matches one but cclen is the wrong length, then the plug-in returns false to indicate that the card cannot be verified.

If these initial tests are passed, the card’s checksum is then calculated using a very known algorithm that gives us just what we need (this algorithm was invented by a the famous IBM scientist Hans Peter Luhn)



for (var j = 1 - (cclen % 2) ; j < cclen ; j += 2)
     if (j < cclen) chksum += number[j] * 1
for (j = cclen % 2 ; j < cclen ; j += 2)
{
      if (j < cclen)
      {
            d = number[j] * 2
            chksum += d < 10 ? d : d - 9
       }
}
if (chksum % 10 != 0) return false



To use this plug-in, pass it a card number, expiry year, and month and it will return true or false. Of course, this algorithm tests only whether the card meets certain requirements. This program will give the customer a "heads up" to check their info before trying to submit their information; it does not test whether the user has entered a genuine card or whether the charge will go through. This plug-in is best for preventing errors before the processing state, e.g. catching mistakes made by customers in typing numbers, entering correct numbers in the wrong area of a form, etc).

Again, a big warning here: We are not connecting to a bank or any financial party to provide us any verification as to whether this card is good to go for a certain amount of payment or not.
The purpose of the plug-in is to catch typing errors, as well as people entering random data to see what happens.
               
Here is a full coded example using our previous code:

<h3>Your credit card details:</h3>
<font face='Courier New'>
Card Number: <input id='ccnum' type='text' name='n' size='24' /><br />
Expires: Month <input id='ccmonth' type='text' name='m' size='2' />
Year <input id='ccyear' type='text' name='y' size='4' /><br />
<button id='button'>Submit Credit Card</button>     

<script>
window.onload = function()
{
      O('button').onclick = function()
      {
if (ValidateCreditCard(O('ccnum').value, O('ccmonth').value, O('ccyear').value))
                                alert("The card validated successfully")
                                else
                                alert("The card did not validate!")
        }
}
</script>                         

If you are to use this plug-in with your own code, you will probably want to replace the onclick event attachment used in the example with a function attached to the onsubmit event of your form. Also, make sure that when you do this your function returns true if the card verifies to allow the form submission to complete, and false (along with and alert message stating the error message) if the card submission doesn’t validate, to stop the form submission from going through.

The full plug-in code:


                                                                          CODE                                                                 

function ValidateCreditCard(number, month, year)
{
         number += ' '
         month += ' '
         year += ' '
         number = CleanupString(number, true, false, true, true)
         month = CleanupString(month, true, false, true, true)
         year = CleanupString(year, true, false, true, true)
         var left = number.substr(0, 4)
         var cclen = number.length
         var chksum = 0

         if (left >= 3000 && left <= 3059 ||
                left >= 3600 && left <= 3699 ||
                left >= 3800 && left <= 3889)
         { // Diners Club
               if (cclen != 14) return false
         }
          else if (left >= 3088 && left <= 3094 ||
                left >= 3096 && left <= 3102 ||
                left >= 3112 && left <= 3120 ||
                left >= 3158 && left <= 3159 ||
                left >= 3337 && left <= 3349 ||
                left >= 3528 && left <= 3589)
          { // JCB
                if (cclen != 16) return false
          }
          else if (left >= 3400 && left <= 3499 ||
                  left >= 3700 && left <= 3799)
          { // American Express
                  if (cclen != 15) return false
          }
          else if (left >= 3890 && left <= 3899)
          { // Carte Blanche
                  if (cclen != 14) return false
          }
          else if (left >= 4000 && left <= 4999)
          { // Visa
             if (cclen != 13 && cclen != 16) return false
          }
          else if (left >= 5100 && left <= 5599)
          { // MasterCard
                  if (cclen != 16) return false
          }
          else if (left == 5610)
          { // Australian BankCard
                   if (cclen != 16) return false
          }
          else if (left == 6011)
          { // Discover
                    if (cclen != 16) return false
          }
          else return false // Unrecognized Card

          for (var j = 1 - (cclen % 2) ; j < cclen ; j += 2)
                       if (j < cclen) chksum += number[j] * 1
          for (j = cclen % 2 ; j < cclen ; j += 2)
          {
             if (j < cclen)
              {
                    d = number[j] * 2
                    chksum += d < 10 ? d : d - 9
              }
          }
          if (chksum % 10 != 0) return false

          var date = new Date()
          date.setTime(date.getTime())

          if (year.length == 4) year = year.substr(2, 2)

          if (year > 50)                                                                    
          return false
          else if (year < (date.getFullYear() - 2000))                     
          return false
          else if ((date.getMonth() + 1) > month                           
          return false
          else
          return true                                                                                           
 }


                                                                          CODE                                                                 


So this is how we can use JavaScript in a more effective way to verify the credit card information.
About the Guest Author
This article was contributed by Bill at Spotted Frog Design, a web development and online marketing company based in the Philadelphia area. For more information about Spotted Frog, please visit their site, or follow them on Twitter at spottedfrog


Read More.....

Friday, June 8, 2012 0 comments

It's a post by our part-time contributor Aditya Sharma. He likes to write about tech & Health.


Notebook (laptop) is a very efficient and important tool of many people today.Businessmen, college students, housewives and professionals all use laptops for one use or the other. However, it is better that men learn that they risk losing their fertility with the excessive usage of laptop computers.


The main reason men tend to lose their fertility with the excessive use of laptop computers is that the heat that is generated by the computers, and the posture that the man adopts to balance the laptop computer tends to increase the temperature surrounding the scrotum.

Scientific researches have proven that the higher is the scrotal temperature, the higher is the possibility of damaging sperms and affecting the male's fertility. Moreover, with the advent of Bluetooth and infrared connections, where there are wireless links to the internet, more and more men are using laptops on their laps than on a desk.

Men usually keep their legs open wider than women to keep their testicles at the right temperature, and for added comfort. However, with a laptop on their laps, they tend to adapt a less comfortable position so that they can balance the laptop on their laps. This leads to an increase in body temperature that is found between the thighs.

It has been recently proven that prolonged and continuous usage of laptops on the laps tend to lead to damage to the fertility of the man. This was because the use of laptops usually leads to about 2.7C increase inthe scrotal temperature of the male. This has lead to more and more men having decreased sperm levels where sperm counts seem to have dropped by a third in ten years.

Most of the reasons for this reduced sperm count is drug use, smoking, alcohol and obesity. Besides this, pesticides, radioactive materials and chemicals, and laptops too contribute to decrease in fertility in men.

The human male body has a fixed testicular temperature to maintain usual sperm production and development.Though it is not known the exact time of heat exposure and frequency of exposure to heat that can lead to reversible and irreversible production of sperms, it is known that frequent usage of laptops can lead to irreversible or partially reversible changes in the reproductive system of the male body.

This is why it is advised that young men and teenage boys should limit the use of laptops on their laps to avoid losing their fertility. It is not advisable for young men or boys to also use wireless services on their laps to play games and do other work as they are sure to develop problems in ten years' time, when trying to have a family.

It is thereby advised that men should use laptops on the desk; in fact, anywhere else is possible, other than using it in the lap. Women don't have to worry much about laptop computers on their laps, as so far, there have been no studies on the impact of using laptop computers on their laps.

Although rare,there have been cases of severe burns from a laptop overhaeting on an individual's lap. Burns can also come from combustion of laptop batteries. Also rare, there have been instances of this happening when the laptop is held in such a way that the venting fan is blocked. So avoid bad postures and try avoid putting laptops on your laps.

Read More.....

Thursday, March 15, 2012 0 comments

With this post I am starting Tech-Jargon series which will give you a brief overview of terminology and concepts in simple manner.
Often I find many of my friends and juniors confusing between the dataspeed i.e. kbps and KBps. Firstly the important question arises whether there is any difference between these two terms?
For your surprise the answer is YES.
Before going into explanation let’s make few terms clear to feel the thing.
b = bit (the most basic unit a computer handles)
B = byte (1 byte = 8 bits)
K = 1,024 ; k= 1,000
so now I think , many things are pretty much clear. In normal adaption both “K” and “k” are considered as same because “K” is recently introduced and faces low adoption (also there is not much difference in both).
So the basic difference is clear by their full form that are "kbps/Kbps - kilobits per second" and "kBps/KBps - KiloBytes per second".
Whenever any ISP claims to provide the data transfer speed in Mbps it simply means Megabits per second. In other words, for a 1Mbps broadband connection, it will take minimum 8 seconds (1000/125KBps) to download a 1 MB (megabyte) file from the internet. Most Broadband companies define 1K as 1,000 and not as 1,024 which is the used for computing. So next time you are looking in to your internet speed do keep this in mind.

General Transformation of Speed

so the overall general conclusion is that whenever you have speed in Mbps or mbps,
 divide that by 8 and that will be your original downloading speed.
I hope you have made your doubts clear and enjoyed this info-ride.
If you liked it, you have full right to comment (& you should use it ;-)) and share it.
Read More.....

Most Trending

Recent Posts

Recommend us on Google!

featured-slider

Labels

Bloggers.com

Bloggers - Meet Millions of Bloggers