Skip to content

Instantly share code, notes, and snippets.

Kyle Fuller kylef

Block or report user

Report or block kylef

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kylef
kylef / dict.c
Created Mar 27, 2009
A key/value dictionary system in C
View dict.c
/* A key/value dict system in C */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TEST TRUE /* Comment this line out to compile without a main function (used when including into another application). */
typedef struct dict_t_struct {
char *key;
void *value;
@kylef
kylef / dispatch.fcgi
Created May 21, 2009
Django fastCGI dispatcher
View dispatch.fcgi
#!/usr/bin/env python2.4
import sys, os
from fcgi import WSGIServer
if __name__ == '__main__':
sys.path += ['/home/kylef/python']
os.environ['DJANGO_SETTINGS_MODULE'] = 'kylef.settings'
from django.core.handlers.wsgi import WSGIHandler
WSGIServer(WSGIHandler()).run()
@kylef
kylef / Toggle Mute (Skype)
Created May 31, 2009
Applescript to toggle mute on Skype
View Toggle Mute (Skype)
tell application "Skype"
if (send command "GET MUTE" script name "MuteToggler") is equal to "MUTE ON" then
send command "SET MUTE OFF" script name "MuteToggler"
else
send command "SET MUTE ON" script name "MuteToggler"
end if
end tell
@kylef
kylef / iphone-update-checker.py
Created Jun 17, 2009
This python script queries iTunes update url to see if iPhone OS 3.0 has been released for the iPhone 3G
View iphone-update-checker.py
import urllib2
import re
from time import sleep
class PageScraper(object):
"""
This class scrapes a url for a string, can be used with a loop.
"""
def __init__(self, url, string=''):
@kylef
kylef / html.py
Created Jul 8, 2009
This middleware strips unnessicery characters from a HTML document in order to save bytes. It will removes things like CR, LR, TAB's and multiples spaces.
View html.py
"""
The idea of this was to strip responses of any unnecessary
characters to save bandwidth, after some testing the savings
were only up-to 8% on rare occasion.
"""
import re
re_is_html = re.compile(r'(*)</html>(*)')
@kylef
kylef / Django HTCPCP Middleware.py
Last active Nov 25, 2015
A HTCPCP Implementation for Django
View Django HTCPCP Middleware.py
from random import randint
from django.http import HttpResponse
class HTCPCPMiddleware(object):
"""
This middleware allows a your django project to act as a HTCPCP (Hyper
Text Coffee Pot Control Protocol) server. If the user requests to BREW
a coffee, and it is not on the list. Then it will get a `406 Not
Acceptable`, and randomly it will respond with `418 I'm a teapot`.
@kylef
kylef / irc-znc.xml
Created Jan 10, 2010
This is a SMF script for OpenSolaris for ZNC
View irc-znc.xml
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='znc'>
<service
name='network/irc'
type='service'
version='1' >
<instance name='znc' enabled='false'>
@kylef
kylef / russian_roulette.cpp
Created Jan 10, 2010
This is a russian routlette module which may kick a user when he says !roulette
View russian_roulette.cpp
#include <main.h>
#include <Modules.h>
#include <Chan.h>
class CRussianRoulette_Mod : public CModule {
public:
MODCONSTRUCTOR(CRussianRoulette_Mod) {}
virtual ~CRussianRoulette_Mod() {}
EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage) {
@kylef
kylef / sabnzbd.py
Created Jan 11, 2010
SABnzbd python api
View sabnzbd.py
import urllib, json
class SABnzbd(object):
"""
Usage:
>>> from sabnzbd import SABnzbd
>>> s = SABnzbd('sakar.local', 8080, '4488f2881b90d7753bef8fb9e1bc56b3')
>>> s.pause() # Pauses the downloads
>>> s.shutdown() # Shut's down SABnzbd+
"""
@kylef
kylef / irc-unreal.xml
Created Jan 11, 2010
This is a SMF script for OpenSolaris for UnrealIRCd
View irc-unreal.xml
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='unrealircd'>
<service
name='network/irc'
type='service'
version='1' >
<instance name='unreal' enabled='false'>
<dependency name='network'
You can’t perform that action at this time.