Skip to content

Instantly share code, notes, and snippets.

@kylef
kylef / userserv.cpp
Created May 4, 2011 16:47
ZNC module to auth you with UserServ
/*
* Copyright (C) 2004-2011 See the AUTHORS file for details.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*/
#include "User.h"
@kylef
kylef / inspircd-stats.sh
Created June 23, 2011 14:10
InspIRCd stats from m_http_stats
#!/bin/sh
address="https://localhost:8081/stats"
count_type=$1
if [[ "$count_type" != "user" && "$count_type" != "channel" ]]; then
echo "Usage: $0 <user|channel>"
exit 1
elif
@kylef
kylef / yubikey.cpp
Created September 14, 2011 16:54
ZNC module for YubiKey
extern "C" {
#include <ykclient.h>
}
#include <znc/Modules.h>
#include <znc/znc.h>
#include <znc/User.h>
#define CLIENT_ID 1
#define DEFAULT_TOKEN_ID_LEN 12
@kylef
kylef / craftirc.cpp
Created September 19, 2011 15:35
CraftIRC ZNC Module
#include "Modules.h"
#include "Chan.h"
class CCraftIRC : public CModule {
public:
MODCONSTRUCTOR(CCraftIRC) {
AddHelpCommand();
AddCommand("Alias", static_cast<CModCommand::ModCmdFunc>(&CCraftIRC::AliasCommand), "username [nick]");
AddCommand("Nick", static_cast<CModCommand::ModCmdFunc>(&CCraftIRC::NickCommand), "nick", "Set the nickname the CraftIRC bot uses.");
}
@kylef
kylef / inspircd_channels
Created September 24, 2011 12:18
InspIRCd plugins for munin
#!/bin/bash
case $1 in
config)
echo "graph_title Channel count"
echo "graph_vlabel channels"
echo "channels.label channels"
echo "channels.draw AREA"
;;
*)
@kylef
kylef / PKGBUILD
Created July 5, 2011 17:41
lxc package for arch linux
pkgname=lxc
pkgver=0.7.4.2
pkgrel=1
pkgdesc="Linux Containers"
arch=('i686' 'x86_64')
url="http://lxc.sourceforge.net/"
depends=('bash' 'perl')
license=('LGPL')
source=("http://lxc.sourceforge.net/download/lxc/$pkgname-$pkgver.tar.gz" lxc.rcd lxc.confd)
md5sums=('36fcb0f6a39d2f55130421f342f24ef3' '520594461912e084c220ca37eb97afd2' 'efb0c46839136842e9d3617924a9b5b5')
@kylef
kylef / Django HTCPCP Middleware.py
Last active November 25, 2015 01:09
A HTCPCP Implementation for Django
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 / Procfile
Created April 14, 2013 15:58
Static server for Heroku using river
web: gunicorn -w 4 serve:wsgi
/*
HTTP Link header parser (http://tools.ietf.org/html/rfc5988)
License: BSD
NSDictionary *links = KFParseRelativeLinks(@"<http://github.com?page=2>; rel=next");
NSURL *nextURL = links[@"next"];
*/
NSDictionary *KFParseRelativeLinks(NSString *header) {
NSMutableDictionary *links = [[NSMutableDictionary alloc] init];
@kylef
kylef / images.py
Last active December 21, 2015 13:59
Search the current directory for unused images. Useful for finding leftover assets from files which exist in Xcode project or in your repository.
# This simple python utility crawls the current directory and finds all images.
# It will then search the directory for files using these images and also mark
# any xcode projects which include these images.
#
# Allowing you to easily find images which are no longer used (or even images
# included in xcode and not used).
#
# Usage, cd into your repository and then run:
#
# curl https://gist.github.com/kylef/6316920/raw/images.py -# | python -