Skip to content

Instantly share code, notes, and snippets.



  • Liftkeeper
  • Budapest, Hungary
View GitHub Profile
pokeb / HTTP Cookie header parser
Created Sep 13, 2008
Quick and dirty HTTP cookie header parser in PHP
View HTTP Cookie header parser
seanmccann / gist:53225
Created Jan 27, 2009
PHP lint checker -- use in svn pre-commit hook. This prevents code with basic parse errors from entering the repository
View gist:53225
# originally from Joe Stump at Digg
for i in `$SVNLOOK changed -t "$TXN" "$REPOS" | /usr/bin/awk '{print $2}'`
if [ ${i##*.} == php ]; then
CHECK=`$SVNLOOK cat -t "$TXN" "$REPOS" $i | /usr/bin/php5 -d html_errors=off -l || echo $i`
RETURN=`echo $CHECK | /bin/grep "^No syntax" > /dev/null && echo TRUE || echo FALSE`
if [ $RETURN = 'FALSE' ]; then
echo $CHECK 1>&2;
exit 1
mbijon / xss_clean.php
Last active Jan 22, 2021
XSS filtering in PHP (cleans various UTF encodings & nested exploits)
View xss_clean.php
* XSS filter, recursively handles HTML tags & UTF encoding
* Optionally handles base64 encoding
* ***DEPRECATION RECOMMENDED*** Not updated or maintained since 2011
* This was built from numerous sources
omnicolor / svn-lint.php
Last active Dec 1, 2017
Pre-commit SVN hook that runs lint
View svn-lint.php
* Pre-commit Subversion script.
* @author Omni Adams <>
k3n / lint-all-files-recursive.php
Created Feb 16, 2012
Applies PHP's lint check to all PHP files in a directory.
View lint-all-files-recursive.php
* Recurses each directory and runs PHP's lint function against each file
* to test for parse errors.
* @param string $dir the directory you would like to start from
* @return array the files that did not pass the test
function lint( $dir = 'C:\dev\\' )
cballou / get-ip-address-optimized.php
Created Mar 26, 2012
PHP - Advanced Method to Retrieve Client IP Address
View get-ip-address-optimized.php
function get_ip_address() {
foreach ($ip_keys as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
// trim for safety measures
$ip = trim($ip);
// attempt to validate IP
if (validate_ip($ip)) {
gingerlime /
Created Apr 24, 2012
Postgresql - Changing ownership on all tables
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on by Alex Soto
jboner / latency.txt
Last active Mar 5, 2021
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers (~2012)
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
jterrace / xvfb
Created Jun 11, 2012
xvfb init script for Ubuntu
View xvfb
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset"
case "$1" in
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
rgreenjr / postgres_queries_and_commands.sql
Last active Mar 4, 2021
Useful PostgreSQL Queries and Commands
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'