-
Notifications
You must be signed in to change notification settings - Fork 2
/
.functions
134 lines (110 loc) · 3.36 KB
/
.functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/sh
function cleanmeta() {
xattr -c * && exiftool -all= * && rm *_original
}
function cleanpip() {
pip freeze | xargs pip uninstall -y
}
function http2ssh() {
REPO_URL=`git remote -v | awk '{print $2; exit}'`;
GIT_USER=${REPO_URL#*com/}; GIT_USER=${GIT_USER%%/*}
GIT_REPO=${REPO_URL#*${GIT_USER}/}; GIT_REPO=${GIT_REPO%%.git*}
if [ -z "$REPO_URL" ]; then
echo "-- ERROR: Could not identify Repo url."
echo " It is possible this repo is already using SSH instead of HTTPS."
return 1
fi
if [ -z "$GIT_USER" ]; then
echo "-- ERROR: Could not identify User."
return 1
fi
if [ -z "$GIT_REPO" ]; then
echo "-- ERROR: Could not identify Repo."
return 1
fi
NEW_URL="[email protected]:$GIT_USER/$GIT_REPO.git"
echo "Changing repo url from"
echo " '$REPO_URL'"
echo " to "
echo " '$NEW_URL'"
echo ""
git remote set-url origin `echo $NEW_URL`
echo "Success"
}
function kali() {
docker run --rm -v "$PWD:/pwd" --privileged -it d33pi0/kali:nightly
}
function killdocker() {
echo 'This is the Docker Master Obliterator ;)'
{
docker stop --time 1 $(docker ps -aq)
docker rm --force $(docker ps -aq)
docker rmi --force $(docker image ls -q)
docker volume rm --force $(docker volume ls -q)
docker network rm $(docker network ls -q)
} &> /dev/null
echo 'Done.'
}
function pidof() {
ps -A | grep -i "$@" | awk '{print $1}'
}
function runpy() {
# Phasing out run in favor of entr.
# EG:
# ls *.go | entr sh -c "go build; ./nanny"
ag -g py$ | entr -c python "$@"
}
function rungo() {
ag -g go$ | entr -c go run "$@"
}
function startdt() {
bash --login '/Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/start.sh'
}
function pomodoro() {
# meh, better than googling/installing a some free app from some random place.
while true; do say "Beep Boop, start working"; sleep 1500; say "Boop, Take a break"; sleep 300; done
}
function createpy() {
poetry new "$@"
cd "$@"
python3 -m venv env
source env/bin/activate
# Remove the email address from the toml file.
gsed -Ei "s/( <[a-zA-Z0-9.@_\-]+>)//" ./pyproject.toml
pip install poetry
poetry add --dev sphinx
poetry add --dev git+https://github.com/crossnox/m2r@dev
poetry add --dev coverage
mkdir docs/
cd docs/
sphinx-quickstart \
--no-sep \
-p "$@" \
-a deepio \
-r 0.0.1 \
-l en
# # Remove the old extensions... ?
# gsed -i "s/extensions\ \=\ \[//" ./conf.py
# gsed -Ei "s/^]$//" ./conf.py
# Using this method because it's more transparent, allowing others to read what's going on.
echo "" >> ./conf.py
echo "" >> ./conf.py
echo "" >> ./conf.py
echo "# -- Custom Options -------------------------------------------------" >> ./conf.py
echo "" >> ./conf.py
echo "import os" >> ./conf.py
echo "import subprocess" >> ./conf.py
echo "if os.environ.get('READTHEDOCS') == 'True':" >> ./conf.py
echo " subprocess.check_output(['pip', 'install', 'm2r'])" >> ./conf.py
echo "" >> ./conf.py
echo "extensions = extensions + ['m2r', 'sphinx.ext.autodoc']" >> ./conf.py
echo "autosectionlabel_prefix_document = True" >> ./conf.py
echo "source_suffix = ['.md', '.rst']" >> ./conf.py
mv index.rst index.md
# RESET if you need it
# rm -rf _* conf.py index.rst index.md make.bat Makefile
cd ..
mv README.rst README.md
# Travel back.
cd ..
}