Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🧠🔥

Patrick Meyer HerrSpace

💭
🧠🔥
View GitHub Profile
View gist:58bace2634ab972b7ed8bd76c6143ddf
- prepare a new puppet branch with the updated version in the postgresql globals
- add the new pkgs to your repo and install them on the server
- systemctl stop postgresql@<old-version>
- systemctl stop postgresql@<new-version>
- pg_dropcluster <new version> main --stop
- try pg_upgradecluster <old version> main -j <cores> --link --method=upgrade
- if that fails try pg_upgradecluster <old version> main
- pg_dropcluster <old version> main
- run puppet with your new branch
- uninstall the old pg version
View json_dumb.py
In [7]: zz={1:2, '1':'2'}
In [8]: zz
Out[8]: {1: 2, '1': '2'}
In [9]: json.dumps(zz)
Out[9]: '{"1": 2, "1": "2"}'
In [11]: qq=json.loads(json.dumps(zz))
@HerrSpace
HerrSpace / paramiko_agent.py
Last active Apr 3, 2019
Using paramiko to use and abuse ssh keys for signing and verifying. Load keys from agent or disk.
View paramiko_agent.py
#!/usr/bin/env python3
# Example 1: Load priv and pub from file
from paramiko import RSAKey
# Load key from file, not from agent.
key = RSAKey.from_private_key_file('/Users/space/.ssh/tuer')
msg = key.sign_ssh_data(b"somestuff")
msg.rewind()
# This derives the public key.. Obviously.
pub = RSAKey(data=key.asbytes())
View git_version.py
def git_version(path):
# Like v1.0.0 or v1.0.0-1-g963fc39.dirty
git_describe = check_output([
'git', '-C', path, 'describe', '--tags', '--dirty=.dirty']
).decode().strip()
# Like v1.0.0
last_tag = check_output([
'git', '-C', path, 'describe', '--tags', '--abbrev=0']
).decode().strip()
View python3-abfuck
╭─space@FeTAp ~
╰─$ python
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> b'\x00'.join(b'\x11\x11\x11')
'\x11\x00\x11\x00\x11'
>>> ^D
╭─space@FeTAp ~
╰─$ python3
View postgresql.service
# systemd service for managing all PostgreSQL clusters on the system. This
# service is actually a systemd target, but we are using a service since
# targets cannot be reloaded.
[Unit]
Description=PostgreSQL RDBMS
[Service]
Type=oneshot
ExecStart=/bin/true
@HerrSpace
HerrSpace / find_orphants.py
Created Jun 30, 2017
Find orphant stubnitz media archive dirs not linked to any event in the db.
View find_orphants.py
#!/usr/bin/env python
import os, re
from mysql.connector import MySQLConnection, Error
__author__ = 'Patrick <space> Meyer'
ARCHIVE_MOUNT = '/var/www/'
EVENT_DIR_RE = ARCHIVE_MOUNT + r'current-archive\/(audio|video|bilder)\/[0-9]+\/[0-9]+\/[0-9]+\/[0-9]+'
View laser-mods.md

Lasercutter Mods

Wasser Temperatur Ueberwachung

Problem: Der Lasercutter wird Wassergekuehlt. Das Wasser darf nicht > 25 Grad werden, sonst stirbt die Laserroehre (noch) schneller. Loesung: Das Wasser muss Temperatur ueberwacht werden. Benoetigte Komponenten:

  • Arduino + Netzteil. (Nicht interne 5V benutzen!)
@HerrSpace
HerrSpace / opensmtpd.service
Created May 24, 2017
A systemd service file for opensmtpd.
View opensmtpd.service
[Unit]
Description=Opensmtpd Mailserver
[Service]
Type=simple
ExecStartPre=/usr/sbin/smtpd -n
ExecStart=/usr/sbin/smtpd -d
ExecStop=/usr/sbin/smtpctl stop
[Install]
@HerrSpace
HerrSpace / n26.sh
Created Jun 27, 2016
Curl number26 transactions.
View n26.sh
curl 'https://api.tech26.de/oauth/token' -H 'Authorization: Basic bXktdHJ1c3RlZC13ZHBDbGllbnQ6c2VjcmV0' --data-urlencode 'username=' --data-urlencode 'password=' --data 'grant_type=password' | jq -r '.["access_token"]' | (read token; curl 'https://api.tech26.de/api/smrt/transactions?limit=50' -H "Authorization: bearer $token") | jq
You can’t perform that action at this time.