Skip to content

Instantly share code, notes, and snippets.

@rcrowley
rcrowley / gist:22687
Created November 6, 2008 19:46
Allow Flickr Uploadr Extensions to store extra information for a user
var data = {
_xpcom: Cc['@mozilla.org/preferences-service;1']
.getService(Ci.nsIPrefService)
.getBranch('opendns.'),
get: function(k) {
var t = this._xpcom.getPrefType(k);
var fn;
if (Ci.nsIPrefBranch.PREF_BOOL == t) { fn = 'getBoolPref'; }
@rcrowley
rcrowley / gist:23535
Created November 10, 2008 16:39
Firewall ports so MS Office will run twice on the same subnet
#!/bin/sh
ipfw add deny udp from any to any 2222
ipfw add deny udp from any to any 2223
@rcrowley
rcrowley / foo
Created March 14, 2009 19:31
Django Shell Script
#!/usr/bin/env python
"""
Django Shell Script
Richard Crowley <[email protected]>
I like organized directory structures. Because of the way the Python
path works, there wasn't a readily-available way to stash shell scripts
that needed access to Django goodness away in bin/. This is a bit
heavy on the scaffolding code (six lines, geez) but works.
@rcrowley
rcrowley / deps.sh
Created April 1, 2009 00:11
Drizzle dependency installer for Ubuntu Intrepid
#!/bin/sh
#
# Drizzle dependency installer for Ubuntu Intrepid
# Richard Crowley <[email protected]>
#
if [ "." != $(dirname "$0") ] ; then
echo "[deps.sh] you must run deps.sh from the directory it is in" >&2
exit 1
#!/bin/sh
# Haystack/Whoosh setup
WD=$(pwd)
cd /tmp/
svn co http://svn.whoosh.ca/projects/whoosh/trunk whoosh
cd whoosh
sudo python setup.py install
cd .. ; sudo rm -rf whoosh
@rcrowley
rcrowley / mysql_linkify.user.js
Created May 12, 2009 23:14
CSS changes to the MySQL docs to make links always look like links
// ==UserScript==
// @name MySQL Linkify
// @namespace rcrowley.org
// @description Restyle <code> tags within <a> tags to reduce confusion
// @include http://*mysql.com/*
// ==/UserScript==
(function() {
var a = document.getElementsByTagName('a');
for (var i = 0; i < a.length; ++i) {
#!/bin/sh
# Haystack/Solr setup
# On a Mac you've already got Java but on Ubuntu, you need it
if [ -z "$(uname -a | grep Darwin)" ] ; then
sudo apt-get install --no-install-recommends sun-java6-jre
fi
WD=$(pwd)
cd /tmp/
// Pageview/click analytics in Cassandra?
{
"pageviews": { // Column family
"cookie": "OH HAI",
"url": "/foo/bar",
"layout": 47,
"ip": "1.2.3.4"
// And we get timestamps for free!
},
@rcrowley
rcrowley / gist:137178
Created June 28, 2009 01:15
print_r but for JavaScript
function obj2ul(obj) {
var ul = document.createElement('ul');
if ('object' == typeof obj) {
for (var k in obj) {
var li = document.createElement('li');
if ('object' == typeof obj[k]) {
li.appendChild(document.createTextNode(k + ':'));
li.appendChild(obj2ul(obj[k]));
} else {
li.appendChild(document.createTextNode(k + ': ' + obj[k]));
@rcrowley
rcrowley / gist:158815
Created July 30, 2009 18:02
curl_quickie
<?php
function curl_quickie($url, $post = false, $cookie = false,
$return_headers = false, $print = false) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if (false !== $post) {