Skip to content

Instantly share code, notes, and snippets.

import psutil
import simplejson
import time
import urllib2
# Sends the CPU and memory usage stats to Loggly. Sends both a machine total and per process.
def log():
""""""
proc_dict = {}
@psychemedia
psychemedia / folium_shapefiles.ipynb
Last active August 29, 2015 14:19
Open Knowledge / Cabinet Office Code Club, week 8
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@psychemedia
psychemedia / diabetes_textualisation.ipynb
Last active September 8, 2015 13:10
Sketching a handcrafted data2text report for diabetes prescribing.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shantanuo
shantanuo / dumper.pl
Created September 20, 2011 09:12
MySQLdump filter. Removes or replaces the DEFINER clauses from a dump
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case );
my $replace = undef;
my $delete = undef;
my $help = 0;
GetOptions (
@adampatterson
adampatterson / git_pull
Created October 17, 2011 20:27
Git pull Helper
/**
* Git Pull
*
* @author Adam Patterson
* http://www.adampatterson.ca/blog/2011/10/diy-simple-staging-server/
*
* Use: echo pull();
*/
function pull ( )
@ambroff
ambroff / patch-keep-slave-data.diff
Created December 21, 2011 23:25
Allow setting up replication without purging data in the slave first.
diff --git a/redis.conf b/redis.conf
index 44fb536..505cb6e 100644
--- a/redis.conf
+++ b/redis.conf
@@ -150,6 +150,13 @@ slave-serve-stale-data yes
#
# repl-timeout 60
+# When setting up replication, the slave will purge the current data set before
+# loading the data sync from the master. Setting this will prevent that from
@ambroff
ambroff / gist:1509153
Created December 22, 2011 06:05
Collapsing a redis cluster from 6 nodes into 2.
1.) [1] [2] [3] Six node cluster
[4] [5] [6]
2.) [1] [2] <= [3] Hosts 2 and 5 replicate from 3 and 6 respectively.
[4] [5] <= [6] Once caught up, the clients are updated to point
to 2 and 5 instead, and 3 and 6 are terminated.
3.) [1] <= [2] Repeat.
[4] <= [5]
unsigned long zslGetRank(zskiplist *zsl, double score, robj *o) {
zskiplistNode *x;
unsigned long rank = 0;
int i;
x = zsl->header;
for (i = zsl->level-1; i >= 0; i--) {
while (x->level[i].forward &&
(x->level[i].forward->score < score ||
(x->level[i].forward->score == score &&
Program received signal SIGSEGV, Segmentation fault.
zslGetRank (zsl=0x7f3d8d71c360, score=19.498544884710096, o=0x7f3d4cab5760) at t_zset.c:335
335 (x->level[i].forward->score < score ||
(gdb) bt
#0 zslGetRank (zsl=0x7f3d8d71c360, score=19.498544884710096, o=0x7f3d4cab5760) at t_zset.c:335
#1 0x000000000042818b in zrankGenericCommand (c=0x7f3d9dcdc000, reverse=1) at t_zset.c:2046
#2 0x00000000004108d4 in call (c=0x7f3d9dcdc000) at redis.c:1024
#3 0x0000000000410c1c in processCommand (c=0x7f3d9dcdc000) at redis.c:1130
#4 0x0000000000419d3f in processInputBuffer (c=0x7f3d9dcdc000) at networking.c:865
#5 0x0000000000419e1c in readQueryFromClient (el=<value optimized out>, fd=<value optimized out>, privdata=0x7f3d9dcdc000, mask=<value optimized out>) at networking.c:908