A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| '''read a csv file representing a table and write a restructured text simple | |
| table''' | |
| import sys | |
| import csv | |
| def get_out(out=None): | |
| ''' | |
| return a file like object from different kinds of values | |
| None: returns stdout | |
| string: returns open(path) |
| #!/usr/bin/env -S uv run --script --quiet | |
| # /// script | |
| # requires-python = ">=3.13" | |
| # dependencies = [] | |
| # /// | |
| """A simple python script template. | |
| """ |
| @echo off | |
| REM Reference: http://www.techrepublic.com/forum/questions/101-215911/dos-command-to-list-all-installed-programs | |
| echo ================= >>software_list.txt | |
| reg export HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall temp1.txt | |
| find "DisplayName" temp1.txt| find /V "ParentDisplayName" > temp2.txt | |
| for /f "tokens=2,3 delims==" %%a in (temp2.txt) do (echo %%a >> software_list.txt) | |
| del temp1.txt | |
| del temp2.txt | |
| REM type software_list.txt | more | |
| echo. |
| apt-get install python-pygraphviz | |
| pip install django-extensions | |
| # add 'django_extensions' to INSTALLED_APPS in settings.py | |
| python manage.py graph_models trees -o test.png |
| -- Remove the history from | |
| rm -rf .git | |
| -- recreate the repos from the current content only | |
| git init | |
| git add . | |
| git commit -m "Initial commit" | |
| -- push to the github remote repos ensuring you overwrite history | |
| git remote add origin [email protected]:<YOUR ACCOUNT>/<YOUR REPOS>.git |
| #!/bin/zsh | |
| # pyenv install for CentOS 6.5 x86_64 | |
| yum install -y gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel | |
| git clone git://github.com/yyuu/pyenv.git ~/.pyenv | |
| export PATH="$HOME/.pyenv/bin:$PATH" | |
| eval "$(pyenv init -)" |
| #!/usr/bin/env bash | |
| # repository | |
| cd /tmp | |
| wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm | |
| rpm -Uvh epel-release-6-8.noarch.rpm | |
| # system update | |
| yum -y update | |
| yum -y groupinstall "Development Tools" | |
| yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick |
| # Systemd unit to enable xboxdrv driver for Xbox 360 controller | |
| # Usage: | |
| # save to /lib/systemd/system/xboxdrv.service | |
| # to start: sudo service xboxdrv start | |
| # to enable on boot: sudo systemctl enable xboxdrv | |
| [Unit] | |
| Description=Xbox controller driver daemon | |
| [Service] |