Skip to content

Instantly share code, notes, and snippets.

@zonque
zonque / mcast-receiver.go
Last active September 11, 2024 07:17
Multi mulitcast receiver in Go
package main
import (
"fmt"
"net"
"os"
"strconv"
"strings"
"sync/atomic"
"time"
#!/usr/bin/python
import xml.etree.ElementTree as ET
from dateutil import parser
def fixup_trackpoint_callback(trackpoint):
timeElement = trackpoint.find("{http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}Time")
distanceElement = trackpoint.find("{http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2}DistanceMeters")
distance = float(distanceElement.text)
@zonque
zonque / s3-bucket-cleanup.py
Last active November 26, 2023 20:31
Remove objects from s3
import boto3
import concurrent
import threading
import os
import magic
import pathlib
region_name = "eu-central-1"
bucket_name = ""
access_key_id = ""
server {
listen 8009;
location / {
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Headers * always;
add_header Access-Control-Allow-Methods * always;
proxy_pass http://localhost:8008;
}
}
@zonque
zonque / gist:9e5a14c01b68b999b200094e03a00486
Created March 9, 2020 20:17
Ignore Keyspan devices in X11
# /usr/share/X11/xorg.conf.d/99-ignore-keyspan.conf
Section "InputClass"
Identifier "Keyspan blacklist"
MatchVendor "Keyspan"
Option "Ignore" "on"
EndSection
@zonque
zonque / gitconfig
Created September 27, 2019 08:31
gitconfig gems
[alias]
sm = submodule
lol = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
lsr = for-each-ref --format='%(committerdate:iso8601) %(committerdate:relative) %(refname)' --sort -committerdate
untracked = ls-files --other --exclude-standard
pr = "!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
pr-clean = "!git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done"
@zonque
zonque / crc32.c
Last active September 18, 2019 20:17
CRC32 implementation in C matching Go's crc32.ChecksumIEEE
#include <stdio.h>
#include <stdint.h>
// License: MIT
static const uint32_t table[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
@zonque
zonque / uio-mmap.cpp
Created August 6, 2019 09:55
Iterator over UIO devices
// License: MIT
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/user.h>
@zonque
zonque / rm-rf.c
Created June 17, 2019 09:03
Very minimal implementation of a recursive 'rm' in plain C
/*
* Very minimal implementation of a recursive 'rm'.
*
* gcc -Wall -o rm-rf rm-rf.c
*
* License: MIT
*/
#include <unistd.h>
#include <dirent.h>
@zonque
zonque / localaddr.go
Created March 20, 2019 08:20
Get local IP that a given host can reach the local machine on
package main
import (
"fmt"
"log"
"net"
)
func localAddrForHost(host string) (string, error) {
conn, err := net.Dial("udp", host + ":12345")