Skip to content

Instantly share code, notes, and snippets.

/*
Copyright (C) 2008 Daniel Richman & Simrun Basuita
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@danielrichman
danielrichman / watchdog.c
Last active September 5, 2015 14:45
watchdog that reboots if not killed in n seconds
/*
Copyright (C) 2010 Daniel Richman
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@danielrichman
danielrichman / periodic_packup.py
Last active September 25, 2015 02:57
random python periodic backup
#!/usr/bin/python
# Copyright 2011 (C) Daniel Richman
#
# This programme is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This programme is distributed in the hope that it will be useful,
@danielrichman
danielrichman / zeuswhoosh.py
Created September 6, 2011 17:21
ZeusWhoosh
# Copyright 2011 (C) Daniel Richman. License: GNU GPL 3; see LICENSE
import os
import sys
import time
import re
import whoosh.index
import whoosh.fields
import whoosh.query
import whoosh.qparser
@danielrichman
danielrichman / couchdb_tail_f.py
Created November 6, 2011 13:17
CouchDB tail: follow couchdb changes
#!/usr/bin/python
# Copyright Daniel Richman 2011. License: GNU GPL 3
import sys
import couchdbkit
import json
import pygments
import pygments.lexers.web
import pygments.formatters
@danielrichman
danielrichman / tee.py
Created January 2, 2012 14:31
bidirectional tee
#!/usr/bin/python
import sys
import subprocess
import threading
import signal
if len(sys.argv) < 3:
sys.stderr.write("Usage: {0} output_file command [arg [arg] ...]\n"\
.format(sys.argv[0]))
@danielrichman
danielrichman / couchdb_runviews.py
Created February 13, 2012 10:31
CouchDB view refresher.
#!/usr/bin/python
# Copyright Daniel Richman 2012. License: GNU GPL 3
import sys
import couchdbkit
def main(uri, db):
server = couchdbkit.Server(uri)
database = server[db]
@danielrichman
danielrichman / couch_bulk_upload.py
Created February 13, 2012 13:07
replication is too slow
import couchdbkit
import gzip
import simplejson as json
def load():
g = gzip.open("habitat.json.gz")
try:
for line in g:
line = line.strip()
if line.endswith("[") or line == "]}":
@danielrichman
danielrichman / git_pygmentize.py
Created April 6, 2012 18:45
dump & syntax everything possible in a git repo
#!/usr/bin/python
import sys
import copy
import errno
import os
import git
import pygments
import pygments.lexers
import pygments.formatters
@danielrichman
danielrichman / README.md
Created April 10, 2012 19:24
old habitat.habhub.org docs scripts

habitat.habhub.org miscellanea

The scripts here live and run on [[nessie.habhub.org]].

  • runas.c (compiles to runas): setugid CGI binary configured to be run by the web server whenever a certain url is fetched. This url is installed as a github post-receive hook. The setugid binary provides a secure way to go from running as www-data, to running as habitat-www in order to regenerate the sphinx documentation. Also locks a file to ensure that simultaneous updating isn't attempted.