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
# 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 |
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
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 |
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
class Support | |
def initialize(sender, settings=nil) | |
@delegate = sender | |
end | |
def commands | |
{ | |
'support' => [:support, 1, { :help => 'request support' }], | |
} | |
end |
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
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 |
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 ruby | |
begin | |
require 'pcaplet' | |
rescue LoadError | |
require 'rubygems' | |
require 'pcaplet' | |
end | |
p = Pcaplet.new(ARGV.join(' ')) |
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
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)) |
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
<?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'/> |
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
/* | |
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) {} |
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
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' |
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
#!/bin/sh | |
# Usage: ./modgen.sh CFooMod > foo.cpp | |
# Usage: ./modgen.sh CFooMod global > foo.cpp | |
if [ ! "$1" ]; then | |
echo "No module class name supplied" | |
exit 1 | |
fi |