Skip to content

Instantly share code, notes, and snippets.

View samrdev's full-sized avatar

Samuel Rau samrdev

  • Nürtingen, Germany
View GitHub Profile
@samrdev
samrdev / example.php
Created January 30, 2012 20:00
A very simple and dirty class to make the GET and POST variables safe.
<?php
// We need to include the class.
require('safe_class.php');
// Here we specify the $_GET-variables as variables which can be used later.
list($foo, $bar) = safe::g('foo', 'bar');
@samrdev
samrdev / gist:1664094
Created January 23, 2012 16:26
Create a unique 10-place user id.
<?php
function createId($mail, $token) {
$r = range('a', 'f');
$h = md5($mail.$token);
$i = str_replace($r, '', strtolower($h));
$i = substr($i, 0, 10);
return (string)$i;
}
<?php $hsl = rand(0, 240) . ',' . rand(50, 80) . '%,60%'; ?>
<style type="text/css">
a {
color: hsl(<?php echo $hsl ?>);
}
</style>