-
Install packages that we need. For Ubuntu this includes:
apt-install git build-essential ncurses-dev xz-utils libssl-dev \ bc flex libelf-dev bison qemu-system-x86 gdb
-
Get the Linux source. (Or use your Linux distribution's package manager to fetch it.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ptrace_test: Set breakpoints and watchpoints on the child process using | |
* ptrace on x86-64 Linux | |
* | |
* Compile using: | |
* gcc -o ptrace_test ptrace_test.c -Wall -ggdb | |
* | |
* Ben Cohen, February 2025 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* sparsedump: Show offsets of holes and data in a possibly sparse file on Linux | |
* | |
* Compile using: | |
* gcc -o sparsedump sparsedump.c -ggdb -Wall | |
* | |
* Ben Cohen, February 2025. | |
*/ | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# | |
# Keep the X primary selection and the clipboard | |
# in sync. Polls regularly and, when one changes, | |
# it's copied to the other. | |
# | |
# To the extent possible under law, Alun Jones has waived all copyright and | |
# related or neighbouring rights to this work. This work is published from: | |
# United Kingdom. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# | |
# pipewinch: Forward a terminal with window size changes across a unix | |
# domain socket. | |
# | |
# Usage: | |
# pipewinch <uds-action> <uds-path> exec ARGS... | |
# pipewinch <uds-action> <uds-path> term | |
# where uds-action is "listen" or "connect" | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// window-size-changed.c: Demo program to handle window changed events | |
// | |
// Ben Cohen, July 2022. | |
// | |
#include <sys/ioctl.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <signal.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# | |
# idleterm.py: Open a pty so that a process from elsewhere - such as a gdb | |
# inferior - can attach to it and copy the IO between the pty and | |
# this process's stdin and stdout. | |
# | |
# This is a Python version of the idleterm program at | |
# https://stackoverflow.com/a/71314902/2319122 | |
# | |
# Ben Cohen, April 2022. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# tmux_pane_wait.sh: Launch an interactive process in a second tmux pane and | |
# wait for it to complete before continuing the script in the first pane. | |
# | |
# Ben Cohen, February 2022. | |
# | |
set -x | |
set -e | |
if [ -z "$TMUX" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# git_check_status.sh: check whether git is in a special state | |
# | |
# Ben Cohen, July 2021 | |
# | |
# This script returns failure if the current directory is a git worktree | |
# that is in a special state - merge, rebase, bisect or detached HEAD - or | |
# returns success if the worktree is in a normal state, or the current | |
# directory is not a git worktree. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: diffpdf.sh file_1.pdf file_2.pdf | |
# requirements: | |
# - ImageMagick | |
# - Poppler's pdftoppm and pdfinfo tools (works with 0.18.4 and 0.41.0, | |
# fails with 0.42.0) | |
# (could be replaced with Ghostscript if speed is | |
# not important - see commented commands below) |
NewerOlder