Skip to content

Instantly share code, notes, and snippets.

@mic-e
mic-e / sftpomo.py
Last active February 1, 2024 13:12
Simple libnotify pomodoro timer which enforces i3 workspace focus
#!/usr/bin/env python3
import argparse
import datetime
import math
import json
import os
import subprocess
import threading
import time
import typing
@mic-e
mic-e / http_rx.py
Created April 27, 2023 12:51
Simple file upload server (equivalent of python3 -m http.server)
#!/usr/bin/env python3
from cgi import parse_header, parse_multipart
from http.server import BaseHTTPRequestHandler, HTTPServer
class handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
@mic-e
mic-e / merge_bags.py
Created March 9, 2023 15:36
ros bag merger
#!/usr/bin/env python3
import sys
import argparse
from fnmatch import fnmatchcase
from rosbag import Bag
def main():
@mic-e
mic-e / coredumpselect.py
Last active January 12, 2024 21:03
replacement for coredumpctl
#!/usr/bin/env python3
"""
Allows the user to select one of the coredumps from the journal using fzf,
places the coredump at the given path (default /tmp/coredump),
links the related program binary to the given path (default /tmp/coredump-program),
and optionally attaches gdb.
"""
import argparse
@mic-e
mic-e / gist:697e1295856876378487e09a11fe01c5
Created January 7, 2021 22:29
OnePlus 6 Enchilada LineageOS Update instructions 16.0 -> 17.1
# install device tree for Android P - this is needed for TWRP P to run
fastboot flash dtbo dtbo_op6-P.img (https://kremowka.xyz/files/op_dtbo/dtbo_op6-P.img)
# boot TWRP P - can take a few seconds to come up. TWRP P is needed to install the stock image
fastboot boot twrp-3.3.1-18-enchilada-Pie-mauronofrio.img (https://sourceforge.net/projects/mauronofrio-twrp/files/Enchilada/twrp-3.3.1-18-enchilada-Pie-mauronofrio.img/download)
# upload the stock image installer
adb push <oos10> /tmp (https://oneplus.com/support/softwareupgrade)
# install the stock image. this is needed to get the device tree for Android Q
adb shell twrp install /tmp/<oos10>
adb reboot bootloader
@mic-e
mic-e / machcode.py
Created February 9, 2019 13:00
Machine code <-> Assembly translator using binutils
#!/usr/bin/env python3
import re
import subprocess
def tmppath(what):
return "/tmp/machcode-" + what
def tool(which, prefix="arm-none-eabi-"):
return prefix + which
@mic-e
mic-e / mon.py
Created January 15, 2019 11:23
Monitor autoconfiguration script
#!/usr/bin/env python3
"""
CLI script for setting display modes through xrandr.
"""
from argparse import ArgumentParser
from collections import OrderedDict
import re
from subprocess import call, Popen, PIPE
from shlex import quote
from time import sleep
@mic-e
mic-e / pixelflut.py
Last active December 30, 2016 16:07
pixelflut sinewave, usage: python3 pixelflut.py 600 0.5 1 8 | pv | nc 151.217.25.113 1234
# the code is rather dirty but hey it works and it looks pretty amazing
import math
import itertools
import argparse
cli = argparse.ArgumentParser()
cli.add_argument('ypos', type=float)
cli.add_argument('freq', type=float)
cli.add_argument('amp', type=float)
@mic-e
mic-e / floppyrescue.py
Created October 17, 2015 14:07
floppyrescue.py: ddrescues, re-formats and tests old floppy disks
#!/usr/bin/env python3
import os
import subprocess
import time
def main():
while True:
subprocess.call(['beep'])
try:
@mic-e
mic-e / gist:2b2681b7dca31488aec1
Created April 13, 2015 11:12
Python GTK file chooser
#!/usr/bin/env python3
from gi.repository import Gtk
class FileChooserError(Exception):
pass
class FileChooser(Gtk.FileChooserDialog):