Skip to content

Instantly share code, notes, and snippets.

@jayers99
jayers99 / workbashrc.sh
Created April 17, 2019 21:48
work bashrc
# .bashrc
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
@jayers99
jayers99 / getpasswd.sh
Last active April 7, 2019 22:59
encrypt linux passwd
# this only work on a centos box
python -c "import crypt; print crypt.crypt('password')"
python -c 'import crypt,getpass; print(crypt.crypt(getpass.getpass()))'
@jayers99
jayers99 / jayers.itermcolors
Created April 2, 2019 23:52
iterm2 color theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.0</real>
@jayers99
jayers99 / stats.sh
Created April 2, 2019 16:33
return sorted frequency list
sort | uniq -c | sort -rn | head -n 25
@jayers99
jayers99 / dirsname.sh
Created April 2, 2019 16:31
take a pipe list of file paths and return the directory
#!/bin/bash
# print just directory name from piped input of file paths
while read line
do
dirname "$line"
done < "${1:-/dev/stdin}"
@jayers99
jayers99 / repodir.sh
Created April 2, 2019 16:29
return the root directory of the current git repo
#!/bin/bash
git rev-parse --show-toplevel 2> /dev/null
if [[ $? == 128 ]]; then
echo $PWD
fi
@jayers99
jayers99 / rgrep.sh
Created April 2, 2019 16:13
repo grep search code
#!/bin/bash
#
# search repo files for some string
#
# defaults
# current repo root directory
# if not repo then current dir
# all file types not in exclude list
# irnP options
# options
@jayers99
jayers99 / iprangeFun.sh
Created April 1, 2019 23:27
aws ip ranges fun
curl https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.region=="us-west-2") | select(.service=="S3") | .ip_prefix' ip-ranges.json
@jayers99
jayers99 / getAllGists.sh
Created April 1, 2019 03:53
download all the github gists from a user
curl https://api.github.com/users/jayers99/gists?page=1 | jq -r '.[].files[].raw_url' > mygisturls.txt
curl https://api.github.com/users/jayers99/gists?page=2 | jq -r '.[].files[].raw_url' >> mygisturls.txt
while read i; do curl -O $i; done < mygisturls.txt
@jayers99
jayers99 / userMgtFun.sh
Created March 29, 2019 17:14
linux user management add and make wheel
sudo adduser <username>
sudo su <username>
mkdir .ssh
chmod 700 .ssh
vim .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
exit