Skip to content

Instantly share code, notes, and snippets.

@Jonty
Jonty / gist:6705090
Last active October 29, 2018 15:06
Unicode printable character filter
def strip_string(self, string):
"""Cleans a string based on a whitelist of printable unicode categories
You can find a full list of categories here:
http://www.fileformat.info/info/unicode/category/index.htm
"""
letters = ('LC', 'Ll', 'Lm', 'Lo', 'Lt', 'Lu')
numbers = ('Nd', 'Nl', 'No')
marks = ('Mc', 'Me', 'Mn')
punctuation = ('Pc', 'Pd', 'Pe', 'Pf', 'Pi', 'Po', 'Ps')
@Jonty
Jonty / uniq.py
Created October 12, 2013 20:34 — forked from ntlk/uniq.py
import sys
def process_lines(lines):
for index, line in enumerate(lines):
last_line = lines[index - 1]
if line != last_line:
sys.stdout.write(line)
process_lines(sys.stdin.readlines())
@Jonty
Jonty / sort.py
Last active December 25, 2015 11:19 — forked from ntlk/sort.py
import sys
lines = sys.stdin.readlines()
lines.sort(reverse = ('-r' in sys.argv))
print ''.join(lines)
@Jonty
Jonty / interleave_list_chunks.py
Created January 22, 2014 19:15
A tiny function for interleaving lists with configurable amounts from each list in each chunk.
def interleave_chunks(lists):
while lists:
items, amount = lists.pop(0)
subset = items[0:amount]
items = items[amount:]
if subset:
for item in subset:
yield item
@Jonty
Jonty / flip.py
Created February 21, 2014 19:26
IRCCat (using command_runner) command for table flipping.
#!/usr/bin/python
# coding=utf8
import sys
import upsidedown
if len(sys.argv) != 6:
sys.exit()
table_string = upsidedown.transform(sys.argv[5])
output = u"(╯°□°)╯︵ ┻━" + table_string + u"━┻"
#!/bin/env/python
import socket
import string
import time
recieve_address = ('0.0.0.0', 12000)
send_address = ('127.0.0.1', 9998)
# Set a mapping to -1 to ignore messages
# Set a mapping to 0 to pass them through rather than delaying
#!/bin/env/python
import socket
import string
import time
recieve_address = ('0.0.0.0', 12000)
listen = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
listen.bind(recieve_address)
import random
class Node:
def __init__(self, children):
self.children = []
root = Node([])
nodes_to_process = [root]
count = 0
@Jonty
Jonty / emf_cfp_email.txt
Created July 14, 2014 14:27
Electromagnetic Field 2014 Call For Participation
Hello!
Electromagnetic Field (EMF) is a volunteer-run non-profit maker/hacker camping festival in the UK. We held our first event in 2012, and this year we're back and bigger than ever: a camping festival with over 1200 people of all ages, just outside Milton Keynes for a long weekend between the 29th and 31st of August.
We run this event to promote people making and learning things across as many disciplines as possible. We'll take over a large field, roll out power and internet to every tent, and put on talks and workshops for three days.
If you'd like a better idea of what that looks like, our website might help:
https://www.emfcamp.org/about
Our Call For Participation is open: we're looking for people to talk or give workshops. At previous events, we've had a huge variety of talks on everything from genetic modification to electronics, blacksmithing to high-energy physics, reverse engineering to lock picking, computer security to crocheting, and quadcopters to brewing. If you'd like to talk, we'll try