Skip to content

Instantly share code, notes, and snippets.

View wosc's full-sized avatar

Wolfgang Schnerring wosc

View GitHub Profile
@wosc
wosc / hatch-release.sh
Created March 19, 2023 17:07
Release dance for a python package with hatch
#!/bin/bash
# Generic "Bump version, update changelog, git tag, upload to pypi, bump version" workflow,
# like zest.releaser+setuptools, but for hatch+towncrier
# Matching pyproject.toml example: https://github.com/wosc/nginx-db-auth/blob/1.1.0/pyproject.toml
# (the salient points are 1) `hatch run release:towncrier`, 2) `dynamic = ["version"]`, 3) file locations for changelog and version)
set -ex
changelog=$(hatch run release:towncrier build --version=draft --draft 2>&1)
if echo "$changelog" | grep -q "No significant changes"; then
@wosc
wosc / README.md
Created July 8, 2021 07:49
Creating tracing data from an haproxy access log via fluent bit and opentelemetry collector

Creating opentelemetry tracing data from an haproxy access log

Approach

Unfortunately, otelcol currently has no receiver for logfiles that produces tracing data. There is log tailing functionality, and e.g. a fluent forward protocol receiver, but they all create "log" data, not tracing. I've seen this proof of concept to implement a forward receiver that creates tracing data, but that seems to have no traction and no relation to the upstream project at all (not even git history.

Thus, we've settled on this approach:

@wosc
wosc / mac-open-terminal-and-wait.sh
Created January 12, 2019 13:59
Launch a command in a new macOS terminal window and block until it exits
#!/bin/bash
# Adapted from https://github.com/jlebon/files/blob/master/bin/gnome-terminal-wrapper
set -euo pipefail
# Needs `flock` command from https://github.com/discoteq/flock
# which can be installed via homebrew (which is not on the PATH by default)
export PATH=/usr/local/bin:$PATH
tmpf=$(mktemp)
trap "rm -f $tmpf" EXIT
@wosc
wosc / Vagrantfile
Created December 18, 2018 19:52
Build unison-2.51.2 deb, compatible with the MacOS binary release
Vagrant.configure("2") do |config|
config.vm.define "default" do |default|
default.vm.hostname = "unisonbuild"
default.vm.provider "lxc"
default.vm.box = "zeitonline/bionic64-lxc"
# default.vm.box = "bento/ubuntu-18.04"
end
end
@wosc
wosc / backup-shaarli.sh
Created March 29, 2018 12:01
Automated export of bookmarks from Shaarli
#!/bin/bash
# Export bookmarks from Shaarli <https://github.com/shaarli/Shaarli> in Netscape HTML format.
# Adapted from <https://github.com/nodiscc/shaarchiver>
url=$1
user=$2
pass=$3
cookies=$(mktemp)
curl="curl -s --cookie-jar $cookies --cookie $cookies"
@wosc
wosc / routing.yml
Created July 14, 2016 09:04
Enable basic auth for wallbag export by adding these configuration statements (files are in app/config/)
backup:
path: "/backup/{category}.{format}"
defaults:
_controller: WallabagCoreBundle:Export:downloadEntries
requirements:
category: all|unread|starred|archive
format: epub|mobi|pdf|json|xml|txt|csv
#!/usr/bin/env python
import json
import sys
# See https://msdn.microsoft.com/en-us/library/aa753582%28VS.85%29.aspx
# and https://github.com/shaarli/Shaarli/blob/v0.6.5/index.php#L1899
HEADER = u'<!DOCTYPE NETSCAPE-Bookmark-file-1><DL>'
FOOTER = u'</DL>'
ITEM = u'<DT><A HREF="{url}" ADD_DATE="{time_created}" TAGS="{tags}">{title}</A>'
@wosc
wosc / backup-delicious.py
Created April 13, 2016 17:40
Backup all your delicious.com bookmarks by scraping the UI-facing API
import json
import requests
import sys
BASE_URL = 'https://avosapi.delicious.com/api/v1/posts/you/time'
def get_bookmarks(entry, auth):
if not entry:
r = requests.get(BASE_URL, auth=auth)
@wosc
wosc / slack-readline.user.js
Created February 18, 2015 20:00
Greasmonkey User Script for Slack: Restore Readline Keybindings
// ==UserScript==
// @name Slack: Restore Readline Keybindings
// @namespace http://wosc.de/
// @version 1.0
// @description Don't let Slack capture keybindings for C-u and C-k (use C-o to open omnibox instead)
// @author Wolfgang Schnerring <wosc@wosc.de>
// @match https://*.slack.com/*
// @grant none
// ==/UserScript==

Keybase proof

I hereby claim:

  • I am wosc on github.
  • I am wosc (https://keybase.io/wosc) on keybase.
  • I have a public key whose fingerprint is D062 178B 7F40 C78F 7724 24CE 61F5 821D E73B C3B4

To claim this, I am signing this object: