This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://eev.ee/blog/2016/07/31/python-faq-why-should-i-use-python-3/#yield-from | |
# https://jeffknupp.com/blog/2013/04/07/improve-your-python-yield-and-generators-explained/ | |
# `yield` | |
# - pauses generator (saves its state) on the current line of code | |
# - returns yielded value (and control) to the caller | |
# - receives another `somevalue` from the caller via generator.send(somevalue) | |
# `yield from` | |
# - yields an entire sequence |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# One-liner | |
pyenv global 3.5.2 && virtualenv .env -p $(pyenv which python) && . .env/bin/activate && python -V && pyenv global system | |
# List installed versions | |
pyenv versions | |
# Set global version to | |
pyenv global 3.5.2 | |
# Check current set version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Author: Alex Just <AlexJustEmail@gmail.com> | |
"""Download target URL, append all 6 letter words with a ™ symbol, and display the outputs in the opened user's browser | |
Project specification: | |
https://docs.google.com/document/d/1bua6MXG9rHyreSPVPEZBkk14WYHy31ia4Vb2rnrgvS0/edit | |
Installation: | |
$ pip3 install bs4 vcrpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
whoami | |
# Add user to sudoers | |
sudo adduser <username> sudo | |
# Switch user | |
su - user2 | |
# List all local users | |
cut -d: -f1 /etc/passwd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get dist-upgrade | |
sudo apt-get upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-keygen -t rsa | |
cat ~/.ssh/id_rsa.pub | ssh user@host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys" | |
# or | |
cat ~/.ssh/id_rsa.pub | ssh-copy-id user@host | |
ssh-add -K ~/.ssh/id_rsa | |
# You might need to start ssh-agent | |
eval `ssh-agent -s` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python3 -c "import requests; proxies = {'http': '127.0.0.1:21233'}; response = requests.get('http://ya.ru', proxies = proxies); print ('Elapsed time: ', response.elapsed)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Upgrading all packages with pip | |
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U | |
# Pip freeze for only project requirements.txt | |
pip freeze -r requirements.txt | grep -B100 "pip freeze" | grep -v "pip freeze" > /tmp/requirements.txt && mv /tmp/requirements.txt . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Login as a UNIX user (IDENT/PEER authentication) | |
sudo -u postgres psql postgres | |
# Login via PostgreSQL's own managed username/password (TCP authentication) | |
psql username -h 127.0.0.1 -d dbname | |
# Switch to postgres user via root | |
sudo -i -u postgres | |
# Backup DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OSX | |
lsof -i :8000 | |
# Ubuntu | |
sudo netstat -peanut |