Skip to content

Instantly share code, notes, and snippets.

--------------------------------------------------------------------------------
-- PHP-style serialization in PostgreSQL
-- Making a better situation of someone else's bad decision
-- See examples at bottom
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Serialization function per type
CREATE OR REPLACE FUNCTION php_serialize(boolean) RETURNS text
@sturadnidge
sturadnidge / tmux-1.8-on-CentOS-6.x.txt
Last active May 10, 2021 18:31
Install tmux 1.8 on CentOS 6.x minimal (64bit)
# download latest libevent2 and tmux sources, and extract them somewhere
# (thx bluejedi for tip on latest tmux URL)
#
# at the time of writing:
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# http://sourceforge.net/projects/tmux/files/latest/download?source=files
#
# install deps
yum install gcc kernel-devel make ncurses-devel
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@DavidWittman
DavidWittman / default.vcl
Created June 1, 2012 19:46
Varnish VCL to detect and redirect file uploads
backend default {
.host = "127.0.0.1";
.port = "8080";
}
backend master {
.host = "10.x.x.x";
.port = "80";
}
sub vcl_recv {
# Any uploads or restarts should go to the master backend
@drsnyder
drsnyder / sar-monitor.sh
Created November 23, 2011 18:45
Bash script to start 2 hour sar monitoring at 30s intervals.
#!/bin/bash
interval=30
cycles=$((60/$interval*60*2))
date=`date -I`
sar -A -o sar.$date $interval $cycles >/dev/null 2>&1 &
@pepijndevos
pepijndevos / parsistent_heap.clj
Created January 15, 2011 17:13
A persistent heap implemented in Clojure
(ns persistent-heap)
(defn swap [heap idx idy]
(assoc heap idx (get heap idy) idy (get heap idx)))
(defn children [idx]
(let [idx (inc (* idx 2))
idy (inc idx)]
[idx idy]))