Skip to content

Instantly share code, notes, and snippets.

View ties's full-sized avatar

Ties de Kock ties

  • The Netherlands
View GitHub Profile
@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
// ...
/**
* Get an DocumentBuilder that is protected from entity injection.
* @return new DocumenBuilder
* @throws ParserConfigurationException when it feels like being peak java
*/
public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
final var df = DocumentBuilderFactory.newInstance();
df.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
df.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
@ties
ties / 00-fedora30-ansible-font-setup.yml
Created April 29, 2020 06:09
fedora-ansible-font-setup
# Snippet from my 'dotfiles' (in Ansible) that configures the fonts
- name: Install font packages
become: true
dnf:
state: present
name:
- adobe-source-sans-pro-fonts
- adobe-source-serif-pro-fonts
- adobe-source-code-pro-fonts
- mozilla-fira-mono-fonts
@ties
ties / tilde_ssh_dot_config.config
Last active March 29, 2020 11:23
Header of my SSH config (~/.ssh/config): Multiplexing of connections and yubikey using PKCS11Provider
Host *
ForwardX11 no
ForwardX11Trusted no
ForwardAgent no
VisualHostKey yes
ControlMaster auto
ControlPersist 1
ServerAliveInterval 300
ServerAliveCountMax 2
ControlMaster auto
@ties
ties / nginx_proxy_pass.j2
Created March 20, 2020 07:37
Jinja2 fragment to define a reverse proxy
# Use like {{ proxy_pass('/admin', 'reljudge') }}
{%- macro proxy_pass(location, backend_name, host='', backend_proto='http', root=None, extra_conf=None) -%}
location {{ location }} {
{% if root != None %}
root {{ root }};
{% endif %}
proxy_pass {{ backend_proto }}://{{ backend_name }}{{ location }};
{% if backend_proto == 'https' %}
proxy_ssl_session_reuse on;
{% endif %}