This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from PIL import ( | |
Image, | |
ImageDraw, | |
ImageFont | |
) | |
img = Image.new('1', (8, 16)) | |
font = ImageFont.truetype('arial.ttf', 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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): |
NewerOlder