Skip to content

Instantly share code, notes, and snippets.

View skywodd's full-sized avatar

Fabien Batteix skywodd

View GitHub Profile
@skywodd
skywodd / lookalikes.py
Created July 24, 2017 19:37
Search for unicode crap
from collections import defaultdict
from PIL import (
Image,
ImageDraw,
ImageFont
)
img = Image.new('1', (8, 16))
font = ImageFont.truetype('arial.ttf', 10)
@skywodd
skywodd / pagination.py
Last active May 4, 2017 14:59
Slice a page range to create a nice pagination effect.
def slice_pagination_range(page_range, page_number, slice_range):
"""
Slice the given ``page_range`` to +/- ``slice_range`` values around the given ``page_number``.
Center the slice on the given ``page_number`` (one based).
First and last values are always in the output slice.
If required, ellipsis are added as ``None`` values.
"""
nb_pages = len(page_range)
@skywodd
skywodd / brainfuck_bytecode.py
Created February 26, 2016 18:15
Yet another Brainfuck interpreter written in Python 3, but with a big plot twist in the implementation
"""
Yet another Brainfuck interpreter written in Python (3.4).
Plot twist: this interpreter craft Python bytecode from the Brainfuck code and execute it.
Yep, dynamic Python bytecode generation from Brainfuck source code. Why? Because I can.
"""
from bytecode import Instr, Label, Bytecode
def bf_rle_encode(input_str):