Skip to content

Instantly share code, notes, and snippets.

View zopieux's full-sized avatar

Alexandre Macabies zopieux

View GitHub Profile
### Keybase proof
I hereby claim:
* I am zopieux on github.
* I am zopieux (https://keybase.io/zopieux) on keybase.
* I have a public key ASCq3dB3j_rLJ_JoF2t2F5Km_8nVHoa-v_nNsWh0aDEBUgo
To claim this, I am signing this object:
@zopieux
zopieux / README.md
Last active May 2, 2024 15:12
QNAP TS-453 Pro: LCD, LEDs, fan & buttons

QNAP TS-453 Pro: LCD, LEDs, fan & buttons

QNAP NAS model TS-453 Pro has limited documentation on how to control its various peripherals, namely:

  • the front LCD display, a 2 row, 16 column blue & white LCD display, and its two menu buttons ("ENTER", "SELECT")
  • the front LEDs "STATUS" (red & green) & "USB" (blue)
  • the 4 "disk error" LEDs (red)
  • the front "USB COPY" button
  • the main rear fan
@zopieux
zopieux / ocr-pdf.py
Last active April 7, 2018 17:41
Google OCR to PDF invisible overlay
#!/usr/bin/env python3
"""
Example usage:
$ pip install reportlab pillow
$ ./overlay.py these-lemaire.tiff 'ocr/{p}.json' these-lemaire.pdf
"""
import argparse
import json
@zopieux
zopieux / citename.py
Created March 28, 2018 13:22
Sphinx citation title
import docutils.nodes
import sphinx.roles
class CiteRole(sphinx.roles.XRefRole):
def result_nodes(self, document, env, node, is_ref):
keys = node['reftarget'].split(',')
refnodes = [
docutils.nodes.reference(classes=['citation'], refuri=key)
for key in keys]
@zopieux
zopieux / override.conf
Created February 26, 2018 23:41
Docker on NFS with automount
# /etc/systemd/system/docker.service.d/override.conf
# TODO: use systemd-automount?
# defeats the purpose of the /net discovering service, though
[Service]
# trigger mount (share is /docker)
ExecStartPre=/usr/bin/stat /net/SERVER/docker
# umount
ExecStopPost=/usr/bin/umount /net/SERVER/docker
@zopieux
zopieux / github-clone-fork
Last active December 2, 2022 15:13
Clone GitHub forked repo and add upstream remote
#!/bin/bash
set -e
fatal() {
echo $@
exit 1
}
repo=$1
from curio import run, spawn, open_connection, sleep
import argparse
import collections
import re
TOKEN = re.compile(r'([\S]{3,})', re.I)
async def client(opts):
q = collections.deque(maxlen=opts.window)
@zopieux
zopieux / kth_perm.py
Created July 24, 2017 14:32
kth permutation
def kth_perm(n, k):
res = list(range(n))
for i in range(n):
f = math.factorial(n - i - 1)
s, m = divmod(k, f)
if m == 0 and s == 0:
break
if s > 0:
for j in range(i - 1 + s, i - 1, -1):
res[j-1], res[j] = res[j], res[j-1]
@zopieux
zopieux / wallpaper.py
Created June 4, 2017 10:52
Yet another reddis-to-wallpaper script
#!/usr/bin/env python
from PIL import Image, ImageDraw, ImageFont
import io
import re
import requests
import subprocess
import time
FNAME = '/tmp/wallpaper'
@zopieux
zopieux / logging_refactor.py
Last active April 26, 2017 23:35
logging.* auto refactoring
import ast
import copy
from pathlib import Path
import asttokens
import astunparse
import string
LOGGING_METHODS = {'debug', 'info', 'warn', 'warning', 'exception', 'error', 'fatal', 'critical'}