Skip to content

Instantly share code, notes, and snippets.

View mikeywaites's full-sized avatar

Mike Waites mikeywaites

View GitHub Profile
@apinstein
apinstein / ipfw bandwidth throttle.sh
Created August 3, 2009 19:38
ipfw bandwidth throttling
#!/bin/sh
#
# Use ipfw to throttle bandwidth.
# usage:
# ./throttle.sh # Throttle at default (60KB/s)
# ./throttle.sh 5 # Throttle at custom speed (5KB/s)
# ./throttle.sh off # Turn throttling off
# flush rules
ipfw del pipe 1
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@robertklep
robertklep / EventStreamMiddlewareWrapper.py
Created June 13, 2012 19:49
Wrapper function for Django middleware classes so they handle text/event-stream
# wrapper for middleware classes (I'm using this in combination with django-sse)
def EventStreamMiddlewareWrapper(original):
original_method = getattr(original, 'process_response', None)
if not original_method:
return original
def new_method(self, request, response):
# return immediately when the response is an event stream
if 'text/event-stream' in response.get('Content-Type', ''):
return response