Skip to content

Instantly share code, notes, and snippets.

View acdha's full-sized avatar

Chris Adams acdha

View GitHub Profile
@acdha
acdha / exim-purge-all-mail.sh
Created March 20, 2009 22:28
Remove all mail from an exim server
#!/bin/sh
for msgid in `mailq | grep '<.*>' | cut -c10-27`; do
exim -Mrm $msgid
done
@acdha
acdha / bookmarklet-template.js
Created April 3, 2009 21:04
A template for creating bookmarklets which load jQuery from the Google CDN - see http://chris.improbable.org/2009/apr/3/cleaning-up-the-web-with-jquery-and-a-little-help/
/*
To avoid polluting the global namespace this uses an anonymous
function which is called with either the URL for an external
JavaScript file or a function. In either case jQuery will be loaded
from the Google CDN before your code is executed so it's free to
depend on jQuery without checking for it and can do things like
jQuery.getScript() to load other components (e.g. jQuery UI),
stylesheets, etc.
*/
(function (target, msg) {
/*
To avoid polluting the global namespace this uses an anonymous
function which is called with either the URL for an external
JavaScript file or a function. In either case jQuery will be loaded
from the Google CDN before your code is executed so it's free to
depend on jQuery without checking for it and can do things like
jQuery.getScript() to load other components (e.g. jQuery UI),
stylesheets, etc.
*/
(function (target, msg) {
/*
To avoid polluting the global namespace this uses an anonymous
function which is called with either the URL for an external
JavaScript file or a function. In either case jQuery will be loaded
from the Google CDN before your code is executed so it's free to
depend on jQuery without checking for it and can do things like
jQuery.getScript() to load other components (e.g. jQuery UI),
stylesheets, etc.
*/
(function (target, msg) {
@acdha
acdha / maxmalloc.c
Created April 3, 2009 21:21
A simple utility to determine the largest allocation possible for your operating system, compiler and C library
/*
* MaxMalloc: a simple test to determine the maximum memory allocation
*
* gcc -Os -Wall -Wextra -o maxmalloc maxmalloc.c
*/
#include <getopt.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@acdha
acdha / wk-bench.py
Created June 11, 2009 22:48
WebKit/PyObjC-based website benchmarking tool for testing AJAX sites in-browser. See http://github.com/acdha/webtoolbox for the actively maintained version
#!/usr/bin/env python
# http://gist.github.com/128284
"""
A WebKit-based site performance test
Usage:
%prog [options] [http://example.net/ ...]
"""
#!/usr/bin/env python
import sys
import os
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.insert(0, os.path.join(PROJECT_ROOT, "apps"))
sys.path.insert(0, PROJECT_ROOT)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
RED Spider Results
</title>
<style type="text/css" media="screen">
body {
@acdha
acdha / django-virtualenv-example.spec
Created August 7, 2009 22:29
The RPM spec file used to distribute a Django site as an RPMed virtualenv. This copy is no longer being maintained as this has moved to a separate repository: http://github.com/acdha/django-deployable-site
%define name example_project
%define version 1.2
%define release 1
%define __prelink_undo_cmd %{nil}
Summary: Example_Project website
Name: %{name}
Version: %{version}
Release: %{release}
Source0: %{name}-%{version}.tar.gz
#!/usr/bin/env python
"""
Force Aperture to reindex data after it corrupts its thumbnails, previews, or image paths
"""
from Cocoa import NSDictionary
import stat
import os
import sys
from xml.parsers.expat import ExpatError