Skip to content

Instantly share code, notes, and snippets.

def chunk_bytes(value, bit_length):
"""
Chunk value into bytes of bit_length
"""
for _ in range(0, value.bit_length(), bit_length):
yield value & ((1 << bit_length) - 1)
value >>= bit_length
def one_is_more_encode(value):
"""
Script to use Wooting Gamepad as Mouse
"""
import asyncio
import collections
import signal
import sys
import evdev
import pyudev
@meeuw
meeuw / testallkeys.py
Created August 27, 2021 10:26
script to test all ssh key in your ssh agent key ring, forces gnome-keyring to ask for a passphrase (and allows you to save it).
import hashlib
import paramiko
a = paramiko.agent.Agent()
for key in a.get_keys():
print(key.sign_ssh_data(hashlib.sha1(b'something to sign').digest()))
@meeuw
meeuw / concat.sh
Created August 2, 2021 19:04
concatenate mp4 files
ls "$1/"*|sed "s%^%file $PWD/%" > /tmp/dmlist
ffmpeg -f concat -protocol_whitelist file,pipe -safe 0 -i /tmp/dmlist -c copy "$1.mp4"
@meeuw
meeuw / _ffmpeg_segments.sh
Created August 2, 2021 19:04
ffmpeg split mp4 file
ffmpeg -i "$1" -acodec copy -f segment -vcodec copy -reset_timestamps 1 -map 0 OUTPUT%04d.mp4
<?xml version='1.0'?>
<!DOCTYPE signatures SYSTEM "file://localhost/System/Library/DTDs/BridgeSupport.dtd">
<signatures version='1.0'>
<opaque name='IONotificationPortRef' type64='^{IONotificationPort=}'/>
<constant name='kIOMasterPortDefault' type64='I'/>
<string_constant name='kIOFirstPublishNotification' value='IOServiceFirstPublish'/>
<string_constant name='kIOPublishNotification' value='IOServicePublish'/>
<string_constant name='kIOMatchedNotification' value='IOServiceMatched'/>
<string_constant name='kIOFirstMatchNotification' value='IOServiceFirstMatch'/>
<string_constant name='kIOTerminatedNotification' value='IOServiceTerminate'/>
@meeuw
meeuw / pasuspender_examples.sh
Last active March 20, 2021 07:10
pasuspender examples; without any configuration pulse is used anyway (by the pulse-alsa plugin)
# mpv
pasuspender -- mpv --audio-device=alsa/hdmi:CARD=HDMI,DEV=2 http://...
# scummvm
pasuspender -- env AUDIODEV=hdmi:CARD=HDMI,DEV=2 SDL_AUDIODRIVER=alsa scummvm
@meeuw
meeuw / stravasync.py
Created January 25, 2021 20:03
get activities from strava.com using API and post to google form
import requests_oauthlib
import click
import json
import datetime
import requests
def token_updater(tok):
with open("token.json", "w") as f:
json.dump(tok, f)
@meeuw
meeuw / pystun.py
Created October 2, 2020 19:05
Simple STUN implementation in Python, usage: python pystun.py stun.l.google.com 19302
#!/usr/bin/python
import socket
import uuid
import struct
import io
import sys
def unpack(stream, fmt):
@meeuw
meeuw / lowvol.sh
Created September 28, 2019 19:27
lower wav files volume to 1% using sox
for W in *.wav ; do sox -v .01 $W lowvol/$W ; done