Apr 02 2008

Puzzle from a picture using Javascript

Published by admin under Javascript

The jQuery library written in javascript is amasing and it has thounsands of plugins for almost everything. One plugin that captured my attention was jqPuzzle . The easiest way to create a puzzle from a jpg file. Here’s an example: SAMPLE PAGE .

Choose the Animation & Effects category for a set of special examples.

No responses yet

Mar 10 2008

WampServer is so cool

Published by admin under Google

WampServer is a tool I found while searching Google for this string ‘php5 + apache 2 + mysql 5′. I needed something to show me how to install these three on a Windows machine because you cannot find something that really worths reading anywhere on this web.

And there it was: 2 minutes to install the latest versions for all anywhere on your computer.

WampServer

But the most important thing this tool can do is exactly the warning from the description page:

WARNING : all the PHP releases aren’t compatible with the Apache releases. WampServer knows which releases can work together and lets you know when it is not possible to switch.

No responses yet

Feb 24 2008

Ecards Open Season

Published by admin under Google

No responses yet

Feb 13 2008

Apache Authentication, Authorization and Access Control - The Basics

Published by admin under Google

What?

Basic Authentication is the simplest method of authentication on apache servers. It means that the visitor of a website will have to authenticate in order to see a page or a group of pages.

How?

When a particular resource has been protected using basic authentication, Apache sends a 401 Authentication Required header with the response to the request, in order to notify the client that user credentials must be supplied in order for the resource to be returned as requested.
Continue Reading »

No responses yet

Feb 04 2008

Session is lost when you move from HTTP to HTTPS

Published by admin under PHP

If you are on a website and the address bar starts with http:// then you must know that the session from the current page will be lost when you get to https:// , basically because it’s another domain. The solution is to pass the data from your sessions to https sessions using POST or GET.

No responses yet

Jan 07 2008

Wordie for words lovers

Published by admin under Google

Wordie is for people who love words.

It happens sometimes to read about a person or a thing in a magazin or newspaper, and you don’t know who that person is or what that thing means. For most of us, Google is the first dictionary you go first. There is an explanation for everything. Even for “Googleganger“. I didn’t know this word even exists, but it does and it has a very simple explanation: “another person of the same name, whose records are intermixed with your own when you ‘google’ yourself.”.

No responses yet

Nov 09 2007

URLencode in javascript

Published by admin under Javascript

Using RFC2396 Mark characters:


function URLencode(){
	var f = document.frm;
	var n = f.n.value;
	var encoded = “”;

    var HEX = “0123456789ABCDEF”;

    var UNSAFECHARS = ‘<>”#%{}|^~[];/?:@=&’;

    for (var i = 0; i < n.length; i++ ) {

    	var ch = n.charAt(i);

    	if (ch == ” “) {
		encoded += “+”;	// x-www-urlencoded, rather than %20
    	}
    	else if (UNSAFECHARS.indexOf(ch) != -1) {

			var charCode = ch.charCodeAt(0);
			encoded += “%”;
            encoded += HEX.charAt((charCode >> 4) & 0xF);
            encoded += HEX.charAt(charCode & 0xF);

			}

		else{
			//it’s safe
			encoded += ch;
    	}

    } // for

    return encoded;
}

No responses yet

Nov 04 2007

Connect to database using singleton in php5

Published by admin under PHP

If you want to connect to a database only once, you must create a singleton to make sure of the number of instances.

First let’s create the singleton object:

class db_connect {
// Static variable (available without needing an actual instance)

private static $db_instance = null;
private function __construct() {

// Restrict the constructor, we don't want programmers to use it.

}

protected function __clone() {

// We don't want them to clone either

}

// getInstance either creates an instance or returns

//our static variable version if it already exists.

static public function getInstance() {

if(is_null(self::$db_instance))

{

// Create database connection here

$link = mysql_connect("localhost", "root", "root") or die(mysql_error());

mysql_select_db("test",$link) or die(mysql_error());

// Set our static variable to the link identifier.

//Now it is available in our static variable.

self::$db_instance = $link;

}

return self::$db_instance;

}

}

Then, we declare a class to create connection:

// fetch database connection (creates it if it wasn't created before)

//$db_con = db::getInstance();class DB_Info {

private $link_db = null;

    private $result;

public function __construct() {

        // create the connection

        $this->Connect();

}

public function Connect(){

 //only one connection is alowed

    	$this->link_db = db_connect::getInstance();

    }

function __destruct() {

       mysql_close($this->link_db);

   }

public function listContent(){

 //get all content from mytable into an array

   		$sql = "select * from mytable";

   		$items = null;

   		$this->result = mysql_query($sql,$this->link_db);

   		$i = 0;

   		if($this->result){

   			while ($m = @mysql_fetch_array($this->result)) {

   				$items[$i] = $m;

   				$i++;

   			}

   		}

   		return $items;

   }

}

Call this class, like this:

$db = new DB_Info();

No responses yet

Oct 08 2007

Best free icons website

Published by admin under Google

Crown iconAfter a long search on the web, the best website with free icons is http://www.iconarchive.co .

Check the left navigation. It has some green links with special icons, for different dimensions. The max size is 250 x 250. You can download archives for free.

Be careful. Some of them are not ment for commerce. You should unzip the archive after download and take a look at the README file.

Have fun!

No responses yet

Oct 03 2007

Print friendly

Published by admin under Javascript

Step 1: create a stylesheet for the page you want to print and link it to the html page.

<link href="print.css" rel="stylesheet" media="print" type="text/css" />

Step2: Create a link to print the current page

<a href="JavaScript:window.print();">Print this page</a>

You can make a page print after it loads (onload method).

No responses yet

Next »