Skip to content

Instantly share code, notes, and snippets.

@wheresalice
wheresalice / gist:112195
Created May 15, 2009 12:42
Display open Trac tickets modified in the past 10 days
SELECT p.value AS __color__,
id AS ticket, summary, component, version, t.type AS type,
owner, status,
time AS created,
changetime AS _changetime, description AS _description,
reporter AS _reporter
FROM ticket t, enum p
WHERE status <> 'closed'
AND unix_timestamp(date_sub(now(), interval 10 day)) < changetime
AND p.name = t.priority AND p.type = 'priority'
@wheresalice
wheresalice / gist:112197
Created May 15, 2009 12:44
redacted code which goes through a Drupal database subscribing all new users to a Mailman list on a separate server. Relies upon Drupal Drush module and Mailman XMLRPC2 patch.
import os
import xmlrpclib
proxy = xmlrpclib.ServerProxy("https://lists.mydomain.org/mailman/RPC2")
def nicepass(alpha=6,numeric=2):
"""
returns a human-readble password (say rol86din instead of
a difficult to remember K8Yn9muL )
"""
@wheresalice
wheresalice / gist:112198
Created May 15, 2009 12:45
Training Bogofilter with virtual imap users
#!/bin/sh
#retrain_bogofilter.sh
#Version 2.0
#jkv@unixcluster.dk - free for all
#kaerast at qvox - modifications, free for all
#Prerequisites:
# - formail
# - bogofilter
@wheresalice
wheresalice / in-out_gui.php
Created January 3, 2010 17:33
PHP-GTK/CouchDB PoC code to set status of an in/out board
<?php
$couch_dsn = "http://localhost:5984/";
$couch_db = "inout";
// libraries come from http://github.com/dready92/PHP-on-Couch
require_once "../lib/couch.php";
require_once "../lib/couchClient.php";
require_once "../lib/couchDocument.php";
$client = new couchClient($couch_dsn,$couch_db);
<?php
$couch_dsn = "http://localhost:5984/";
$couch_db = "inout";
require_once "../lib/couch.php";
require_once "../lib/couchClient.php";
require_once "../lib/couchDocument.php";
$client = new couchClient($couch_dsn,$couch_db);
@wheresalice
wheresalice / gist:271161
Created January 7, 2010 10:54
Select somebody's name or email address, then use this bookmarklet to search for them on Facebook. It can probably be refactored, but I'm not Javascript expert
javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://www.facebook.com/search/?ref=ffs&q=',l=d.location,e=encodeURIComponent,p=e(s)+'&o=2048&init=ffs',u=f+p;{a%20=function(){if(!w.open(u,'t','toolbar=0,resizable=0,status=1,width=450,height=430'))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}void(0);
@wheresalice
wheresalice / Hash Analyzer
Created April 2, 2010 15:47
PHP code to analyse password hashes. See it running at hash.kaerast.info
<html>
<body>
<ul>
<?php
$myhash = $_GET['hash'];
$hash = array();
switch ( strlen($myhash)) {
case(0):
$hash[] = "No hash passed";
break;
@wheresalice
wheresalice / drupal.rb
Created April 8, 2010 12:33
Very basic test suite using Watir to ensure a Drupal site is working
#!/usr/bin/ruby1.9.1
require "rubygems"
require "test/unit"
require "watir"
$site = ARGV[0]
puts $site
if ($site[-1,1] != "/")
puts "url must end in a slash"
exit
end
@wheresalice
wheresalice / drupal_spec.rb
Created April 8, 2010 15:14
rspec file to check the basics of a Drupal site
require 'rubygems'
require 'watir'
require 'spec'
Watir::Browser.default = 'firefox'
describe "test Drupal frontend" do
before(:each) do
@browser ||= Watir::Browser.new
@domain ||= 'example.org'
@wheresalice
wheresalice / testgoogle.rb
Created April 14, 2010 13:05
A really simple example of using webrat and rspec for integration testing
require 'rubygems'
require 'webrat'
require 'spec/test/unit'
include Webrat::Methods
include Webrat::Matchers
Webrat.configure do |config|
config.mode = :mechanize
end