Skip to content

Instantly share code, notes, and snippets.

View ties's full-sized avatar

Ties de Kock ties

  • The Netherlands
View GitHub Profile
import argparse
import itertools
import json
import logging
import os
import random
import time
from typing import Dict, List, Optional, Union
import argparse
import logging
import os
import requests
import sys
import urllib.parse
from typing import Optional
import pyotp
@ties
ties / rpki-client.sh
Created May 14, 2021 08:52
rpki-client: run looped
#!/bin/ksh
export BASE=${HOME}
echo "Removing cache and output directory..."
rm -rf ${BASE}/data/rpki-client/cache/*
rm -rf ${BASE}/data/rpki-client/output/*
echo "Running rpki-client"
exec /usr/sbin/rpki-client -vv -t /etc/rpki/ripe.tal -d ${BASE}/data/rpki-client/cache/ ${BASE}/data/rpki-client/output/
@ties
ties / run-intellij-remotely-in-flatpak.md
Last active April 26, 2021 09:50
IntelliJ community idea flatpak over remote X11

Run IntelliJ community edition flatpak over remote X11

Make sure you run XQuartz if you are using a mac and that DISPLAY is set on the host machine.

$ export DISPLAY=:0

And SSH to the target machine with forwarding enabled (ssh -Y [host]) Inspect the environment by running:

$ flatpak run --filesystem=~/.xauth com.jetbrains.IntelliJ-IDEA-Community --command=sh -c "export DISPLAY=$DISPLAY"
@ties
ties / docker-compose.yml
Last active April 9, 2021 19:27
Time machine with docker and samba, even on big sur. Three parts: docker-compose file, time machine config snippet (for in docker volume), and avahi service
# ...
samba:
image: dperson/samba
restart: unless-stopped
command: >-
-u "user;badpass"
-u "timemachine_rmbp;${TIMEMACHINE_RMBP_PASSWORD}"
-s "data;/media/data;yes;yes;yes;all"
ports:
- 139:139
pointwise_experiment_content = session.query(PointwiseExperiment). \
filter(PointwiseExperiment.features==feature_string).subquery('c')
# reindented on phone...
q = session.query(PointwiseExperiment, func.row_number().over(
partition_by=PointwiseExperiment.learner,
order_by=PointwiseExperiment.mse_mean
).label('ord')).select_entity_from(pointwise_experiment_content).subquery()
@ties
ties / host_health.yaml
Last active February 22, 2021 14:22
Prometheus rules for basic machine health of my NAS
groups:
- name: host.health
rules:
- alert: SmartFailure
expr: smartmon_device_smart_healthy != 1
labels:
severity: "critical"
annotations:
summary: "Disk {{ $labels.disk }} on {{ $labels.instance }} has a SMART failure."
- alert: DiskFullPercentage
@ties
ties / read_multiline_file_in_chunks_of_whole_lines.py
Last active February 9, 2021 20:21
Read a file in chunks of [length to the first newline after length chars after previous block]. There may be an easier solution...
import io
def read_in_chunks_of_whole_lines(file, length=1024*1024):
"""Read a file in blocks of length bytes, up to the next newline."""
tail = ""
with open(file, "r") as f:
while True:
chunk = tail + f.read(length)
if not chunk:
return
- name: ssl_expiry.rules
rules:
- alert: SSLCertExpiringSoon
expr: probe_ssl_earliest_cert_expiry - time() < 86400 * 7
for: 10m
annotations:
summary: "SSL certificate for {{ $labels.instance }} is about to expire."
labels:
severity: "warning"
We can't make this file beautiful and searchable because it's too large.
T GULDEN BOEK ( DE CHRISTELIJKE BOEKENCENTRALE ) B.V.,HOUTEN,29.646
"!PET PROJECTINRICHTERS B.V.",HOOGEVEEN,31.956
""" SERVICE- EN VERSPREIDINGSBUREAU WILLEMS "" V.O.F.",DUIVEN,9.402
"""AAN DE MAAS"" EXPLOITATIE B.V.",SCHIEDAM,28.848
"""ACHT"" UITZENDBURO B.V.",ZOETERMEER,70.830
"""ACHT"" UITZENDBURO B.V.",ZOETERMEER,25.086
"""ACHT"" UITZENDBURO B.V.",ZOETERMEER,3.780
"""ART OF PRIVATE SHAKING"" GLASS & BAR SUPPLY B.V.",AMSTERDAM,59.979
"""B.V. BOUW- EN AANNEMINGSBEDRIJF G. DE HAAN EN ZN"".",GARYP,68.658
"""BEMI"" AMUSEMENTSAUTOMATEN B.V.",ENSCHEDE,8.412