Skip to content

Instantly share code, notes, and snippets.

View textarcana's full-sized avatar

Noah Sussman textarcana

View GitHub Profile
@textarcana
textarcana / between_two_regex
Last active November 24, 2021 00:22
Between Two Regex: Find the text between two lines that match regexes.
#!/usr/bin/env perl
use strict;
use warnings;
use Carp;
use v5.10;
use constant FALSE => 1==0;
use constant TRUE => not FALSE;
# Given two regex that match a start and end line, return blocks of
# Silently shift the first line off input sent through a pipe.
all_but_first_line(){
# Read from a pipe
declare input=${1:-$(</dev/stdin)};
# Print all but the first line of input
tail -n +2 <<< "$input"
}
@textarcana
textarcana / spell_check.pl
Created March 18, 2021 14:43
Spell check a word on the command line.
#!/usr/bin/env perl -w
# Suggest alternate spellings for a word
use strict;
use Text::Aspell;
my $speller = Text::Aspell->new;
my $word = qq{$ARGV[0]};
@textarcana
textarcana / profanity_search.sh
Last active March 18, 2021 14:45
Profanity search command line tool.
#!/usr/bin/env bash
set -Eeuo pipefail
profane_regex=$(
perl -e '
use Bad::Words;
my $wordref = new Bad::Words;
my $updated = $wordref->remove(qw(
xxx
filesystem_paths=$(
find . \
-name "*.php" \
-not -name "*Test.php"
)
git log \
--since='3 weeks ago' \
--format='%ad' \
--date=iso-local \
filesystem_paths=$(find . -name "*Test.php")
git log \
--since='3 weeks ago' \
--format='%ad' \
--date=iso-local \
$filesystem_paths \
| cut -d ' ' -f1 \
| sort \
| uniq -c
(
echo 'app/'
echo 'test/'
) \
| xargs -I@ bash -c "
echo @
git log \
--since='3 weeks ago' \
--format='%ad' \
--date=iso-local @ \
TZ=$(date +%z) git log --reverse --date-order --format="%cd" --date=iso-local \
| dateround -S Sun \
| cut -d'T' -f1 \
| uniq -c \
| column -t \
| perl -pwe 's{\s+}{\t}'
TZ=$(date +%z) git log --reverse --date-order --format="%cd" --date=iso-local \
| cut -d- -f1-2 \
| uniq -c \
| column -t \
| perl -pwe 's{\s+}{\t}'
repo_age=$(git log --date=relative --reverse --format="%ad" | head -n1)
commits_in_history=$(git log --pretty=oneline | wc -l)
echo "$commits_in_history commits since $repo_age"