Skip to content

Instantly share code, notes, and snippets.

View pavel-kirienko's full-sized avatar
:shipit:

Pavel Kirienko pavel-kirienko

:shipit:
View GitHub Profile
@pavel-kirienko
pavel-kirienko / 51-xbox-gamepad.rules
Last active January 30, 2025 13:06 — forked from dnmodder/fixcontroller.py
Use Microsoft X-Box 360 Gamepad with GNU/Linux
# By default, X-Box 360-compatible controllers are detectable but dysfunctional because they expect the host
# to send a particular USB control transfer with some sort of initialization command.
# This udev rule will invoke a trivial Python script automatically when the gamepad is connected that emits
# the required initialization command.
#
# Integration:
# 1. Put this rule into /etc/udev/rules.d/51-xbox-gamepad.rules
# 2. Install pyusb for the root's Python: sudo pip install pyusb
# 3. Reload udev rules as root: udevadm control --reload-rules && udevadm trigger
#
@pavel-kirienko
pavel-kirienko / video-to-gif.sh
Created June 9, 2020 15:42
Convert video to gif
#!/bin/bash
# Convert all video files in the current directory into gifs.
# Silently overwrite existing files.
# This is useful for working with matplotlib animations.
for src in *.mp4
do
bn="${src%.*}"
echo "$src $bn"
ffmpeg -y -i "$src" "${bn}.gif" || exit 1
done
@pavel-kirienko
pavel-kirienko / arm-bin-to-elf.sh
Last active December 6, 2024 12:43
Converting flat binary into ARM ELF format, useful for firmware uploading via GDB
# The part .data=0x08000000 should be replaced with the correct base offset of the ROM.
# The value 0x08000000 is valid for STM32.
arm-none-eabi-objcopy -I binary -O elf32-little --change-section-address .data=0x08000000 input.bin output.elf
@pavel-kirienko
pavel-kirienko / rpm_snippet.py
Created November 6, 2017 20:53
A simple snippet for the UAVCAN GUI Tool (v0.9) that sweeps an ESC RPM setpoint from zero to maximum and then back
def run():
rpm_setpoint = 0
going_down = False
step = 2
def update():
nonlocal rpm_setpoint
nonlocal going_down
rpm_setpoint += (-step if going_down else step)
broadcast(uavcan.equipment.esc.RPMCommand(rpm=[rpm_setpoint]))
if going_down:
@pavel-kirienko
pavel-kirienko / index.sh
Last active April 6, 2021 02:32
Web interface for a backup storage server (CGI bash script, usable with any web server that supports CGI)
#!/bin/bash
#
# Backup server web interface (CGI script).
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: