Skip to content

Instantly share code, notes, and snippets.

View imaami's full-sized avatar
🐺
C/C++/Linux ░▒▓▉▊▋▌▍▎▏

Juuso Alasuutari imaami

🐺
C/C++/Linux ░▒▓▉▊▋▌▍▎▏
  • Finland
View GitHub Profile
#!/bin/bash
#
# Save this script as $HOME/.local/lib/git/find (make sure it's
# executable), then add a git alias:
#
# $ git config --global alias.find '!$HOME/.local/lib/git/find'
#
T="$(git rev-parse --show-toplevel)"
[[ -z "$T" ]] || T="$T/"
@imaami
imaami / 99-usb-serial-screen.rules
Created November 5, 2019 11:40
Automatically launch urxvt serial consoles
#
# /etc/udev/rules.d/99-usb-serial-screen.rules
#
ACTION!="add", GOTO="usb_serial_screen_end"
KERNEL!="ttyUSB[0-9]*", GOTO="usb_serial_screen_end"
SUBSYSTEM!="tty", GOTO="usb_serial_screen_end"
# List of USB serial devices for which to launch a terminal
ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GOTO="usb_serial_screen_run"
@imaami
imaami / video_frame_times.sh
Created December 30, 2019 17:16
Get frame indices + timestamps from video file.
#!/bin/bash
#
# Extract list of zero-based frame indices with timestamps.
#
ffprobe -v error -show_entries frame=pkt_pts_time \
-select_streams v -of csv=p=0 "$1" | grep -n '^' \
| while read L; do
i="${L%%:*}"
echo "$((i-1)):${L#*:}"
@imaami
imaami / temperature_data.sh
Created February 2, 2020 13:53
Quick & dirty script that prints thermals from /sys
#!/bin/bash
for f in $(find /sys/ | grep -E '/temp[0-9]+_input'); do
t="${f%_input}_type"
l="${f%_input}_label"
if [[ -e $t ]]; then
t=$(<$t)
else
t=' '
fi
@imaami
imaami / git_log_format_patch.sh
Created February 5, 2020 11:40
`git format-patch` output from `git log --pretty=format:...`
#!/bin/bash
#
# Doesn't print the content of the actual diff yet.
# Probably fails to produce identical output in some
# cases.
#
git log --pretty='format:From %H%nFrom: %an <%ae>%nDate: %aD%nSubject: [PATCH] %s%n%n%b%n' "$@"
@imaami
imaami / foldingathome-webui
Created March 17, 2020 12:46
Launch a fresh Folding@home web control UI
#!/bin/sh
#
# The Folding@home Web Control UI seems to bug out
# frequently (at least on Chrome). It'll go into a
# page refresh loop from which it will not recover
# until the browser cache is cleared manually.
#
# This script launches a fresh Chrome window using
# app mode and incognito to eliminate any leftover
# cached data. If the UI bugs out, just ctrl-w the
@imaami
imaami / do-cpupower.sh
Created April 2, 2020 12:46
cpupower frequency monitoring
#!/bin/bash
clear
while z="$(cpupower monitor -i .3333 -m Mperf)"; do
echo $'\e'"[0;0H$z"
done
@imaami
imaami / trick_tty.c
Created July 5, 2020 11:59
Trick programs into thinking they're piping to an interactive terminal
/**
* Overrides the glibc function. Will always return true.
*
* Note: Although this should be ok for most applications it can
* lead to unwanted side effects. It depends on the question
* why the programm calls isatty()
*
* Compiling
*
* $ gcc -s -fpic -shared -o libtricktty.so trick_tty.c
@imaami
imaami / headless_install_cmake_in_wine.md
Last active August 31, 2021 09:46
Installing CMake for Windows in Wine without a GUI

Installing CMake for Windows in Wine without a GUI

Steps

  1. Set and export shell variables

    These variables are for our convenience:

MYPREFIX=cmaketest

@imaami
imaami / headless_install_cuda_in_wine.md
Created July 13, 2020 23:51
Installing CUDA Toolkit 10.2 in Wine without a GUI

Installing CUDA Toolkit 10.2 in Wine

Steps

  1. Set and export shell variables

    Use a helper variable for the prefix name:

MYPREFIX=cudatest