Skip to content

Instantly share code, notes, and snippets.

@dnng
dnng / unicode_code_point_fix.py
Created October 13, 2017 20:04
Fix file encoding when file has unicode code points written as strings (eg: "a string with u00e1 or \u00d1 code point as string in it")
from re import compile, findall, split
with open('original_file', 'r') as of:
with open('fixed_file', 'w') as ff:
for line in of:
# looks for substrings that are either 'u00fo' or '\u00fo'
pattern = compile(r'\\?u00..')
code_points = findall(pattern, line)
pieces = split(pattern, line)
res = ''
@dnng
dnng / lutti.py
Last active March 21, 2018 06:19
import argparse
import logging
VERSION = '3.0'
parser = argparse.ArgumentParser(description='Luttify your messages')
parser.add_argument('message', metavar='message', type=str,
help='add a Lutti to be Luttified')
parser.add_argument('-up', '--uppercase', action='store_true',
default=False, dest='uppercase',
help='outputs Lutti\'s message as it should be')
@dnng
dnng / Makefile
Created October 4, 2023 05:32 — forked from weshouman/Makefile
arduino cli tips
VERSION=0.14.0
SPECIFIER=arduino-cli_${VERSION}_Linux_64bit
BINDIR=/usr/local/bin/
# - Avoid redownloading
# - Avoid overwriting
# - To overwrite, use make uninstall
install:
TMPDIR=/tmp/$(SPECIFIER) && \
mkdir -p $${TMPDIR} && \