This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Requires 'GatewayPorts clientspecified' to be set in /etc/ssh/sshd_config | |
HOST="muetsch.io" | |
REMOTE_PORT="8080" | |
REMOTE_BIND_V4="127.0.0.1" | |
PROXY_URL="https://local.muetsch.io" | |
echo -e "----------- localssh -----------" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = file_get_contents('php://input'); | |
$json = json_decode($data); | |
header("Content-type: application/json"); | |
if ($json->_type !== 'location') { | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
import os | |
import re | |
import shutil | |
# A script to help you migrate your whole WhatsApp chat history with a person to Telegram | |
# Instructions | |
# 1. Install "Backup WhatsApp Chats" extenstion to Chrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://livebook.manning.com/book/postgis-in-action-second-edition/chapter-17/242 | |
-- with a couple of bugs fixed | |
CREATE OR REPLACE FUNCTION get_rast_tile( | |
param_format text, -- e.g. 'image/png' | |
param_width integer, -- e.g. 256 | |
param_height integer, -- e.g. 256 | |
param_srid integer, -- e.g. 'EPSG:3857' | |
param_bbox text, -- e.g. '660415.9243839228,3713005.085980721,665307.8941941742,3717897.0557909757' in EPSG:3857 | |
param_schema text, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://livebook.manning.com/book/postgis-in-action-second-edition/chapter-17/242 | |
// https://gist.github.com/muety/9e3a6d0ad2bb5890c081670e0c4fc044 | |
<?php | |
define("DSN", "host=localhost dbname=postgis_in_action user=postgis_in_action port=5432 password=whatever"); | |
$param_format = $_REQUEST['FORMAT']; | |
$param_width = (int) $_REQUEST['WIDTH']; | |
$param_height = (int) $_REQUEST['HEIGHT']; | |
$param_bbox = $_REQUEST['BBOX']; | |
$param_schema = $_REQUEST['SCHEMA']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# TODO: https://stackoverflow.com/a/58840987/3112139 | |
import os | |
import stat | |
import time | |
import logging | |
import asyncio | |
from dataclasses import dataclass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run with gunicorn: | |
# gunicorn --preload --workers 4 --worker-class=uvicorn.workers.UvicornWorker app.main:app | |
# ('preload' is the important bit here) | |
# alternatively, set GUNICORN_CMD_ARGS='--preload' | |
import ctypes | |
import multiprocessing as mp | |
from fastapi import FastAPI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reboot after 5 minutes of disconnect | |
let wait_sec = 30; | |
let retries = 10; | |
let c = 0; | |
let timer = Timer.set(wait_sec * 1000, true, function () { | |
Shelly.call('WiFi.GetStatus', null, function (result, error_code) { | |
if (result.status !== 'got ip') { | |
if (c++ < retries) { | |
print('wifi not connected, waiting another', (retries - c) * wait_sec, 'seconds until reboot'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://localhost:8080 { | |
@get method GET | |
@propfind method PROPFIND | |
root * /tmp/data | |
# TODO: add basic auth for DELETE, PROPPATCH, LOCK, etc. | |
# TODO: add matchers so uploaded file keys must be uuids | |
route { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
if __name__ == '__main__': | |
while True: | |
with open('/sys/class/power_supply/BAT0/current_now', 'r') as f: | |
current = float(f.readline().strip()) | |
with open('/sys/class/power_supply/BAT0/voltage_now', 'r') as f: | |
voltage = float(f.readline().strip()) | |
print(f'{current * voltage / 1000000000000} W', end='\r') |