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 / unknown_browsers.py
Created Jan 16, 2010
Create a list of all unknown user agents in a django-request django project.
View unknown_browsers.py
# This code grabs all unknown browsers in django-request on a django project.
from request.models import Request
from request.utils import browsers
requests = Request.objects.this_month().only('user_agent')
user_agents = [request.user_agent for request in requests]
unknown_agents = [agent for agent in user_agents if browsers.resolve(agent)[0] == 'Unknown']
print unknown_agents
@kylef
kylef / magicword.rb
Created Mar 14, 2010
MagicWord plugin for ZMB bot
View magicword.rb
class MagicWord
attr_accessor :words, :users
def initialize(sender, settings);
@words = settings['words'] if settings.has_key?('words')
@words = Hash.new if not @words
@users = settings['users'] if settings.has_key?('users')
@users = Array.new if not @users
end
@kylef
kylef / support.rb
Created Mar 14, 2010
Support plugin for ZMB
View support.rb
class Support
def initialize(sender, settings=nil)
@delegate = sender
end
def commands
{
'support' => [:support, 1, { :help => 'request support' }],
}
end
View request-plugin-performance.py
import time
from request.plugins import plugins
from request.models import Request
def timer(callback, args=[], kwargs={}):
start = time.time()
callback(*args, **kwargs)
stop = time.time()
return stop - start
View http.rb
#!/usr/bin/env ruby
begin
require 'pcaplet'
rescue LoadError
require 'rubygems'
require 'pcaplet'
end
p = Pcaplet.new(ARGV.join(' '))
View example_app_engine.py
import rivr
def view(request):
return rivr.Response("Hello World")
if __name__ == '__main__':
from google.appengine.ext.webapp import util
from rivr.wsgi import WSGIHandler
util.run_wsgi_app(WSGIHandler(view))
@kylef
kylef / http-nginx.xml
Created Jan 26, 2011
SMF manifest for nginx
View http-nginx.xml
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='network/http' type='service' version='0'>
<instance name='nginx' enabled='false'>
<dependency name='network' grouping='require_all' restart_on='error' type='service'>
<service_fmri value='svc:/milestone/network:default'/>
</dependency>
<dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local:default'/>
@kylef
kylef / craftbukkit
Created Feb 9, 2011
init.d script for craftbukkit (minecraft server)
View craftbukkit
#!/bin/sh
# /etc/init.d/craftbukkit
USERGROUP="sam:sam"
CBPATH="/home/sam/.craftbukkit"
PIDFILE=$CBPATH/pidfile
case "$1" in
start)
@kylef
kylef / preventpart.cpp
Created Feb 21, 2011
ZNC Module to prevent a client from parting a IRC channel
View preventpart.cpp
/*
ZNC Module to prevent a client from parting a IRC channel
This is useful for use with github's IRC service hook.
*/
#include "Modules.h"
class CPreventPart : public CModule {
public:
MODCONSTRUCTOR(CPreventPart) {}
@kylef
kylef / pyeval.py
Last active Sep 25, 2015
Python Evaluate for ZNC modpython
View pyeval.py
import sys
import re
from code import InteractiveInterpreter
import znc
class pyeval(znc.Module, InteractiveInterpreter):
module_types = [znc.CModInfo.UserModule, znc.CModInfo.NetworkModule]
description = 'Evaluates python code'
You can’t perform that action at this time.