Skip to content

Instantly share code, notes, and snippets.

View mitchellrj's full-sized avatar

Richard Mitchell mitchellrj

View GitHub Profile
@mitchellrj
mitchellrj / echoserver_example.py
Created April 23, 2012 14:55
WebSocket response object for WebOb with echoserver example
class EchoWebSocketResponse(BaseWebSocketResponse):
def after_open(self):
self.receive_until_closed()
def handle_text(self, text):
self.send_text(text)
def handle_request(self, request):
@mitchellrj
mitchellrj / brew --config.log
Created May 22, 2012 15:11
Brew ffmpeg upgrade failure
HOMEBREW_VERSION: 0.9
HEAD: 9d50a0ca0448c14bbdaa8f027b08b2cde6d90f08
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit sandybridge
OS X: 10.7.4
Kernel Architecture: x86_64
Xcode: 4.3.2
GCC-4.0: N/A
GCC-4.2: N/A
@mitchellrj
mitchellrj / brew --config.log
Created May 22, 2012 15:28
coreutils upgrade failure
HOMEBREW_VERSION: 0.9
HEAD: 9d50a0ca0448c14bbdaa8f027b08b2cde6d90f08
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit sandybridge
OS X: 10.7.4
Kernel Architecture: x86_64
Xcode: 4.3.2
GCC-4.0: N/A
GCC-4.2: N/A
@mitchellrj
mitchellrj / normalized_cmp.py
Created May 26, 2012 09:08
Normalized cmp for sorting lists of strings with accents
import unicodedata
def normalized_cmp(x, y):
if isinstance(x, unicode) and isinstance(y, unicode):
normalized_x = ([c for c in unicodedata.normalize('NFKD', x) if not unicodedata.combining(c)] + [''])[0]
normalized_y = ([c for c in unicodedata.normalize('NFKD', y) if not unicodedata.combining(c)] + [''])[0]
return cmp(normalized_x, normalized_y)
HOMEBREW_VERSION: 0.9
HEAD: 55d79f45121f2739b7df7125be8a27eacc28d292
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit sandybridge
OS X: 10.7.4
Kernel Architecture: x86_64
Xcode: 4.3.2
GCC-4.0: N/A
GCC-4.2: N/A
@mitchellrj
mitchellrj / loadtweetsfromjson.php
Created August 28, 2012 13:39 — forked from bryanveloso/loadtweetsfromjson.php
A horrible, simply horrible hack to getting TweetNest to read JSON. Copy this to the /maintenance/ folder of your TweetNest installation.
<?php
// TWEET NEST
// Load tweets (from JSON)
error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", true); // For easy debugging, this is not a production page
@set_time_limit(0);
require_once "mpreheader.php";
$p = "";
// The below is not important, so errors surpressed
@mitchellrj
mitchellrj / turing_test_widget.pt
Created August 31, 2012 15:26
deform widget for a turing test
<input type="hidden" name="__start__" value="${field.name}:mapping"/>
<div id="${field.oid}">
<p>Solve this problem:</p>
<p class="turing-challange">${challenge}</p>
<input type="hidden"
name="${field.oid}-challenge"
value="${challenge}"/>
<input type="text"
name="${field.oid}"/>
</div>
@mitchellrj
mitchellrj / strip.py
Created September 4, 2012 15:23
Replace whitespace at the beginning of non-empty lines
import re
def strip_non_empty_lines(text):
return re.sub(r'^\s+(?=\S)', '', text)
@mitchellrj
mitchellrj / configuration.py
Created September 14, 2012 13:20
Implementations of the TRACE and OPTIONS HTTP methods for Pyramid
config.add_route('options', '/*path', request_method='OPTIONS', view='.utility_views.OptionsView')
config.add_route('trace', '/*path', request_method='TRACE', view='.utility_views.TraceView')
@mitchellrj
mitchellrj / complexity.cfg
Last active December 10, 2015 23:28
Add a complexity analysis script to your buildout.
[buildout]
parts =
....
complexity
[complexity]
recipe = zc.recipe.egg
eggs = radon[tool]
scripts = radon=complexity