Skip to content

Instantly share code, notes, and snippets.

@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")
#!/usr/bin/ruby
#
# Reads lines from STDIN such as
#
# 00000001 01234578
#
# and assumes that the first column is a register offset and the 2nd is a value.
#
# Will then output the all registers ever accessed with the value they were set to last.
#!/usr/bin/python
# Find patterns in a text an remove then, along with everything that follows in
# curly braces ({}). The matched pattern may as well contain nested curly brances.
# Patterns may spread across multiple lines.
import sys
import fileinput
def strip_first(s, pattern, count):