Skip to content

Instantly share code, notes, and snippets.

View thomd's full-sized avatar

Thomas Dürr thomd

  • Hamburg, Germany
View GitHub Profile
import SimpleHTTPServer
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def send_head(self):
"""Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied
to the outputfile by the caller unless the command was HEAD,
and must be closed by the caller under all circumstances), or
@thomd
thomd / hack.sh
Created April 2, 2012 08:41 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
#!/bin/bash
PASTEL='{
"Ansi 0 Color" = {
"Blue Component" = 0.3097887;
"Green Component" = 0.3097887;
"Red Component" = 0.3097887;
};
"Ansi 1 Color" = {
"Blue Component" = 0.3764706;
/*!
* JavaScript preload() function
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Demo: http://mathiasbynens.be/demo/javascript-preload
*/
function preload(arr) {
var i = arr.length,
<!DOCTYPE html>
<html>
<head>
<title>jQuery Templating Demo</title>
<style type="text/css">
html {
background:#f3f3f3;
font: 13px/1.5 helvetica, arial, san-serif;
}
ul {
var performance = (function () {
var my = {};
// Wrap a function body in this to return a copy that instruments itself
// If you want this to be useful, you should give your profiled function a name,
// otherwise it will be identified as "", which is less than useful.
my.profile = function (func) {
return function () {
var start = new Date().getTime(),
time,
@thomd
thomd / httpdump
Created April 4, 2009 12:54 — forked from peterc/httpdump
httpdump
# Monitor HTTP requests being made from your machine with a one-liner..
# Replace "en1" below with your network interface's name (usually en0 or en1)
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile:
# (again replace "en1" with correct network interface name)
alias httpdump='sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"'
# All the above tested only on OS X.
@thomd
thomd / markdown.css
Last active August 29, 2015 14:24 — forked from imjasonh/markdown.css
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
#!/bin/bash
version=1.0.1
versionDate="2014-02-14"
function showHelp() {
echo "watchfile - monitor file(s)/command and perform action when changed
Possible ways of usage
----------------------------------------
@thomd
thomd / watch.sh
Created August 13, 2014 18:34 — forked from mikesmullin/watch.sh
#!/usr/bin/env bash
# script: watch
# author: Mike Smullin <mike@smullindesign.com>
# license: GPLv3
# description:
# watches the given path for changes
# and executes a given command when changes occur
# usage:
# watch <path> <cmd...>
#