Skip to content

Instantly share code, notes, and snippets.

View patte's full-sized avatar
🏝️

Patrick Recher patte

🏝️
View GitHub Profile
@patte
patte / proxy_server.go
Created February 15, 2024 11:39
litefs proxy_server.go with simple websocket support
package main
import (
"io"
"log"
"net/http"
"net/http/httputil"
"net/url"
)
var topojsonClient = require("topojson-client")
ch = await fetch("https://swiss-maps.vercel.app/api/v0?format=topojson&projection=wgs84&year=2022&shapes=lakes").then(res => res.json())
geo = topojsonClient.feature(ch, ch.objects.lakes)
console.log(JSON.stringify(geo, null, 2))
@patte
patte / Logitech G502 X.md
Last active November 6, 2022 02:02
Logitech G502 X (HID, hidraw)
@patte
patte / wireguard-allowedips-exclude.md
Created April 1, 2021 20:49
exclude one address from Wireguard AllowedIPs

exclude one address from Wireguard AllowedIPs

The following python script calculates the network addresses in CIDR notation (ready to be set in the config to AllowedIPs =) to route all traffic (0.0.0.0/0) except for one address (30.31.32.33/32) through the wireguard interface. This is usefull if you run wireguard over another tunnel (e.g. udp2raw).

$ python3

import ipaddress
n1 = ipaddress.ip_network('0.0.0.0/0')
n2 = ipaddress.ip_network('30.31.32.33/32')
l = list(n1.address_exclude(n2))
{
"data": {
"questionnaire": {
"id": "f44ac7ae-fa51-4565-aa90-fbcbf42bba40",
"userMainstreamScore": 0,
"answerSets": {
"userAnswerSet": null,
"sets": [
{
"id": "1111100000",
@patte
patte / messages.csv
Last active January 20, 2019 16:05
fb
outbound day hour label
true 1204844400000 1502 07.03.2008 15:02
true 1205276400000 1133 12.03.2008 11:33
false 1205276400000 1548 12.03.2008 15:48
true 1205362800000 053 13.03.2008 00:53
true 1205535600000 110 15.03.2008 01:10
false 1207692000000 1546 09.04.2008 15:46
false 1208296800000 1755 16.04.2008 17:55
true 1208383200000 1438 17.04.2008 14:38
true 1208383200000 1448 17.04.2008 14:48

Archive a repo history

How to archive a repo and copy the last n commits to a new one. republik/magazine is used as an example here.

Preparation

  1. Ìnstall git script rebase-from
git config --global alias.rebase-from '!b="$(git branch --no-color | cut -c3-)" ; h="$(git rev-parse $b)" ; echo "Current branch: $b $h" ; c="$(git rev-parse $1)" ; echo "Recreating $b branch with initial commit $c ..." ; git checkout --orphan new-start $c ; git commit -C $c ; git rebase --onto new-start $c $b ; git branch -d new-start ; git reflog expire --expire=all ; git gc --prune=all'
@patte
patte / fixCombiningDiaeresis.js
Created October 8, 2018 14:05
fix UTF8 combining diaeresis
//https://www.fileformat.info/info/unicode/char/0308/index.htm
//https://vi.stackexchange.com/questions/3557/can-i-search-for-a-unicode-combining-character-in-vim
const fs = require('fs')
const path = __dirname+'/article.md'
const buffer = fs.readFileSync(path)
const fixed = buffer.toString('utf8')
.replace(/a\u0308/g, 'ä')

republik

  • greeting (+pubsub)
  • searches (expire 3d)
  • pubsub comment
  • pubsub webNotification

publikator

  • mailchimpCampaignId (expire 8w)
  • commits (expire 8w)
@patte
patte / Operation verbrennt.md
Last active June 22, 2018 17:54
delete (pre*)publications from redis
  1. connect to redis
heroku redis:cli redis-NAME -a republik-api
  1. delete keys
EVAL "return redis.call('del', unpack(redis.call('keys', ARGV[1])))" 0 *publication