Archive for the ‘ Programming ’ Category
This code is still beta, use at your own risk. __db_host = $host; $this->__db_username = $username; $this->__db_password = $password; $this->__db_name = $db_name; $this->connect(); } /** * Initialize our table object [ READ MORE ]
__db_host = $host; $this->__db_username = $username; $this->__db_password = $password; $this->__db_name = $db_name; $this->connect(); } /** * Initialize our table object [ READ MORE ]
"Most people getting started with JavaScript these days are faced with the challenging task of picking a library to use, or at least which one to learn first. If you're working for a company chances are they have already chosen a framework for you, in which case the point is somewhat moot. If this is the case and they've chosen MooTools and you're used to jQuery, then this article might still be of some use to you. " Written by Aaron Newton Article here: http://jqueryvsmootools.com[ READ MORE ]
This is a quick and dirty screen scraper for quantcast.com. It currently only grabs the site rank and description. Usage: $q = new QuantCast('cnet.com'); echo 'Rank: ' . $q->getRank() . ''; echo 'Desc: ' . $q->getDescription() . ''; Class Source Code: class QuantCast { public $siteName; private $siteContents; public function __construct($siteName){ $this->siteName = strtolower(str_replace('http://', '', $siteName)); [ READ MORE ]
$q = new QuantCast('cnet.com'); echo 'Rank: ' . $q->getRank() . ''; echo 'Desc: ' . $q->getDescription() . '';
class QuantCast { public $siteName; private $siteContents; public function __construct($siteName){ $this->siteName = strtolower(str_replace('http://', '', $siteName)); [ READ MORE ]
This class requires PHP 5.2+ and the MySQLi extension. It will not work with the regular MySQL extension. An object representing a table is created on the fly that will allow you to do inserts, updates etc. Please see comments in the code for usage. init('user_table'); * $user->get("user_id = 4343"); [ READ MORE ]
init('user_table'); * $user->get("user_id = 4343"); [ READ MORE ]
Just a simple php mime type array $mimes = array( 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/macbinary', 'dms' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'class' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'so' => 'application/octet-stream', [ READ MORE ]
$mimes = array( 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/macbinary', 'dms' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'class' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'so' => 'application/octet-stream', [ READ MORE ]
This array can be used to build out a Country drop down list. 'AFGHANISTAN', 'AL'=>'ALBANIA', 'DZ'=>'ALGERIA', 'AS'=>'AMERICAN SAMOA', 'AD'=>'ANDORRA', 'AO'=>'ANGOLA', 'AI'=>'ANGUILLA', 'AQ'=>'ANTARCTICA', 'AG'=>'ANTIGUA AND BARBUDA', 'AR'=>'ARGENTINA', 'AM'=>'ARMENIA', 'AW'=>'ARUBA', 'AU'=>'AUSTRALIA', 'AT'=>'AUSTRIA', 'AZ'=>'AZERBAIJAN', 'BS'=>'BAHAMAS', 'BH'=>'BAHRAIN', 'BD'=>'BANGLADESH', 'BB'=>'BARBADOS', 'BY'=>'BELARUS', 'BE'=>'BELGIUM', 'BZ'=>'BELIZE', [ READ MORE ]
'AFGHANISTAN', 'AL'=>'ALBANIA', 'DZ'=>'ALGERIA', 'AS'=>'AMERICAN SAMOA', 'AD'=>'ANDORRA', 'AO'=>'ANGOLA', 'AI'=>'ANGUILLA', 'AQ'=>'ANTARCTICA', 'AG'=>'ANTIGUA AND BARBUDA', 'AR'=>'ARGENTINA', 'AM'=>'ARMENIA', 'AW'=>'ARUBA', 'AU'=>'AUSTRALIA', 'AT'=>'AUSTRIA', 'AZ'=>'AZERBAIJAN', 'BS'=>'BAHAMAS', 'BH'=>'BAHRAIN', 'BD'=>'BANGLADESH', 'BB'=>'BARBADOS', 'BY'=>'BELARUS', 'BE'=>'BELGIUM', 'BZ'=>'BELIZE', [ READ MORE ]
This is a simple script that will highlight required fields on a form. It requires no libraries and is just one simple function that accepts an array of field id's that are required. Code: function checkRequiredFields(fieldIdsArray){ var fields = fieldIdsArray; var errorThrown = false; for (var i = 0; i < fields.length; i++){ var obj = document.getElementById(fields[i]); if (obj.value == '' || obj.value == null){ obj.style.border = '1px solid red'; obj.onfocus = function(){ this.style.border = '1px solid #999999'}; [ READ MORE ]
function checkRequiredFields(fieldIdsArray){ var fields = fieldIdsArray; var errorThrown = false; for (var i = 0; i < fields.length; i++){ var obj = document.getElementById(fields[i]); if (obj.value == '' || obj.value == null){ obj.style.border = '1px solid red'; obj.onfocus = function(){ this.style.border = '1px solid #999999'}; [ READ MORE ]
A simple javascript snippet to remove HTML elements dynamically. function removeElement(elementId){ var itemToBeRemoved = document.getElementById(elementId); var parent = itemToBeRemoved.parentNode; parent.removeChild(itemToBeRemoved); }; [ READ MORE ]
function removeElement(elementId){ var itemToBeRemoved = document.getElementById(elementId); var parent = itemToBeRemoved.parentNode; parent.removeChild(itemToBeRemoved); };
function showPopup(textBox, className){ // grab the textbox object var textbox = document.getElementById(textBox); // get the textboxes parent var parent = textbox.parentNode; // check to see if this popup is already on screen var popup = document.getElementById(textBox + '_popup'); if (!popup) { // we don't have a popup, lets create one // create popup div var popup = document.createElement('div'); // give it a unique id popup.id = textBox + '_popup'; // attach css if passed in [ READ MORE ]
Pull weather data from Google's weather API (http://www.google.com/ig/api?weather=10027). This class grabs the raw data (xml) and creates a nicely formatted associative array containing the weather information. Example: $w = new googleWeather(); $w->enable_cache = 1; $w->cache_path = '/var/www/mysite.com/cache'; $ar_data = $w->get_weather_data(10027); print_r($ar_data); echo $ar_data['forecast'][0]['day_of_week']; Source: <?php /** * Grabs weather data from Google.com's weather API and return a nicely formatted array * [ READ MORE ]
$w = new googleWeather(); $w->enable_cache = 1; $w->cache_path = '/var/www/mysite.com/cache'; $ar_data = $w->get_weather_data(10027); print_r($ar_data); echo $ar_data['forecast'][0]['day_of_week'];
<?php /** * Grabs weather data from Google.com's weather API and return a nicely formatted array * [ READ MORE ]