Skip to content

Instantly share code, notes, and snippets.

View thomd's full-sized avatar

Thomas Dürr thomd

  • Hamburg, Germany
View GitHub Profile
@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.
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,
<!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 {
/*!
* 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,
#!/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;
@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
#
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
require 'net/https'
require 'nokogiri'
url = "https://example.com"
url = URI.parse( url )
http = Net::HTTP.new( url.host, url.port )
http.use_ssl = true if url.port == 443
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if url.port == 443
path = url.path
path += "?" + url.query unless url.query.nil?
@thomd
thomd / log.sh
Created June 28, 2013 23:16 — forked from mahemoff/log.sh
#!/bin/bash
##########################################################################
# library
##########################################################################
# via http://stackoverflow.com/a/12199798/18706
function format_date {
((h=${1}/3600))
((m=(${1}%3600)/60))
#!/usr/bin/env python
import plistlib
from shutil import copy
import subprocess
import os
from tempfile import gettempdir
import sys
import atexit
BOOKMARKS_PLIST = '~/Library/Safari/Bookmarks.plist'