Shows the steps involved in converting a number from a given base to base 10. I wrote the example for a book, but after I was mostly finished it, it seemed too off topic. I hope
that someone finds it useful. :)
The credit_card class provides methods for cleaning, validating and identifying the type of credit card numbers.
Methods include: identify() - Find the type of credit card (Mastercard, Visa, etc...) based on the card number.
The method can identify 8 different card types, including Amex, Mastercard and Visa
validate() - Validate a number using the LUHN (mod 10) algorithm.
check() - Validate and identify a credit card number.
clean_no() - Strip all non-numeric characters from the passed value and return an integer.
Duplicates the functionality of PHP 4's array_rand function in PHP 3. Handy for people who have not yet been able to convince their sysadmins to upgrade to PHP 4, or for those
who need a starting point to create a function similar to array_rand.
The inline class provides methods for creating and destroying local variable scopes. Simply put, local scopes are spaces where some or all of the global variables are
temporarily hidden.
This behavior is useful when debugging, or for making emergency hacks to code.
Methods include:
inline() (class constructor) - create a local scope for one or more variables.
get_global() - find the value of a hidden global variable.
get_globals() - find the values of all the hidden global variables.
export() - export a local variable to global scope.
export_all() - export all local variables to global scope.
exit_scope() - exit the local scope and destroy the class variables
Slots and Signals ================= This code is a simple implementation of the slots/signals concept. Slots and signals are used by the Qt toolkit as a kind of extra-powerful
callback. The best source of information on them is the Qt toolkit docs see (http://doc.trolltech.com/3.0/signalsandslots.html) To briefly summarize, they allow you to bind a
signal to one or more slots and/or signals. When a signal is 'emitted', all slots and signals bound to it are called. Each slot corresponds to a single function. When a signal
is called by another signal, the called signal is emitted, calling the slots and signals that it is bound to. Any parameters passed when the signal is emitted are passed to the
slots and signals that that are called. This easily allows you to write handler functions (slots) and bind them to events (signals) as needed - without having to make explicit
function calls or rewrite handler functions just to accomodate minor modifications in how a function is called. I find slots and signals particular useful for message passing
and error handling. Have Fun! :) Zak Greant
The str class provides 4 perl-like methods for manipulating strings and other scalar variables.
Methods include: pop() - Strip the rightmost character from a string and return the character.
push() - Join one or more scalar values onto the right end of a scalar variable.
The values are concatenated from left to right, in the order that they were specified.
shift() - Strip the leftmost character from a string and return the character.
unshift() - Join one or more scalar values onto the left end of a scalar variable.
The values are concatenated from right to left, in the order that they were specified.