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
#!/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 \

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 / 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)
@shtrom
shtrom / echo.php
Created February 15, 2021 07:02
A simple echo page in PHP
<?php
/** A simple echo page in PHP
*
* It just outputs the request it received back, including HTTP headers.
*/
if (!function_exists('getallheaders')) {
// Polyfill for PHP<7.3
function getallheaders()
{
@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
@shtrom
shtrom / dial.php
Created November 3, 2020 11:44
dial.php - A simplistic one-page protocol handler for tel: schemes, for FRITZ!Box and Mitel phones
<?php
/**
* dial.php - A simplistic one-page protocol handler for tel: schemes.
*
* Copyright (C) 2020 Olivier Mehani <[email protected]>
*
* This renders a simple HTML form allowing to call a number,
* and to register itself as a protocol handler.
*
* Multiple devices are supported (see the `$devices` array),