Skip to content

Instantly share code, notes, and snippets.

@tjt263
tjt263 / permute.py
Created March 27, 2019 08:40
permutations of a set
#!/usr/bin/env python3
import string
import time
print('\033c')
x = string.ascii_uppercase
for a in x:
#!/usr/bin/env python3
def plusone(x):
y = x + 1
return(y)
print(plusone(1))
@tjt263
tjt263 / gitquick.sh
Created April 14, 2018 14:19
Notes on how to quickly contribute to a GitHub repo.
#fork "$repo";
git clone "https://github.com/$user/$fork.git";
cd "$fork";
#edit "$file";
git add "$file";
git status;
git commit -m "$message";
git push origin master;
#pull "$fork" into "$repo"
@tjt263
tjt263 / fixbrewpy.sh
Last active April 12, 2018 12:28
Fix your messed up homebrew python installs (macOS). For recent version & symlink conflicts.
#!/usr/bin/env bash
brew uninstall --force --ignore-dependencies python python2 python2.7 python3 python3.6 > /dev/null 2>&1;
brew install python@2 python@3 > /dev/null 2>&1;
echo;
for x in python python2 python3;
do
which $x;
readlink $(which $x);
$x --version;
echo;
#!/usr/bin/env bash
if showall=$(defaults read com.apple.finder AppleShowAllFiles) && [[ $showall = TRUE ]];
then defaults write com.apple.finder AppleShowAllFiles FALSE;
else defaults write com.apple.finder AppleShowAllFiles TRUE;
fi
killall Finder
####
#!/usr/bin/env bash
switch="$(defaults read com.apple.finder AppleShowAllFiles)"
if [[ "${switch}" = "TRUE" ]]; then
defaults write com.apple.finder AppleShowAllFiles FALSE
elif [[ "${switch}" = "FALSE" ]]; then
defaults write com.apple.finder AppleShowAllFiles TRUE
fi
#!/usr/bin/env bash
switch ()
{
defaults read com.apple.finder AppleShowAllFiles
}
switch="$(switch)"
if [[ "${switch}" = "TRUE" ]]; then
#!/usr/bin/env bash
switch ()
{
defaults read com.apple.finder AppleShowAllFiles
}
switch="$(switch)"
if [[ "${switch}" = "TRUE" ]]; then
@tjt263
tjt263 / getopts.sh
Created January 12, 2018 23:26
getopts demo
#!/usr/bin/env bash
while getopts abc opt
do
case $opt in
a) ...;;
b) ...;;
c) ...;;
esac
done
1.3 - The Bash Environment
The GNU Bourne-Again SHell (Bash)4 provides a powerful environment to work in,
and a scripting engine that we can make use of to automate procedures using existing
Linux tools. Being able to quickly whip up a Bash script to automate a given task is an
essential requirement for any security professional. In this module, we will gently
introduce you to Bash scripting with a theoretical scenario.
1.4 - Intro to Bash Scripting
1.4.1 - Practical Bash Usage – Example 1