This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SERVER_PORT="${1:-8080}" | |
function handleRequest(){ | |
# $METHOD = GET|POST | |
# $FULL_REQUEST = /query/url/complete?with=params | |
# $REQUEST = /query/url/complete | |
# render query parameters as QUERY_* environment variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:;while [ $? -eq 0 ];do nc -vlp 8080 -c'(r=read;e=echo;$r a b c;z=$r;while [ ${#z} -gt 2 ];do $r z;done;f=`$e $b|sed 's/[^a-z0-9_.-]//gi'`;h="HTTP/1.0";o="$h 200 OK\r\n";c="Content";if [ -z $f ];then($e $o;ls|(while $r n;do if [ -f "$n" ]; then $e "<a href=\"/$n\">`ls -gh $n`</a><br>";fi;done););elif [ -f $f ];then $e "$o$c-Type: `file -ib $f`\n$c-Length: `stat -c%s $f`";$e;cat $f;else $e -e "$h 404 Not Found\n\n404\n";fi)';done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
show_help() { | |
cat << EOF | |
Usage: ${0##*/} [-u USER] [-p PASS] [-P PORT] [-H HOST] [DATABASE] | |
${0##*/} -h | |
Open a standard connection in Sequel PRO. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# GIT CHANGELOG Generator | |
# Stefano Azzolini <stefano.azzolini@caffeina.com> | |
# | |
# Use parameter --skip-head to skip HEAD section | |
LOG_FORMAT="\`%h\` **%s** _by %an_ " | |
function changelog_for_tag() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include "tree.php"; | |
$x = new Tree(); | |
$x->bacon = "Pancetta"; | |
$x->pasta["fagioli"] = 3; | |
$y = clone $x; | |
$y->pasta = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function M($c){return function(...$p)use($c){static$m=[];return$m[$k=json_encode($p)]??$m[$k]=$c(...$p);};} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function closure_source(Closure $c) { | |
$rfx = new ReflectionFunction($c); $args = []; | |
foreach($rfx->getParameters() as $p) | |
$args[] = ($p->isArray() ? 'array ' : ($p->getClass() ? $p->getClass()->name . ' ' : '')) | |
. ($p->isPassedByReference() ? '&' : '') . '$' . $p->name | |
. ($p->isOptional() ? ' = ' . var_export($p->getDefaultValue(), true) : ''); | |
return 'function(' . implode(',', $args) . "){\n" | |
. implode('',array_slice(file($rfx->getFileName()), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @example : | |
* shell_echo("<red>==></red> <b>Hohoho!</b>"); | |
*/ | |
function shell_echo() { | |
static $col_stack = ['normal']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function verifica_codice_fiscale($codfis, $nome='', $cognome='', $maschio=true){ | |
$codfis = strtoupper($codfis); | |
if (!preg_match('(([A-Z]{6})(\d{2})([A-Z])(\d{2})([A-Z]\d{3})([A-Z0-9]))A', $codfis, $parts)) return false; | |
list(,$_slug,$_anno,$_mese,$_giorno,$_istat,$_chk) = $parts; | |
// Checksum | |
$chk_map = [ | |
['0'=>0,'1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8, | |
'9'=>9,'A'=>0,'B'=>1,'C'=>2,'D'=>3,'E'=>4,'F'=>5,'G'=>6,'H'=>7,'I'=>8, |