Tip: Use Code igniter methods without instance a class

Sometimes making a class in Code Igniter you could need to use some method of Code igniter (database class for examples) without instance the class itself, for example in static method.

In this case, you can use the Code Igniter instance itself:

$ci_ins =& get_instance();
$ci_ins->load->model("some model");
$ci_ins-->db->insert(); //Using database

Leggere le variabili GET in javascript

Snipplet per leggere le variabili GET in Javascript

function GET(q,s)
{
s = s ? s : window.location.search;
var re = new RegExp('&'+q+'(?:=([^&]*))?(?=&|$)','i');
return (s=s.replace(/^\?/,'&').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined;
}

Esempio:

// http://test.com/index.php?v=test
var var1 = GET('v');

alert(var1);

Ho trovato questa ottima funzione qui
Credits tuttavia andava fixata la regex, per questo la posto.