Skip to content

Instantly share code, notes, and snippets.

View textarcana's full-sized avatar

Noah Sussman textarcana

View GitHub Profile
@textarcana
textarcana / git_history_pop.sh
Created November 21, 2024 17:29
In git, put the repo into the state it was at commit X, without changing history. Like git stash pop but for git history.
git checkout <hash> -- .
@textarcana
textarcana / smiley_prompt.sh
Last active November 14, 2024 17:48
bash smiley face that changes based on exit status. Based on some stack exchange posts I read a long time ago.
# Smiley face prompt if the last command would have been a
# passing Jenkins build step.
#
# Add this to your shell config file.
#
# A smiley face if the exit status of the last command was 0.
#
# Otherwise a frowny face.
RESET="\[\017\]"
@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 @ \