Skip to content

Instantly share code, notes, and snippets.

@czuger
czuger / gist:476ed57c0fc83d6b8fa08090aa93b60b
Created April 14, 2025 14:19
Turn off swap on debian (raspberry pi)
sudo dphys-swapfile swapoff # If you don't want to reboot imediately.
sudo systemctl disable dphys-swapfile.service
sudo apt purge dphys-swapfile # No need for it now.
@czuger
czuger / gist:2ee1b2900a0f2f09190f5bb4915282bb
Created January 22, 2025 11:10
Modify docker data directory
# Edit or create a file in /etc/docker/daemon.json
# Modify or add
{
"data-root": "/new/data/root/path"
}
# Restart docker
@czuger
czuger / gist:ec4235128aa2f7e75964fd92eaecec86
Created December 25, 2024 11:32
Reset all commit author in branch history
git rebase -r --root --exec "git commit --amend --no-edit --author '[email protected]'"
@czuger
czuger / gist:97c8aaa2a7380eda82f8217760031aea
Created November 24, 2024 12:31
How to show virtualenv in zsh prompt
# First ensure you enabled auto-activation of virtualenvs
# https://github.com/pyenv/pyenv-virtualenv
# echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc
# Then follow
# https://barker.codes/blog/adding-the-virtual-environment-name-to-your-prompt-with-oh-my-zsh/
# May also face this :
# https://stackoverflow.com/questions/38928717/virtualenv-name-not-show-in-zsh-prompt
@czuger
czuger / gist:58eb85940b33fb70fd0379cad559d4ad
Created November 24, 2024 12:07
Key binding on mac os , replacing , -> . on numpad
mkdir -p ~/Library/KeyBindings/
touch ~/Library/KeyBindings/DefaultKeyBinding.dict
vim DefaultKeyBinding.dict
# Insert
{
"#," = ("insertText:", ".");
}
# https://ss64.com/mac/syntax-keybindings.html
@czuger
czuger / gist:8900bed2fc9ec2b616d7b0597f1215a6
Last active November 24, 2024 12:31
Pyenv install for M4
brew install liblzma-dev
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
cd ~/.pyenv && src/configure && make -C src
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
eval "$(pyenv init -)"
@czuger
czuger / psql.sh
Created June 17, 2024 16:39
Intstall psql client on Mac Os
brew doctor
brew update
brew install libpq
brew link --force libpq
@czuger
czuger / python_install.sh
Last active June 17, 2024 16:29
Python + pyenv for mac
brew install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev
brew install libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev pkg-config liblzma-dev git
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
cd ~/.pyenv && src/configure && make -C src
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
@czuger
czuger / gist:ab5c932fd6569e339a5160a59727befa
Created June 5, 2024 08:08
Disable wifi and bluetooth on Raspberry Pi
# In /boot/firmware/config.txt (or /boot/config.txt)
# After [all], add
dtoverlay=disable-wifi
dtoverlay=disable-bt
from flask_login import login_user
from flask_login import logout_user
from flask_login import current_user
from werkzeug.security import check_password_hash
class User(Base):
__tablename__ = 'user'
id = Column(Integer, primary_key=True)