Last active
June 21, 2024 19:11
-
-
Save hexfusion/8260318 to your computer and use it in GitHub Desktop.
This file contains 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
# podman hammer | |
ps aux | grep podman | grep -v grep | awk '{print $2}' | xargs -r sudo kill -9 | |
# zombie killer | |
kill -9 $(ps -A -ostat,ppid | awk '/[zZ]/ && !a[$2]++ {print $2}') | |
# benchmark with perf | |
go test -benchmem -run=^$ -bench ^BenchmarkGetValidatorSet$ github.com/ava-labs/avalanchego/snow/validators/gvalidators -memprofile benchvset.mem -cpuprofile benchvset.cpu | |
go test -run=X -bench=. -count=10 -benchmem | tee /tmp/zeropool.bench && benchstat -col .name /tmp/zeropool.bench | |
git tag tag_name | |
git push upstream tag_name | |
git push --delete origin tag_name | |
# Review installed golang packages | |
go version -m | |
# kill defunt | |
ps -ef | grep defunct | |
kill -9 1234 3444 | |
# gen go mod sha | |
TZ=UTC git --no-pager show \ | |
--quiet \ | |
--abbrev=12 \ | |
--date='format-local:%Y%m%d%H%M%S' \ | |
--format="%cd-%h" | |
#ubuntu slow wifi | |
/etc/NetworkManager/conf.d/default-wifi-powersave-on.conf change to 2 | |
# repair gz | |
for i in ./*.gz ; do gunzip -c "$i" | head -8000 | gzip > "$i.tmp"; mv -f "$i.tmp" $(basename "$i") ; done | |
# shell expansion | |
https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion | |
# kill process by port | |
fuser -k 2380/tcp | |
# sed delete match line and line after | |
sed '/192.0.2.1/I,+1 d' test.file | |
# pretty print with struct fields. | |
fmt.Fprintf(os.Stderr, "object: %# v\n", pretty.Formatter(hb)) | |
# go to line column vim | |
:call cursor(15,25) | |
# copy bucket | |
gsutil cp gs://etcd/v3.4.0-rc.0/*.asc . | |
# etcd selinux perms | |
gsutil -m acl ch -u allUsers:R -r gs://etcd/ | |
openssl x509 -in client.pem -text -noout | |
openssl x509 -in client.pem -noout -subject -issuer | |
oc get secrets -n openshift-etcd etcd-peer-ip-10-0-137-127.us-west-1.compute.internal -o jsonpath={.data.tls\\.crt} | base64 -d | openssl x509 -text -noout | |
# check for OOM | |
dmesg | egrep -i 'killed process' | |
# i3 rename workspace. | |
i3-msg 'rename workspace to "totally"' | |
### regex | |
# extract json keys | |
%s/\"\(\w\+\)\".*/\1 | |
## Docker add rule to block traffic between nodes | |
iptables -I DOCKER -s 172.16.22.41 -d 172.16.22.45 -j DROP | |
# Flush by chain name. | |
iptables -F DOCKER | |
# list traffic by rule | |
iptables -v -L | |
### emulate dropped packets | |
$ iptables -A INPUT -m statistic --mode random --probability 0.1 -j DROP | |
$ iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j DROP | |
### restic | |
# restore specific asset from backup | |
$ restic restore 18650d8c --target /tmp/grpc-go/ --include /samb/documents/development/dev_modules/go/grpc-go/ | |
## grep exclude | |
grep -r --exclude-dir={custom,lib,scripts} --exclude={*.xml,error_log} "sumting" . | |
# interchange crypt | |
htpasswd -n -d samb | |
# clear fail2ban | |
iptables -L -n --line-numbers | |
iptables -D fail2ban-SSH 1 # line number in chain | |
# HTTPS onlytar -zcvf prog-1-jan-2005.tar.gz | |
Redirect permanent / https://www.site.com/ | |
# tar.gz | |
tar -zcvf prog-1-jan-2005.tar.gz /path | |
### storage review ### | |
ncdu | |
### Data::Dumper for go | |
import "github.com/davecgh/go-spew/spew" | |
str := spew.Sdump(myVar1, myVar2, ...) | |
return fmt.Errorf("oops: %s", str) | |
## go test | |
go test -v -cpu 1,4 -timeout 5m ./... | |
go test -v -cpu 1,4 -timeout 5m google.golang.org/grpc/... | |
# Interchange sessions | |
storable -s <path> | |
### AWS | |
ulist account number | |
### Pretty Print JSON | |
json_pp -json_opt pretty,utf8 <<< '' | sort | |
### go ### | |
# update binaries after upgrade. | |
go get github.com/rjeczalik/bin/cmd/gobin | |
gobin # lists Go binaries | |
gobin -u # updates them | |
### BIND ### | |
rndc reload example.com | |
### AWS ### | |
aws cp --recursice s3://bucketnamesource s3://bucketnamedestination | |
aws ec2 terminate-instances --instance-ids i-0af6baaf90dc769f4 | |
curl http://169.254.169.254/latest/meta-data/public-ipv4 | |
# spellcheck recursive | |
find ./ -iregex '.*\.md' -exec aspell -d, --master=english --mode=sgml -c '{}' \; | |
#letsenctryt on ec2 | |
yum -y install yum-utils | |
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional | |
### TLS ### | |
# print all ciphers | |
nmap --script ssl-enum-ciphers domain.com -p 443 | |
### JWT ### | |
ssh-keygen -t rsa -b 4096 -f jwtRS256.key | |
# Don't add passphrase | |
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub | |
# search and replace area tag | |
%s/\(\[area href=\)\(.*\)\(\]\)/\/manager\/\2\.html/g | |
# unsuitable terminal: rxvt-unicode-256color". | |
ssh remotemachine mkdir -p .terminfo/r | |
cp /usr/share/terminfo/r/rxvt-unicode* remotemachine:.terminfo/r/ | |
or export TERM=xterm | |
# debug REST API!!! | |
https://requestb.in | |
# install list of packages from list | |
yum -y install $(cat filename.txt) | |
# list inodes | |
df -iT | |
# time queries | |
SET STATISTICS TIME ON | |
GO | |
SELECT * FROM MyTable | |
GO | |
SET STATISTICS TIME OFF | |
GO | |
### PFX | |
openssl pkcs12 -export -out star.corp.aws.org.pfx -inkey star.corp.aws.org.key -in star.corp.aws.org.crt -certfile chain.cer | |
#list row | |
select * from foo where bar = 5234512\G | |
#test all | |
RELEASE_TESTING=1 make test | |
# find perl modules | |
grep -rhP '(?!use strict;$)(?!use warnings;$)^use.*(::)?.*;$' catalogs/app/i/ > out | |
# count ips in logs | |
awk -F'[ "]+' '$7 == "/" { ipcount[$1]++ } END { for (i in ipcount) { printf "%15s - %d\n", i, ipcount[i] } }' logfile.log | |
# list by response codes | |
awk '{print $9}' access_log | sort | uniq -c | sort -rn | |
# compressed pipe | |
zcat logs/champ/access_log-20171106.gz | awk '($9 ~ /500/)' | awk '{print $7}' | sort | uniq -c | sort -rn | |
# log parsing | |
https://easyengine.io/tutorials/nginx/log-parsing/ | |
# list all packages in a nice resable way | |
yum list installed | awk '{print $1}' | cut -d'.' -f-1 | |
# update all versions at once for a moudle | |
ppi_version show | |
# show all whitespace | |
/\s\+$ | |
# not enough spaces | |
:/^ \s\+ | |
# kill zsh | |
exec bash | |
# check for large deleted files | |
lsof +L1 | |
# create random password | |
date +%s | sha256sum | base64 | head -c 12 ; echo | |
#create pod | |
pod2text myperl.pl > README | |
pod2markdown lib/Etcd3.pm > README.md | |
# highlight code for blogs | |
http://hilite.me/ | |
# tmux stuck? | |
You might have hit Ctrl+S ? | |
It is reenabled by pressing Ctrl+Q. | |
# gpg encrypt | |
gpg -e -r samb secret.txt | |
# gpg secrets | |
../../scripts/secrets_re-encrypt.sh -t something-secrets.txt | |
# sed replace | |
lead='^<!-- Start of Google Analytics -->$' | |
tail='^<!-- End of Google Analytics -->$' | |
find . -type f -exec sed -i "/$lead/,/$tail/{ /$lead/{p; r /home/samb/google.txt | |
}; /$tail/p; d }" {} \; | |
find catalogs/ -type f | xargs sed -i 's/http:\/\/store/https:\/\/store/g' | |
# until | |
while true; do foo; sleep 2; done | |
#debug perl modules | |
print STDERR Dumper($foo) | |
# reset htaccess -c = create | |
htpasswd -s /$path/firewall.users $username | |
# create sha1 password | |
echo -n "testing" | openssl dgst -sha1 | |
# selinux | |
- certs: chcon -u system_u -r object_r -t cert_t | |
# yum undo something. | |
yum history undo ID | |
# check mail que | |
mailq | |
# flush que | |
postfix flush | |
#print line in IC5 | |
Debug('here at %s', __LINE__); | |
# dont run conversion | |
LC_ALL=C vim charset-conversion-input.txt | |
# quick keygen | |
ssh-keygen -t rsa -b 4096 -C "[email protected]" | |
# put untracked files into gitignore | |
git ls-files --others --exclude-standard >> .gitignore | |
# fix git perms | |
chgrp -R camp . | |
chmod -R g+rwX . | |
find . -type d -exec chmod g+s '{}' + | |
# validate perl syntax | |
!perl -wc % | |
# set vim to use normal tabs | |
:set noexpandtab | |
:set ts=4 | |
:set noet | |
:%retab! | |
# rsync timestamps only for exisating files in destination | |
rsync -vrt --size-only --existing | |
# export only changed files between 2 commits | |
tar -zcf update.tar.gz git diff --name-only SHA1..SHA2 | |
# show commit by commit message | |
git log -1 -p -m ":/$COMMIT_MESSAGE" | |
# list commits between branches | |
git log --pretty=oneline 'upstream/release-4.4'..'upstream/master' | |
# git refresh commit | |
git commit --amend --no-edit | |
# git revert multiple commits | |
git revert -n <commits> | |
git commit | |
# git search all branches | |
git log -p --all -S 'string' | |
# git bare repo | |
git init --bare test_repo.git | |
# git find tags where commit exists | |
git tag --contains fa61bf86d7709fdddc | |
# git check IC release version against current | |
git diff HEAD:interchange/lib/Vend/Config.pm REL_5_10_0:lib/Vend/Config.pm | |
# avoid ESC in git status etc | |
git config --global core.pager more | |
git config --global user.name "Sam Batschelet" | |
git config --global user.email "[email protected]" | |
# grep all ever | |
git rev-list --all | xargs git grep checkopts | |
# reset your current unpished commit and keep work | |
git reset HEAD~1 --soft | |
# reset file to previous version. | |
git reset <commit hash> <filename> | |
# merge master into PR/branch | |
git rebase upstream/master | |
# keep branch up to date with master | |
git rebase master | |
# Create the branch on your local machine : | |
$ git checkout -b <name_of_your_new_branch> | |
# Push the branch on github : | |
$ git push origin <name_of_your_new_branch> | |
# Delete a branch on your local filesystem : | |
$ git branch -d [name_of_your_new_branch] | |
# To force the deletion of local branch on your filesystem : | |
$ git branch -D [name_of_your_new_branch] | |
# Delete the branch on github : | |
$ git push origin :[name_of_your_new_branch] | |
# Merge master into a dev branch | |
git fetch origin master && git rebase master | |
# Fetch tags from git upstream and push | |
[remote "upstream"] | |
url = <redacted> | |
fetch = +refs/heads/*:refs/remotes/upstream/* | |
fetch = +refs/tags/*:refs/tags/* | |
git push --tags | |
# cherry pick only what you want | |
git cherry-pick -c | |
# write yaml | |
perl -e 'use YAML;print Dump({headers => { source => "Item Cat", map => "navigation" }})' | |
# setup exim | |
http://mindref.blogspot.com/2011/02/exim4-smarthost-no-local-mail.html | |
# git-svn commit | |
git svn dcommit | |
# install git submodule | |
git submodule update --init | |
# ssh tunnel reflect localhost on domain.com back to localhost on computer #mysql | |
ssh -N [email protected] -L 3307/127.0.0.1/3306 | |
# ssh tunnel pfsense login | |
ssh -N [email protected] -L 1024/xxx.xxx.xxx.2/443 | |
# weechat show away users | |
/set irc.server_default.away_check 5 | |
# kill process by name | |
pkill -f starman | |
#setup solr | |
http://yonik.com/solr-tutorial/ | |
# dump IC situation. | |
<xmp> │············· | |
[area foo] │············· | |
[area href=foo secure=1] │············· | |
│············· | |
server name: __SERVER_NAME__ │············· | |
vend url param: __VEND_URL__ │············· | |
secure url param: __SECURE_URL__ │············· | |
│············· | |
[calc] return 'vend url config: ' . $Config->{VendURL}; [/calc] │············· | |
[calc] return 'secure url config: ' . $Config->{SecureURL}; [/calc] │············· | |
│············· | |
[dump] │············· | |
</xmp> | |
# use mutt to send attahment. | |
echo “see attached“ | mutt -a "/foo/bar.pdf" -s "pdf form" -- [email protected] | |
# adjust brightness with xrandr | |
xrandr --output DP-3.2 --brightness 1.5 | |
# keyring | |
ssh-add ~/.ssh/id_dsa | |
# cron best practices | |
https://sanctum.geek.nz/arabesque/cron-best-practices/ | |
# check for credit card and omit keywords | |
egrep -Ev "^.*(keyword1|keyword2|keyword3).*\b[3456][0-9]{3}[-\[:space:]\[:digit:]][0-9]{3,4}[-\[:space:]\[:digit:]][0-9]{3,4}[-\[:space:]\[:digit:]][0-9]{1,4}" test.txt | |
# reset mysql root password in camps | |
nohup mysqld_safe --defaults-file=/home/samb/camp12/my.cnf > /home/samb/camp12/mysql/tmp/nohup.out 2>&1 & | |
- add skip-grant-tables to my.cnf | |
mysql> use mysql; | |
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root'; | |
mysql> flush privileges; | |
mysql> quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment