So today to have some fun i decided to rip data from a site that returns a street and city for any postcode. They have this service on the website but that's only intended for retrieving data for 1 address at a time for private use. To use this function commercially you have to get [...]
I decided to pull an old project out of the cupboard. It was something I was concepting a while ago but got distracted by other things (aplis). Its a class, no its actually a mini apli consisting of a builder GUI and a class.
The idea is to automate form creation, checking, processing and data loading. The [...]
Very simple little php function that returns a black or white colour depending on the darkness of the given html colour.
function fontColour($colour){
$r = hexdec($colour[0].$colour[1]);
$g = hexdec($colour[2].$colour[3]);
$b = hexdec($colour[4].$colour[5]);
$sum = $r+$g+$b;
if($sum>390){ return '000000'; }else{ return 'FFFFFF'; }
}
as i said, simple
enter a 6 char html background colour and it returns 000000 or FFFFFF for your [...]
This one was much easier than i thought it was going to be. The aim: use the mouse wheel scroller for something other than scrollbars. This could be used to scroll through different years or months in the agenda calendar.
http://www.thomassmart.com/Experiments/scroll/
code is in the source of the file
Was working on some scripts today for the upcoming agenda application.
I needed to get a few things working: drag-drop over different hours and days and resize appointment box.
Got those all working now, note its a sandbox script so far from foolproof its just needed to work complicated things out before i start on the actual [...]
Was playing around with colours the last couple of days. made 2 scripts and a new Apli.
Script 1: colour array generator. Basically i ripped a list of html colour codes of a site but wanted to use only a few of them and also wanted to be able to order them nicely. So made a [...]
Just made a cute little javascript suggestion script. Still needs some work to clean it up a bit and also for placing the elements in a page in an easy to use manner. But it does the trick, nicely too.
http://thomassmart.com/Experiments/suggest/
check the source for the code
I'm currently working on a function to speed up making forms. When making a form with some back-end table you need to do 4 things: make the database table and make a form, with javascript check and php processing into the table. My aim is to bring this back to 1 thing and have the rest automated [...]
A simple little function to make querying databases a bit less repetative
function sqlGetQuery($table,$return='q',$id=0,$select='*',$where="){
global $dbL;
$q = mysql_query("SELECT * FROM $table WHERE 0",$dbL); $idName = mysql_field_name($q,0);
if($id>0){ $where = "$idName='$id' ".$where; }else{ $where = "$idName>0 "; }
$q = mysql_query("SELECT $select FROM $table WHERE $where",$dbL);
$selCount=explode(',',$select);$selCount=count($selCount);
if(mysql_num_rows($q)==0){
return false;
}elseif($return=='q' || mysql_num_rows($q)>1){
return $q;
}elseif($return=='r' || $selCount>1 || $select=='*'){
return(mysql_fetch_array($q));
}elseif($return=='i'){
$r=mysql_fetch_array($q);
return $r[$select];
}
}
Usage
if($q=sqlGetQuery('content_menus')){
$r=mysql_fetch_array($q);
[...]
This is by far the best XML2ARRAY function for php i have found so far, i use it in several projects.
function xml2array($contents, $get_attributes=1) {
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is [...]
Comments