Skip to content

Instantly share code, notes, and snippets.

Fletcher Tomalty fletom

Block or report user

Report or block fletom

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
View q&a.css
p.q:before {
content: "Q: ";
font-weight: bold;
}
p.a:before {
content: "A: ";
font-weight: bold;
}
@fletom
fletom / iterzipstream.py
Created Oct 21, 2014
Dynamically create a zip archive in Python with iterable input and iterable output.
View iterzipstream.py
#!/usr/bin/env python
"""
Iterable ZIP archive generator.
Modified from https://github.com/SpiderOak/ZipStream.
"""
import struct, os, sys
import binascii
View pervy.js
// The Omegle.com "pervy chat" detection algorithm. (From http://www.omegle.com/static/omegle.js.)
function pervy(s) {
return /^\s*f\s*\?\s*$|horny|slut|(?:rub|touch|lick|suck|finger)\s+(?:my|your|ur)|boner|(am|i'm|so|im|my|your?)\s+(hard|wet|tight)|\bcum|sexy|boob|\btits\b|nipple|penis(?:[^e]|$)|cock(?:[^s]|$)|dick(?:[^s]|$)|\bvag(?:\b|ina)|pussy|\bclit|spank|(?:jack|jerk)\s+off|\bfap|nudes|kink/i.test(s);
}
/*
An expanded version of this regex for readability:
/
^\s*f\s*\?\s*$|
View crypto.py
import base64
from Crypto.Cipher import AES
from Crypto.Hash import SHA256, HMAC
from Crypto.Random import get_random_bytes
class Cipher(object):
# This can be 16 (AES-128), 24 (AES-192), or 32 (AES-256)
key_length = 32
View gist:6471167
In [41]: from Crypto.Cipher import AES
In [42]: from Crypto import Random
In [43]:
In [43]: key = b'Sixteen byte key'
In [44]: iv = Random.new().read(AES.block_size)
@fletom
fletom / gist:4164773
Created Nov 28, 2012
Python language code
View gist:4164773
def english_count(count, object = None, plural = None):
"""
Generate an English representation of the count of objects. Plural defaults to object + 's' or object[:-1] + 'ies' for objects ending in 'y'.
Examples:
In [2]: english_count(0, 'hat')
Out[2]: 'no hats'
In [4]: english_count(1, 'hat')
@fletom
fletom / pascals_triangle.py
Last active Oct 6, 2015
A concise generator of the rows of Pascal's triangle
View pascals_triangle.py
def pascals_triangle():
row = [1]
while True:
yield row
row = map(sum, zip([0] + row, row + [0]))
@fletom
fletom / gist:2784466
Created May 24, 2012
Indented HTML attributes
View gist:2784466
<a
id="some_id"
href="http://matchfwd.com/"
class="some_class et_cetera"
rel="twipsy"
title="Mouseover tooltip text."
>
Link text
</a>
View gist:1649392
def is_hidden(self):
if self.state == 'HIDDEN':
return True
return False
@fletom
fletom / gist:1163995
Created Aug 23, 2011 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
View gist:1163995
Day job:
Freelance programmer and web developer
Favorite Python project:
Django!
Favorite Conference:
You can’t perform that action at this time.