This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Spotify URL handler | |
// @namespace http://open.spotify.com/ | |
// @description Takes care of zombie windows left undead from Spotify URL-to-URI actions | |
// @include http://open.spotify.com/* | |
// ==/UserScript== | |
window.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Calculates the binary huffman code for the given characters and their frequencies." | |
from copy import copy | |
freqs = {'a': 20, 'b': 10, 'c': 12, 'd': 5, 'e': 15, 'z': 65 } | |
class Node: | |
def __init__(self, ch='', freq=-1, code=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Time modulus for use with caching etc. | |
A time window of size window_size second distributed in chunks of granularity seconds. | |
''' | |
import time | |
def modtime(window_size, granularity, t=None): | |
'''Time distributions | |
modtime(60, 5) | |
12 unique evenly distributed over 60 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* * * * * root ps xU www-data|grep '/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf'|grep -v grep>/dev/null || invoke-rc.d lighttpd restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ttserver\ | |
-host 127.0.0.1\ | |
-port 41201\ | |
-mhost 127.0.0.1\ | |
-mport 51201 \ | |
-pid /Users/rasmus/src/lightcloud_manager/data/lookup1_A.pid\ | |
-dmn \ | |
-le \ | |
-ulog /Users/rasmus/src/lightcloud_manager/data/logs/1/\ | |
-sid 1\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# String substitution by indexing, avoiding recursive replacement. | |
# | |
# Copyright (c) 2009 Rasmus Andersson | |
# | |
# 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
'''A very simple HTTP server using eventlet (which in turn is based on greenlet) | |
''' | |
from eventlet import api, httpd, util | |
util.wrap_socket_with_coroutine_socket() | |
class Handler(object): | |
def handle_request(self, req): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# libevent echo server example using buffered events | |
SOURCES=libevent_echo.c | |
EXECUTABLE=libevent_echo | |
CFLAGS=-c -Wall -DDEBUG=1 -I/opt/local/include | |
LDFLAGS=-L/opt/local/lib -levent | |
OBJECTS=$(SOURCES:.c=.o) | |
all: $(SOURCES) $(EXECUTABLE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% simple TCP secho server in Erlang | |
-module(tcp_echo_server). | |
-export([run/1]). | |
-define(TCPOPTS, [binary, {packet,0}, {active,false}, {reuseaddr,true}]). | |
% Call tcp_echo_server:run(Port) to start the service. | |
run(Port) -> | |
run(Port, {127,0,0,1}). | |
run(Port, IpAddress) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Cocoa accessibility framework for intercepting Spotlight user input. */ | |
#import <Cocoa/Cocoa.h> | |
#import <AppKit/NSAccessibility.h> | |
static CFStringRef kSpotlightBundleIdentifier = CFSTR("com.apple.spotlight"); | |
static void SpotlightCallback(AXObserverRef observer, | |
AXUIElementRef element, |
OlderNewer