Skip to content

Instantly share code, notes, and snippets.

@bbelderbos
Last active May 12, 2023 11:07
Show Gist options
  • Save bbelderbos/3069c087af95ce756facf1712d501b7d to your computer and use it in GitHub Desktop.
Save bbelderbos/3069c087af95ce756facf1712d501b7d to your computer and use it in GitHub Desktop.
== 1. save time ==
alias python3=python3.11
alias ae='source venv/bin/activate'
alias pvenv='python3 -m venv venv && ae'
alias pipall="python -m pip install -r requirements.txt"
alias pipfr="python -m pip freeze >|requirements.txt"
alias dl='cd ~/Downloads'
# change this to your own project
alias cch='cd ~/code/codechalleng.es'
# change this to your own shell / editor
alias brc='vim ~/.zshrc'
alias vrc='vim ~/.vimrc'
alias src='source ~/.zshrc'
alias whatweek='date +%U'
# change this to your own links you often need to copy around, might need to install pbcopy
alias onceh="echo https://go.oncehub.com/pybiteschat | pbcopy && echo 'Calendar linked copied to clipboard'"
alias pbslack="echo https://pybit.es/community| pbcopy && echo 'Slack link copied to clipboard'"
alias kindle='open https://read.amazon.com/notebook'
alias runredis="docker run -it --rm --name redis -p 6379:6379 redis"
alias gitignore="curl -s https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore > .gitignore"
== 2. some git stuff ==
alias gs='git status'
alias grv='git remote -v'
alias gco='git checkout'
alias gcme='git add . && git commit'
alias gcma='git add . && git commit --amend'
alias gcmaa='git add . && git commit --amend --no-edit'
== 3. django / postgres ==
alias rs='python manage.py runserver'
function csu() {
echo "from django.contrib.auth.models import User; User.objects.create_superuser('$1', '$1@example.com', 'handl3bar')" | python manage.py shell
}
# install pgcli, update postgres variables if needed
alias pb_cc='pgcli postgres://postgres:password@0.0.0.0:5432/pb_cc'
== 4. utils ==
# requires https://github.com/bbelderbos/youtube-thumbnails
function ytimg {
(cd $HOME/code/youtube-thumbs && ae && python thumbs.py "$1" && open images)
}
# requires https://github.com/PyBites-Open-Source/pybites-carbon
function carbp {
(cd $HOME/code/pybites-carbon && ae && carbon -c -b \#A0D6B4 -w bw -d $HOME/Downloads)
}
# requires https://github.com/bbelderbos/emojisearcher
function emo {
(cd $HOME/code/emojisearcher && ae && python -m emojisearcher.script "$@")
}
# requires https://github.com/PyBites-Open-Source/search
export SEARCH_REPO=$HOME/code/search
function vid {
(cd $SEARCH_REPO && ae && python -m src.pybites_search video "$@")
}
function tip {
(cd $SEARCH_REPO && ae && python -m src.pybites_search tip "$@")
}
function pod {
(cd $SEARCH_REPO && ae && python -m src.pybites_search podcast "$@")
}
function bite {
(cd $SEARCH_REPO && ae && python -m src.pybites_search bite "$@")
}
function art {
(cd $SEARCH_REPO && ae && python -m src.pybites_search article "$@")
}
function all {
(cd $SEARCH_REPO && ae && python -m src.pybites_search all "$@")
}
# random tip script: https://gist.github.com/bbelderbos/ca135aff7379e4e97ee11928d5ace12d
alias randomtip="cd ~/bin && ae && python random-tip.py"
== 5. read source code ==
function pys {
if [ "$#" -eq 1 ]; then
# show source of module
search=$1
else
# show source of module -> object
search=$1:$2
fi
(python -m inspect $search|less)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment