Skip to content

Instantly share code, notes, and snippets.

@ephemient
ephemient / cmdsdaskpass.c
Created October 16, 2015 01:49
libcmdsdaskpass.so
#/* \
make -C "$(dirname "$0")" -f "$0" "$@"; exit $?
libcmdsdaskpass.so: LDFLAGS += -shared
libcmdsdaskpass.so: LDLIBS += -ldl
libcmdsdaskpass.so: cmdsdaskpass.o
$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@
cmdsdaskpass.o: CFLAGS += -fPIC
cmdsdaskpass.o: cmdsdaskpass.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@ $^
help:
@ephemient
ephemient / crc32.c
Last active July 7, 2020 13:44
crc32
#/* \
make -C "$(dirname "$0")" -f "$0" "$@"; exit $?
crc32: LDLIBS += -lz
crc32: crc32.o
$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@
crc32.o: crc32.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@ $^
help:
$(info )
$(info http://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-generate-a-crc32-checksum-163908/#post4670222)
@ephemient
ephemient / wait-dbus-service
Created October 16, 2015 01:58
wait-dbus-service
#!/bin/bash
set -e
eval "$(git rev-parse --parseopt -- "$@" <<EOF || echo exit $?
${0##*/} [OPTIONS...] {SERVICE} [TIMEOUT]
Wait for {SERVICE} to be registered on the bus.
--
y,system Connect to system bus
e,session Connect to user bus
@ephemient
ephemient / shortcat
Created October 16, 2015 02:14
shortcat
#!/usr/bin/perl
use 5.014;
our $VERSION = 0.001;
use strict;
use warnings;
use autodie;
use Carp qw(carp croak);
use File::Basename qw(dirname);
@ephemient
ephemient / cpblk
Created October 16, 2015 02:22
cpblk
#!/usr/bin/perl
use strict;
use Digest::MD5 qw(md5);
use Fcntl qw(:DEFAULT :seek);
use Getopt::Long qw(:config gnu_getopt);
my $bs = 4096;
my $skip = 0;
@ephemient
ephemient / paswitch
Created October 16, 2015 02:23
paswitch
#!/bin/bash
set -e
IFS=$'\t'
list_devices() {
local line default_sink_name default_source_name
local sink source name driver format state
while read -r line; do
case ${line} in
@ephemient
ephemient / swfuncompress
Created October 16, 2015 02:41
swfuncompress
#!/usr/bin/perl
use Compress::Zlib;
undef $/;
binmode(ARGV);
while (<>) {
my ($a, $b, $c) = unpack 'a3a5a*' => $_;
if ($a eq 'CWS') {
open FH, '>:raw', "${ARGV}.raw";
syswrite FH, "FWS$b";
syswrite FH, uncompress($c);
@ephemient
ephemient / delay
Created October 16, 2015 02:48
delay
#!/bin/bash -e
WHEN=${1}
shift
if [[ -z ${WHEN} ]]; then
echo "Usage: ${0} <date/time format> [program]"
exit 1
fi
TARGET=$(date -d "${WHEN}" +%s)
echo "Terminating on $(date -d "@${TARGET}")"
while :; do
@ephemient
ephemient / run
Last active October 18, 2015 23:59
#!/bin/bash
exec /usr/bin/busctl --user call org.kde.klauncher5 /KLauncher org.kde.KLauncher exec_blind sas -- "$1" $(($#-1)) "${@:2}"
exit $?
#!/bin/bash -e
USAGE='git sgrep [<options>] [-e] <pattern> [<rev>...] [[--] <path>...]'
NONGIT_OK=1
SUBDIRECTORY_OK=1
. "$(git --exec-path)/git-sh-setup"
declare -a opts=() patterns=() revpaths=()
git config --get-colorbool diff && opts+=(--color=always) || opts+=(--color=never)
while (($#)); do
arg=$1; shift