Skip to content

Instantly share code, notes, and snippets.

View shtrom's full-sized avatar
💭
When you're coding, noone needs to see your mouth.

Olivier Mehani shtrom

💭
When you're coding, noone needs to see your mouth.
View GitHub Profile
@shtrom
shtrom / bootstrap.sh
Last active February 1, 2024 22:00
Semi-automated tag deduplicator for Wallabag
#!/bin/sh
python3 -m venv .venv/wallabag_merge_tags
. .venv/wallabag_merge_tags/bin/activate
pip install -r requirements.txt
cat << EOF >&2
*** Now run
. .venv/wallabag_merge_tags/bin/activate
#!/usr/bin/env python
import base64
import hashlib
import json
import logging
import random
import requests
import string
import uuid
@shtrom
shtrom / ssi-extractor.Dockerfile
Last active April 25, 2023 08:37
A Dockerfile to proccess Apache Server-side Include and dump the fully rendered static files https://blog.narf.ssji.net/2023/04/24/render-apache-server-side-includes-docker/
# usage:
#
# docker build -t ssi-extractor - < Dockerfile
# docker run -v ./www:/usr/local/apache2/htdocs/ -v ./out:/out ssi-extractor
FROM httpd:alpine
RUN apk update \
&& apk add wget
RUN sed -i \
@shtrom
shtrom / fritz_cert_upload.py
Last active March 12, 2023 17:01
Upload a TLS key and cert to a FRITZ!Box, in pretty Python
#!/usr/bin/env python3
# vim: fileencoding=utf-8
"""
Upload a TLS key and cert to a FRITZ!Box, in pretty Python
Copyright (C) 2018--2021 Olivier Mehani <shtrom@ssji.net>
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 2 of the License, or
(at your option) any later version.

Fix magisk stock backup does not exist

# put stock boot.img into /sdcard/boot.img

# get sha1
adb shell
su
SHA1=$(cat $(magisk --path)/.magisk/config | grep SHA1 | cut -d '=' -f 2)
@shtrom
shtrom / staticVsSelf.php
Last active September 5, 2022 07:30
`static` vs `self`
<?php
class VarHolder {
const VAR = 2;
public function showVar() {
echo self::VAR;
echo static::VAR;
}
}
@shtrom
shtrom / html_url_encode.py
Last active July 4, 2022 08:08
urlencode, and escape as html entities, all characters
def encode_all(string):
'''
From https://gist.github.com/Paradoxis/6336c2eaea20a591dd36bb1f5e227da2 via https://stackoverflow.com/a/67629249/10660788
>>> encode_all('<script>console.log("hello")</script>')
'%3c%73%63%72%69%70%74%3e%63%6f%6e%73%6f%6c%65%2e%6c%6f%67%28%22%68%65%6c%6c%6f%22%29%3c%2f%73%63%72%69%70%74%3e'
'''
return "".join("%{0:0>2}".format(format(ord(char), "x")) for char in string)
def escape_all(string):
@shtrom
shtrom / CACert.sh
Last active December 28, 2021 01:05
Backport of CACert update scripts (https://www.qnapclub.eu/fr/qpkg/238) for manual use on Qnap QTS 4.3
#!/bin/sh
CONF=/etc/config/qpkg.conf
QPKG_NAME="CACert"
#QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}`
QPKG_ROOT=$(cd $(dirname ${0}); pwd)
QPKG_NAME1="QPerl"
QPKG_ROOT1=`/sbin/getcfg $QPKG_NAME1 Install_Path -f ${CONF}`
export QNAP_QPKG=$QPKG_NAME
@shtrom
shtrom / Zendesk Conversation Fixer.js
Created April 21, 2021 07:57
GreaseMonkey script to fix ZenDesk conversation threads so they are not top-posted
// ==UserScript==
// @name Zendesk Conversation Fixer
// @version 2
// @grant none
// @match https://*.zendesk.com/agent/tickets/*
// ==/UserScript==
function fix(eventContainers) {
console.log("GreaseMonkey ZCF: fixing ...");
const nContainers = eventContainers.length;
@shtrom
shtrom / ndjson2csv.py
Last active March 17, 2021 02:40
Convert an NDJSON file of similarly-formatted object to a CSV file
#!/usr/bin/env python3
import csv, ndjson, itertools, sys
r = ndjson.reader(sys.stdin)
r, rh = itertools.tee(r)
w = csv.DictWriter(sys.stdout, next(rh).keys())
w.writeheader()
for d in r:
w.writerow(d)