Skip to content

Instantly share code, notes, and snippets.

View skywodd's full-sized avatar

Fabien Batteix skywodd

View GitHub Profile
@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):
@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 / 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 / unicoder.py
Created July 26, 2017 19:53
Unicoder - The unicode nightmare for developers.
"""
Unicoder - The unicode nightmare for developers.
"""
import os
import sys
import random
import codecs
import argparse
import unicodedata
@skywodd
skywodd / Configuration.h
Last active April 18, 2022 22:31
Marlin 1.1.x configuration files for the Prusa i3 rework 1.5 (eMotion) [TESTED WORKING]
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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 3 of the License, or
@skywodd
skywodd / updatedb.py
Last active September 25, 2017 19:45
Incremential backup script for NGINX logs files. Store log entries in a SQlite3 database. Ignore existing entries using SHA256.
"""
Incremential backup script for NGINX logs files.
"""
import re
import sqlite3
import argparse
from hashlib import sha256
import pdb
@skywodd
skywodd / resize_gif.py
Created November 3, 2017 12:48
Resize GIF image using Python Pillow library
from PIL import Image, ImageSequence
# Output (max) size
size = 320, 240
# Open source
im = Image.open("in.gif")
# Get sequence iterator
frames = ImageSequence.Iterator(im)
@skywodd
skywodd / dmm4.py
Last active February 15, 2023 10:52
Serial protocol decoder for UNI-T UT61C (GS)
"""
Serial protocol decoder for UNI-T UT61C (GS).
"""
import serial
BV = lambda x: 1 << x
FLAGS = {
BV(0): 'BPN', # Bargraph rule
@skywodd
skywodd / userdata.py
Created April 18, 2018 15:54
[Django 2.0 management command] Export all data related to the given user.
"""
Export all data related to the given user.
"""
from django.contrib.auth.models import User
from django.core.serializers import serialize
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
@skywodd
skywodd / semantictext.md
Created May 28, 2018 16:32
SemanticText syntax proposal

SemanticText

SemanticText is a proposal for a new text-based writing syntax for the web (and much more).

Status: Draft - Request for comments

Revision: 2.0.0

Context of creation