Skip to content

Instantly share code, notes, and snippets.

View henkin's full-sized avatar

Paul Henkin henkin

View GitHub Profile
@henkin
henkin / match-words.sh
Created August 15, 2020 07:50
match words in a list print
awk 'NR==FNR {a[$1]++; next} $1 in a' words myfile
grep -Fw -f words myfile
#* This would extract the lines in myfile that contains the words in the file words anywhere.
#The strings in words are treated as fixed strings (not regular expressions) due to the -F option, and the -w option ensures that we only get lines that contains the exact same word (no matches of substrings in words are allowed).
#The words in the file words most be listed on separate lines.
@henkin
henkin / docker-run.sh
Last active October 16, 2020 20:10
docker single script in ubuntu
#!/usr/bin/env bash
set -x
chmod +x "$1"
docker build -t $1 -f- . <<EOF
FROM osexp2000/ubuntu-with-utils
COPY $1 ./
USER root
ENTRYPOINT [ "bash", "$1" ]
EOF
@henkin
henkin / DebugEnvironmentTest.cs
Created May 19, 2021 18:43
xunit test dump sorted environment dotnet
using System;
using System.Linq;
using Xunit;
using Xunit.Abstractions;
namespace Jail.Booking.ComponentTests
{
public class DebugTests
{
private readonly ITestOutputHelper _outputHelper;
@henkin
henkin / addf.sh
Created July 12, 2022 22:39
addf - add function
:${1?addf name 'body'}
func_filename="$FUNCS/$1"
func_body=$2
if [[ -f $func_filename ]];
then
echo "Existing found:"
highlight $func_filename --syntax bash
read -q "REPLY?Overwrite existing function?"
fi
@henkin
henkin / delete_aws_repo.sh
Created November 11, 2022 17:43
aws delete repo
aws ecr --region=us-west-2 describe-repositories | jq -r '.repositories[] | .repositoryName' | grep paul | xargs -L1 aws ecr --region=us-west-2 delete-repository --repository-name
@henkin
henkin / pto.accept.sh
Created November 17, 2022 20:14
pto acceptance containers
docker build -t ptoaccept --platform amd64 -f Dockerfile ../../../..
docker run --rm --platform linux/amd64 -v $(pwd)/TestResults:/app/TestResults ptoaccept
@henkin
henkin / import.sh
Last active December 1, 2022 00:20
terraform
tf workspace select test
tf import module.waf.aws_wafv2_ip_set.main_waf_ip_blacklist cf1527f5-b1f9-48d0-b30a-9708de235b0b/pto-waf-ip-blacklist/REGIONAL
tf import module.waf.aws_wafv2_web_acl.main_waf_acl ac78a099-ae47-42d8-a2d6-3c32932470fe/pto-test-main-waf/REGIONAL
tf workspace select stage
tf import module.waf.aws_wafv2_web_acl.main_waf_acl fdddc840-67ef-4836-a59c-e7b319d9e673/pto-stage-main-waf/REGIONAL
@henkin
henkin / adduser.sh
Last active December 31, 2022 00:35
ddwrt
user=user
password=`openssl passwd -1 -salt xyz your-password-here`
cp /etc/passwd /tmp/passwd.bak
echo "${user}:${password}:1000:1000:User,,,:/tmp/${user}:/bin/sh" >> /etc/passwd
mkdir /tmp/${user}
chmod 1000:1000 /tmp/user
@henkin
henkin / curl-cut-tail.sh
Last active January 22, 2023 00:28
linux
# list of all domains
doctl compute domain list | cut -w -f1 | tail -n +2 | xargs curl -v -m 1
# show all NS record ids
doctl compute domain records list paulhenkin.com | grep NS | cut -w -f1
@henkin
henkin / bunyan-seq.sh
Last active October 4, 2023 17:26
seq
#!/bin/bash
# assumes bunyan-seq is installed globally - "npm install -g bunyan-seq"
# run with: npm run dev | ./bunyan-seq.sh
# SEQ_TOKEN comes from either $1, SEQ_TOKEN environment variable, or contents of ~/.seq_token
# This script assumes you've previously created a SEQ_TOKEN (reseq.sh - https://gist.githubusercontent.com/henkin/4b965bb0e71223a5d9436507dd717ec0/raw/636ac6f219010042ae0cbf233ffe1fe19c9a052a/reseq.sh)
export SEQ_TOKEN=${1:-${SEQ_TOKEN:-$(cat ~/.seq_token)}}
echo "token: $SEQ_TOKEN"
bunyan-seq --serverUrl http://localhost:5341 --apiKey $SEQ_TOKEN --logOtherAs Debug