Skip to content

Instantly share code, notes, and snippets.

@kylef
kylef / Mocta.md
Last active August 29, 2015 14:01 — forked from orta/Mocta.md

Getting a Mocta object

NSUserDefaults<Mocta> *defaults = [Mocta objectWithClass:[NSUserDefaults class]];
id< UITableViewDelegate , MoctaStub> delegate = [Mocta objectWithProtocol:@protocol(UITableViewDelegate)];

Expectations

Expectations are ran on dealloc, so I don't have to do it manually.

Keybase proof

I hereby claim:

  • I am kylef on github.
  • I am kylef (https://keybase.io/kylef) on keybase.
  • I have a public key whose fingerprint is 4130 FDF9 EB2D 440D CD17 8114 C73A 0893 E165 0558

To claim this, I am signing this object:

import requests
"""
Simple script to delete every dns entry for a cloudflare domain.
Depends on requests (pip install requests). Then fill in the
following three variables:
"""
token = 'INSERT API TOKEN'
@kylef
kylef / dispatch.fcgi
Created May 21, 2009 13:58
Django fastCGI dispatcher
#!/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 / iphone-update-checker.py
Created June 17, 2009 13:36
This python script queries iTunes update url to see if iPhone OS 3.0 has been released for the iPhone 3G
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 July 8, 2009 23:46
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.
"""
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 / russian_roulette.cpp
Created January 10, 2010 13:19
This is a russian routlette module which may kick a user when he says !roulette
#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 / irc-znc.xml
Created January 10, 2010 02:07
This is a SMF script for OpenSolaris for ZNC
<?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 / irc-unreal.xml
Created January 11, 2010 15:18
This is a SMF script for OpenSolaris for UnrealIRCd
<?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'
@kylef
kylef / getdelim.c
Created January 15, 2010 16:20
Mac OS X port of getdelim by Simon Josefsson
/* getdelim.c --- Implementation of replacement getdelim function.
Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005 Free
Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but