Skip to content

Instantly share code, notes, and snippets.

@kremerben
Last active March 2, 2022 23:16
Show Gist options
  • Save kremerben/4401b95ff12ed44f9ed079c2065e8a5f to your computer and use it in GitHub Desktop.
Save kremerben/4401b95ff12ed44f9ed079c2065e8a5f to your computer and use it in GitHub Desktop.
current ~/.bash_aliases - August 28, 2017
alias leetcode='cd ~/Dropbox/\ LEETCODE/ && jupyter notebook'
alias lc='leetcode'
alias leet='leetcode'
alias goopencv='deactivate || : && cd ~/Dropbox/\ CLASSES/LearnOpenCV_2021/ && source .venv/bin/activate && jupyter notebook'
#Energy Solution specific aliases
alias activate='source .venv/bin/activate'
alias act='activate'
alias deact='deactivate'
# ADR PANDA
alias fixpanda='ssh panda.energy-solution.net "sudo systemctl restart panda_uwsgi" && echo "$(date +%FT%T%z) fixpanda" >> ~/zz_fixpanda_dates.txt'
alias pandafix='fixpanda'
alias gopanda='pycharm /Users/bkremer/projects/panda && deactivate || : && workon panda38 && cd panda/panda && echo ">>>>>> python manage.py runserver - or - python manage.py worker"'
alias goadr='gopanda'
# CALDGSTATS
alias gocal='pycharm /Users/bkremer/projects/caldgstats/ && deactivate || : && cd ~/projects/caldgstats && source .venv/bin/activate && echo ">>>>>> manage.py runserver and/or manage.py qcluster"'
alias gocaldgstats='gocal'
alias gocds='gocal'
# ER
alias goclassic='deactivate || : && cd ~/projects/er && workon er-classic'
alias goer='goclassic && django-admin.py runserver'
alias gocacr='goclassic && SITE=CACR django-admin.py runserver'
alias gobce='goclassic && SITE=BCE django-admin.py runserver'
alias gocair='goclassic && SITE=CAIR django-admin.py runserver'
alias goesi='goclassic && SITE=ESI django-admin.py runserver'
alias gomass='goclassic && SITE=MASS django-admin.py runserver'
# IRIS
alias goiris='pycharm ~/projects/iris && deactivate || : && cd ~/projects/iris && echo ">>>>>> mprs - or - mp shell_plus --notebook" && source .venv/bin/activate'
alias goirisdj='goiris && manage.py runserver'
alias goirisq='goiris && manage.py qcluster'
alias goirisreactw='cd ~/projects/iris/iris/static && pipenv run npx webpack --config webpack.dev.js --progress --profile --color --watch'
# I think reactc needs to be updated === https://github.com/energy-solution/iris#compile-the-react-bundle
alias goirisreactc='cd ~/projects/iris/iris/static && deactivate && pipenv run npx webpack-cli --config webpack.config.js && cd ../..'
alias reactc='cd iris/static; npx webpack-cli --config webpack.config.js; cd ../..'
alias reactw='cd iris/static; npx webpack-cli --config webpack.config.js --watch'
alias resetiris='mp reset_db --noinput && mp migrate && mp hopper -q -i forward -u bkremer -p test'
alias irisdbdump='gofab && esfab iris develop dump_db'
irisdbload() {
if [[ $1 == "" ]];
then
local DBNAME=iris_$(date +'%Y%m%d')
else
local DBNAME=$1
fi
if psql -lqt | cut -d \| -f 1 | grep -qw $DBNAME;
then
echo -n "$DBNAME already exists Continue? [y/N] "
read response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])+$ ]];
then
echo "Try another database name"
return
fi
fi
echo -n "Dropping and loading db named $DBNAME Continue? [y/N] "
read response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
echo "This may take a while"
dropdb --if-exists $DBNAME
createdb $DBNAME
gunzip -c ~/projects/es_fab/iris_bkremer.pgsql.gz | psql $DBNAME
else
echo "no"
fi
}
# TPC TradePro Connect - Manage My Power?
alias gotpc='cd ~/projects/tpc && pipenv shell'
# RPS
alias gorps='pycharm ~/projects/rps_python3 && deactivate || : && cd ~/projects/rps_python3/rps && echo ">>>>>> mprs - or - mp shell_plus --notebook" && source .venv/bin/activate'
alias deployrps='rm rps.zip; git archive -v -o rps.zip --format=zip HEAD && zip -d rps.zip docker-compose.yml && git rev-parse HEAD'
alias rpsdeploy='deployrps'
# ESFAB
alias gofab='deactivate || : && cd ~/projects/es_fab/ && source .venv/bin/activate'
alias goesfab='gofab'
# ETC
#alias wkillwsa='for f in $(pgrep WSDaemon); do sudo renice -n +20 -p $f; echo $f "deprioritized"; done'
alias fullkillwsa='pkill WSDaemon'
alias cleanpyc='cd /opt/web && find . -name '*.pyc' -delete'
# alias mkvirtualenv3='mkvirtualenv --python=`which python3`'
# notes
ben ( ) {
echo '';
echo 'VIRTUAL ENVs >>---------------------';
echo ' pyenv local 3.7.11 # to specify which version this directory uses';
echo ' pyenv exec python -m venv .venv # uses specified version';
echo ' python3 -m venv .venv # uses current python3 version';
echo ' .venv/bin/pip install --upgrade setuptools wheel pip';
echo ' source .venv/bin/activate';
echo '';
echo 'GIT & CLI >>------------------------';
echo ' git checkout stash@{0} -- <filename>';
echo ' gitad to show gitadvanced';
echo ' git merge --no-ff develop';
echo ' git pull --rebase origin <branch_name> :: my branch, pull down others updates';
echo ' gitup <branch> :: updates branch';
echo ' git status 2>&1 | tee ~/Desktop/output.txt :: output here and file';
echo ' find . -name "<*.txt>" -print';
echo ' grep -rl <TEXTtoFIND> . /// find text starting here - recursive';
echo ' grep -i <TEXTtoFIND> <*.txt> /// -i ignores case';
echo ' ebaliases or ebprofile to update and source';
echo ' open . /// open finder at this directory';
echo ' mcd <name> // make directory and cd into it';
echo '';
echo 'PYTHON >>---------------------------';
echo ' pytest -m "not-ui" -s -n 8 -k <project/apps/users> :: -s for print statements :: -k for search :: -x failfirst';
echo '';
echo 'DJANGO >>---------------------------';
echo ' django-admin.py test prism_events.tests.test_api_views --settings=app.settings --keepdb';
echo '';
echo 'ENERGY SOLUTIONS >>-----------------';
echo ' sshes <branch / test server name> :: sshes iris-develop';
echo ' goiris :: goirisq :: goiris';
echo ' fixpanda :: temporarily fix panda memory issue';
echo ' adrdash :: update adr dashboard';
echo ' killwsa or fullkillwsa :: WSDaemon';
echo ' irisdbload <dbname> :: load db';
}
# echo '';
# echo 'MISC >>-----------------------------';
# echo ' um () :: personal manual pages';
# echo ' umedit (<name of shortcut>) :: edit manual';
alias open_gitad='open evernote:///view/1234567890'
alias cat_gitad='cat ~/.bash_git_advanced'
alias gitad='cat_gitad && open_gitad'
#gitadw () {
# open "evernote:///view/12345/";
# cat ~/.bash_git_advanced;
# open_gitad;
#}
# homemade man pages mdless
function mdless() {
pandoc -s -f markdown -t man $1 | groff -T utf8 -man | less
}
umedit() { mkdir -p ~/.notes; nano ~/.notes/$1; }
um() { mdless ~/.notes/"$1"; }
umls() { ls ~/.notes; }
# django aliases
alias mp='./manage.py'
alias mprs='./manage.py runserver'
alias mpwk='./manage.py worker'
alias djtest='django-admin.py test'
alias mpshell='./manage.py shell_plus --notebook'
# some more ls aliases
alias ls='ls -hG'
alias ll='ls -halF'
alias lll='ll -haltr'
alias la='ls -hA'
alias l='ls -hCF'
mcd () { mkdir -p $1; cd $1; pwd; }
cd() { builtin cd "$@"; ll; } # Always list directory contents upon 'cd'
alias cd..='cd ../' # Go back 1 directory level (for fast typers)
alias ..='cd ../' # Go back 1 directory level
alias ...='cd ../../' # Go back 2 directory levels
alias ~="cd ~" # ~: Go Home
alias qfind="find . -name " # qfind: Quickly search for file
# git aliases
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias go='git checkout '
gitup () { git checkout $1; git pull; }
# extract: Extract most know archives with one command
# ---------------------------------------------------------
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
adrdash () {
# networksetup -connectpppoeservice "L2TP VPN";
# open smb://user:pass@192.168.25.13/Share/;
if [[ $1 == "" ]];
then
echo "Add filename argument please"
return
else
local FILENAME=$1
fi
workon adr-dashboard;
open -a /Applications/Tableau\ Desktop\ 2018.1.app --hide;
git status; git diff;
read -r -p "Everything good? Continue? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
echo 'Continuing\n';
echo "Tableau. u: pborocz@energy-solution.com :: p: password ";
# gitup ADR-189_budget_program_year_from_adrincappid;
gitup master;
cd py;
python 0_integrity.py $FILENAME;
python 1a_program_dashboard.py $FILENAME;
git status; cd..; git add .; git status;
read -r -p "Everything still good? Continue with committing? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
echo 'Continuing ------------------------------';
git commit -am "$(date +'%F') dashboard refresh";
echo "If all that looks good Command-V to paste:";
# echo "git push origin ADR-189_budget_program_year_from_adrincappid" | pbcopy;
echo "git push origin master" | pbcopy;
# echo "git push origin ADR-189_budget_program_year_from_adrincappid";
echo "git push origin master";
echo "Tableau ---------------------------------";
echo "1. Open Tableau:: control-command-O :: ADR_Dashboard_v0.9.8";
echo "2. u: pborocz@energy-solution.com :: p: password";
echo "3. Run Data > Refresh All Extracts";
echo "4. control-command-S to save";
echo "------------------------------------------";
echo "slack://channel?team=T02N7NGQF&id=C089ULHDK";
echo "FYI - I just finished updating the ADR program dashboard";
echo "http://pge-adr.com/dashboard/";
open "slack://channel?team=asdf&id=asdf";
open -R ~/projects/adr-dashboard/py/integrity.xlsx
else
echo 'no :: exiting (2)';
fi
else
echo 'no :: exiting (1)';
fi
}
alias ebaliases='nano ~/.bash_aliases && source ~/.bash*'
alias ebprofile='nano ~/.bash_profile && source ~/.bash*'
alias lt='ls -alrt'
#temp since prev point to kremerdesign not benkremer computer setup
fixvenv () {
deactivate;
rmvirtualenv $1;
mkvirtualenv --python=/usr/local/bin/python$2 $1;
}
# then
# $ source ~/.bash*
# to reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment