Skip to content

Instantly share code, notes, and snippets.

View jchook's full-sized avatar

Wes Roberts jchook

  • Meter AI, Inc.
  • Tübingen, Germany
View GitHub Profile
@thenewbie
thenewbie / echo-server.php
Created November 21, 2009 10:58
PHP is UNIX - Simple preforking echo server in PHP
<?
/*
PHP is UNIX - Simple preforking echo server in PHP
**************************************************
The code here is related to:
http://tomayko.com/writings/unicorn-is-unix
http://jacobian.org/writing/python-is-unix/
http://plasmasturm.org/log/547/ - perl is unix
@dtjm
dtjm / monitrc.vim
Created August 6, 2010 17:38
Vim syntax file for Monit configuration files
" Vim syntax file
" Language: Monit control file
" Maintainer: Sam Nguyen
" Latest Revision: 6 August 2010
if exists("b:current_syntax")
finish
endif
syn keyword monitCommand set check include
@victorbstan
victorbstan / php_object_to_array.php
Created December 17, 2010 04:18
recursively cast a PHP object to array
<?php
/*
This function saved my life.
found on: http://www.sitepoint.com/forums//showthread.php?t=438748
by: crvandyke
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?!
*/
$array = json_decode(json_encode($object), true);
@nrk
nrk / predis-0_6_3-relnotes.markdown
Created January 1, 2011 17:21
Predis 0.6.3 (2011-01-01) - Release notes

Predis 0.6.3 (2011-01-01) - Release notes

Predis is a flexible and feature-complete PHP client library for Redis. This is a maintenance release for the 0.6 series that features support for check and set (CAS) operations using the Predis\MultiExecBlock abstraction for MULTI/EXEC transactions and the addition of the remaining commands that will be part of Redis 2.2 (now in the RC stage). As with previous releases, Predis is also available for PHP 5.2 with an officially supported backport (PHP >= 5.2.6). What follows is an overview of the new features introduced in this new release. For a more in-depth list of changes please see the CHANGELOG.

New features and changes

Transactions with CAS support

@jehiah
jehiah / simple_args_parsing.sh
Created March 4, 2011 16:56
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
@v1nc3ntlaw
v1nc3ntlaw / rbenv-install-system-wide.sh
Last active July 26, 2022 01:08
rbenv install ruby 1.9.3-p448 on Debian 6 Squeeze
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@mattbaker
mattbaker / thunk.js
Created January 6, 2012 17:12
Thunk in Javascript
function Thunk(fn) {
this.get = function() {
var v = fn();
this.get = function() { return v };
return v;
}
}
/*
* > var x = new Thunk(function() { console.log("working..."); return 2 * 2 * 2; })
@alobato
alobato / start-stop-example.sh
Created March 3, 2012 23:09
start-stop-example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar
@xeoncross
xeoncross / index.php
Created March 8, 2012 17:31
Tiny, SMTP client in PHP
<?php
/*
This is a very tiny proof-of-concept SMTP client. Currently it's over 320 characters (if the var names are compressed). Think you can build one smaller?
*/
ini_set('default_socket_timeout', 3);
$user = 'you@gmail.com';
$pass = '';
$host = 'ssl://smtp.gmail.com';
@bcantoni
bcantoni / json-int.php
Created March 22, 2012 19:42
Demo of PHP workaround for large integers in JSON data responses
<?php
/* Demonstration of problem with large integers in JSON, and
a couple options for dealing with them as strings instead.
ref:
* http://php.net/manual/en/function.json-decode.php
* http://stackoverflow.com/questions/2907806/handling-big-user-ids-returned-by-fql-in-php
*/
$json = <<<EOT