Skip to content

Instantly share code, notes, and snippets.

View ties's full-sized avatar

Ties de Kock ties

  • The Netherlands
View GitHub Profile
// ...
/**
* 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 %}
"""
An old fiddle when we were investigating the size of the ranges owned by Ziggo…
"""
import aiohttp
import asyncio
import json
import itertools
import netaddr
@ties
ties / routinator-grafana-prometheus-dashboard.json
Created January 12, 2020 16:25
Routinator dashboard for Grafana with Prometheus as datasource
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
from passlib.context import CryptContext
myctx = CryptContext(schemes=['argon2', 'bcrypt'], deprecated=['bcrypt'])
# h ~= hash('password', 'bcrypt')
h="$2b$12$/kdxAcUQ432BgwKzhTwGM.CKq7gDHAhgDIYE3zyTirDahma6EshhK"
myctx.needs_update(h)
# True
(verifies, new_hash) = myctx.verify_and_update("password", h)
@ties
ties / cbs_odata_ggplot2.Rmd
Created July 25, 2019 09:55
Een voorbeeld van CBS open data in combinatie met ggplot2
---
title: "Voorbeeld van CBS open data in combinatie met ggplot2"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
list.of.packages <- c(
"cbsodataR", "smooth", "zoo", "Mcomp", "svglite"
@ties
ties / get_event_loop_tests.py
Last active May 8, 2019 08:57
Tests basic assumptions about running event loops.
"""
Tests basic assumptions about running event loops.
Gets and compares the result of `get_event_loop` with `get_running_loop` before
and after setting it to None.
A more strict situation than in the documentation holds (for Python 3.7.3),
given default event loop policy:
`get_event_loop` returns the same result after setting the event loop to None,
when ran from a coroutine.
version: '2.1'
services:
#
# Nextcloud
#
nextcloud:
image: nextcloud
depends_on:
- nextcloud-db