This file contains hidden or 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/sh | |
# detect and show IP Address, MAC Address and OS of local network computers. | |
# requires nmap and ip(iproute2). | |
gateway=$(ip route); gateway=${gateway#*via }; gateway=${gateway%% *} | |
localip=$(ip route get 1); localip=${localip#*src }; localip=${localip%% *} | |
scan=$(sudo nmap -sT -n -O --host-timeout 1m "${gateway:?}"/24) || exit 1 | |
printf '%s\n' "${scan:?}" | while IFS= read -r line; do case $line in 'Nmap scan report for '*) |
This file contains hidden or 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/sh | |
# burn a file or an iso to a dvd. | |
# requires the cdrtools package. | |
# usage: $ burn FILE [TITLE] | |
# config | |
speed=1 # leave blank for default speed | |
dev=/dev/sr0 | |
tmp=~/.cache/burn |
This file contains hidden or 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 | |
# winetricks, but for Bottles (https://github.com/bottlesdevs/Bottles). | |
# config | |
d=~/.local/share/bottles | |
set -e | |
cd ${d:?}/bottles | |
b=$(printf '%s\n' * | fzf) | |
r=$(grep '^Runner:' $b/bottle.yml | cut -d' ' -f2) |
This file contains hidden or 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/sh | |
# check #!/bin/sh-shebanged scripts in /usr/bin for | |
# dash-incompatible syntax using shellcheck. | |
# config | |
outdir=~/bashisms | |
searchdir=/usr/bin | |
mkdir -p "$outdir" || exit 1 |
This file contains hidden or 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/zsh | |
# a wrapper for rm to make it safer to use. | |
# it stops rm from recursively removing top-level directories. | |
unset recursive endopt | |
# check arguments | |
for arg; do case $arg in | |
--) break ;; |
This file contains hidden or 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
void | |
pushincol(const Arg *arg) | |
{ | |
Client *sel = selmon->sel, *c; | |
if (!sel || sel->isfloating) | |
return; | |
if (arg->i > 0) { | |
if ((c = nextofmodeloop(sel))) { |
This file contains hidden or 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
#include <stdio.h> | |
#include <glob.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#define LENGTH(X) (sizeof(X) / sizeof(X[0])) | |
void getproccwd(const unsigned int pid, char *cwd, const unsigned int size); | |
void getdesc(const unsigned int pid, int *desc, const unsigned int size); |
This file contains hidden or 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
/* source: https://legacy.imagemagick.org/discourse-server/viewtopic.php?p=80803#p80803 | |
* requires the "opencl-headers" package | |
* compile: | |
* cc ConvertExample.c -o convert $(pkg-config --libs --cflags MagickCore MagickWand) */ | |
/* | |
Bare minimal test of a direct call to ConvertImageCommand() | |
Actually this is basically what the "convert" command does. | |
Compile with... |
This file contains hidden or 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
/* source: https://stackoverflow.com/questions/29977651/how-can-the-pulseaudio-asynchronous-library-be-used-to-play-raw-pcm-data#29980624 | |
* pcm-playback: pcm-playback.c | |
* gcc -o pcm-playback pcm-playback.c `pkg-config --cflags --libs libpulse` */ | |
#include <stdio.h> | |
#include <assert.h> | |
#include <pulse/pulseaudio.h> | |
#define FORMAT PA_SAMPLE_U8 | |
#define RATE 44100 |
This file contains hidden or 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/sh -efu | |
# split the given video/audio files by chapters using ffmpeg. | |
for file; do | |
ffprobe -print_format csv -show_chapters -- "$file" | cut -d, -f5,7,8 | | |
while IFS=, read start end chapter; do | |
ffmpeg -hide_banner -nostdin -ss "$start" -to "$end" -i "$file" \ | |
-c copy -map 0 -map_chapters -1 -- "${file%.*}-$chapter.${file##*.}" | |
done | |
done |