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 | |
set -eu -o pipefail | |
# This script ensures source code files | |
# have copyright license headers. | |
# | |
# It modifies all source files in place | |
# and avoids adding a license header | |
# to any file that already has one. |
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
package seen | |
type Seen[T comparable] struct { | |
Map map[T]struct{} | |
} | |
func New[T comparable](size int) Seen[T] { | |
return Seen[T]{ | |
Map: make(map[T]struct{}, 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
import "math/rand/v2" | |
func randomBytes(dst []byte) { | |
const charset = "abcdefghijklmnopqrstuvwxyz" + | |
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\t\n " | |
for i := 0; i < len(dst); i++ { | |
dst[i] = charset[rand.IntN(len(charset))] | |
} | |
} |
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 | |
# like surfraw, but not a million fucking lines long. | |
# requires dmenu. | |
# the default search engine is shown at first. | |
# to select another search engine, press enter when | |
# the prompt is empty in dmenu. | |
# name of the default search engine | |
default='Searx' |
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 |
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
/* 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
#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
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
#!/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 ;; |