Skip to content

Instantly share code, notes, and snippets.

View robcowie's full-sized avatar

Rob Cowie robcowie

  • Recycleye
  • Leeds/London, United Kingdom
View GitHub Profile
import logging
from pylons import config, request, response, session, tmpl_context as c
from pylons.controllers.util import abort, redirect_to, url_for
from pylons_openid.lib.base import BaseController, render
log = logging.getLogger(__name__)
import urllib2
import md5
import simplejson as json_
$(function() {
//run the accordion plugin, set height of sections to height of content
$("#accordion").accordion({ autoHeight: false });
});
;(function($) {
//write new sammy application
var app = new Sammy.Application(function() {
with(this) {
//corresponds to routes such as #/section/1
get('#/section/:section_id', function() { with(this) {
// adds a persitant server-side logger to the Sammy logger pool
Sammy.addLogger(function() {
var message = $.makeArray(arguments).join(', ');
// dont provide a callback (aka ignore the results)
$.post('/log', "message=" + message);
});
Sammy.log('logging', 'should', 'be', 'working');
// POST /log
@mnot
mnot / urlnorm.py
Created December 1, 2009 05:29
urlnorm.py: URL normalisation
#!/usr/bin/env python
"""
urlnorm.py - URL normalisation routines
urlnorm normalises a URL by;
* lowercasing the scheme and hostname
* taking out default port if present (e.g., http://www.foo.com:80/)
* collapsing the path (./, ../, etc)
* removing the last character in the hostname if it is '.'
@luisuribe
luisuribe / Postgresl hints
Created May 24, 2010 04:35
Postgresql snippets
-- select size of tables and indices in random order
SELECT relname, reltuples, relpages FROM pg_class ;
-- select size of tables and indices in descending order of size
SELECT relname, reltuples, relpages FROM pg_class ORDER BY relpages DESC ;
-- select size of tables and indices in descending order of tuple- / recordcount
SELECT relname, reltuples, relpages FROM pg_class ORDER BY reltuples DESC ;
-- Change admin password
# Copyright (c) 2010, Philip Plante of EndlessPaths.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@adamstac
adamstac / TODO
Created February 11, 2011 18:50
A Rubyist’s guide to setting up a Mac OS X development environment using Homebrew, RVM, Git and Bundler
* Review this article and add new steps as needed: http://blog.therubymug.com/blog/2010/05/20/the-install-osx.html
@sygo
sygo / conf.hexdump
Last active August 7, 2023 15:00
additions to the standard grc.conf (check the appropriate conf files for each command)
# offset
regexp=([0-9a-fA-F]{1,7})+
colours=bold red
count=once
======
# Hex Bytes %_p
regexp=\|.+?\|
colours=cyan
count=once
======
@robcowie
robcowie / countries.csv
Created April 4, 2011 14:05
Create a table of Countries with ISO codes
alpha2 alpha3 numeric name
AF AFG 004 Afghanistan
AX ALA 248 Åland Islands
AL ALB 008 Albania
DZ DZA 012 Algeria
AS ASM 016 American Samoa
AD AND 020 Andorra
AO AGO 024 Angola
AI AIA 660 Anguilla
AQ ATA 010 Antarctica
@akheron
akheron / async_map.py
Created April 7, 2011 13:20
Asynchronous map for Tornado's ioloop
from tornado.ioloop import IOLoop
# Calls fn for all items of iterable, saves result to a list, and
# calls callback with that list. This is most useful when fn works
# asynchronously.
def async_map(fn, iterable, callback, io_loop=None):
ioloop = io_loop or IOLoop.instance()
def loop():
try: