Skip to content

Instantly share code, notes, and snippets.

View izabera's full-sized avatar

Isabella Bosia izabera

  • General System
  • Flitwick, UK
View GitHub Profile

A funky shell thingy that I've never seen before

So you're in posix sh and you want to do the equivalent of this in bash:

foo | tee >(bar) >(baz) >/dev/null

(Suppose that bar and baz don't produce output. Add redirections where needed if that's not the case.)

@izabera
izabera / automata.sed
Last active September 8, 2023 01:03
cellular automata in sed
#!/bin/sed -f
# store rule in hold space
1 { h; d; }
# make borders wrap
s/\(.\)\(.*\)\(.\)/>\3\1\2\3\1|/
# do some mucking around that can probably be done more elegantly by someone who is actually good at sed
x; G; h; s/\n.*//; x
@izabera
izabera / snoopfd
Last active August 25, 2022 12:00
Dump what an arbitrary linux process writes to some fd
#!/bin/sh -e
target=${1?usage: $0 pid [fd]}
fd=${2-1}
fifo=fifo.$$
log=log.$$
mkfifo $fifo
echo writing to $log
tee $log <$fifo >/proc/$target/fd/$fd &
#include <ctype.h>
#include <fcntl.h>
#include <linux/openat2.h>
#include <netinet/in.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char **func_that_returns_strings(int nstrings) {
// first dump all the strings into a contiguous buffer, separated by \0
char buf[100];
size_t size = 0;
for (int i = 0; i < nstrings; i++)
#!/usr/bin/env python
import fuse
import time
import sys
import errno
class fs(fuse.Operations):
def getattr(self, path, fh=None):
if "blockme" in path:
musl-gcc -shared -fPIC sys_errlist.c -o libsys_errlist.so
#!/bin/bash -e
rm -rf build
mkdir build
cd build
echo "int main() {" > f.c
limit=${1-500}
for (( i = 0; i < ${1-500}; i++ )) do
#!/bin/bash
shopt -s extglob
declare -A signal=(
[1]=sighup [2]=sigint [3]=sigquit [4]=sigill [5]=sigtrap
[6]=sigabrt [7]=sigbus [8]=sigfpe [9]=sigkill [10]=sigusr1
[11]=sigsegv [12]=sigusr2 [13]=sigpipe [14]=sigalrm [15]=sigterm
[16]=sigstkflt [17]=sigchld [18]=sigcont [19]=sigstop [20]=sigtstp
[21]=sigttin [22]=sigttou [23]=sigurg [24]=sigxcpu [25]=sigxfsz
[26]=sigvtalrm [27]=sigprof [28]=sigwinch [29]=sigio [30]=sigpwr
file /bin/true
b main
r