Skip to content

Instantly share code, notes, and snippets.

switch ($a)
case 1:
#this runs if case 1 is true
case 2:
case 3:
#this runs if case 1, 2 or 3 are true
break;
case 4:
#this runs if case 4 is true
function consistent_hash($path, $servers){
$hash = hexdec(substr(md5($path), 0, 5));
return $cache[$hash % count($servers)];
}
$server = consistent_hash($path_to_asset, array('cache1', 'cache2'));
@iamcal
iamcal / gist:1468403
Created December 12, 2011 18:12
Merging to a parent repo after it accepts your changes
$ git remote add parent git://github.com/shiflett/testmore.git
$ git fetch parent
$ git branch parent-master parent/master
$ git checkout parent-master
$ git checkout master
$ git merge parent-master
$ git push origin master
$ git branch -d parent-master
@iamcal
iamcal / gist:1033478
Created June 18, 2011 20:22
Installing yum on a Centos 5 box (MediaTemple dv 3.5)
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-sqlite-1.1.7-1.2.1.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/nspr-4.8.6-1.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/nspr-devel-4.8.6-1.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/nss-3.12.8-1.el5.centos.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/nss-devel-3.12.8-1.el5.centos.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/cpio-2.6-23.el5_4.1.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/nss-3.12.8-1.el5.centos.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/nss-devel-3.12.8-1.el5.centos.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/popt-1.10.2.3-22.el5.i386.rpm
<?php
mysql_connect('localhost', 'root', 'root');
mysql_select_db('porn');
$result = mysql_query("SELECT * FROM images WHERE has_goats=1 AND has_nuns=1");
while ($row = mysql_fetch_array($result)){
echo "<img src=\"$row[image]\" />\n";
}
function joinBuffers(b1, b2){
// if one arg is null, be smart
if (!b1) return b2;
if (!b2) return b1;
var l1 = b1.length;
var l2 = b2.length;
var b3 = new Buffer(l1 + l2);
GNU nano 2.0.6 File: /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
bind-address=10.210.215.67
# npm publish
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursiv
{ "SERVERUSED" : "LIGHTHOUSE.5.MONGOLAYER.COM/54.70.204.247:10001" , "LASTOP" : { "$TS" : 0 , "$INC" : 0} , "CONNECTIONID" : 7940 , "ERR" : "MULTI UPDATE ONLY WORKS WITH $ OPERATORS" , "CODE" : 9 , "N" : 0 , "OK" : 1.0}
@iamcal
iamcal / status.php
Created August 27, 2014 17:25
Parse mod_status output for localhost
<?php
#
# scoreboard stuff
#
echo file_get_contents('http://localhost/server-status?auto');
echo "\n";
#