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
| # NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
| $ cd /usr/src | |
| $ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
| $ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
| $ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
| $ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
| $ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |
| #!/bin/bash | |
| set -e | |
| if [ $# -eq 0 ]; then | |
| echo "USAGE: $0 plugin1 plugin2 ..." | |
| exit 1 | |
| fi | |
| plugin_dir=/var/lib/jenkins/plugins |
| #!/bin/sh | |
| # extend non-HiDPI external display on DP* above HiDPI internal display eDP* | |
| # see also https://wiki.archlinux.org/index.php/HiDPI | |
| # you may run into https://bugs.freedesktop.org/show_bug.cgi?id=39949 | |
| # https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/883319 | |
| EXT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^eDP | head -n 1` | |
| INT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^DP | head -n 1` | |
| ext_w=`xrandr | sed 's/^'"${EXT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'` |
It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
| /* | |
| After purchasing a humble book bundle, go to your download page for that bundle. | |
| Open a console window for the page and paste in the below javascript. | |
| This will download all the books in all the formats available. | |
| */ | |
| $('a').each(function(i){ | |
| if (['MOBI', 'PDF', 'EPUB'].indexOf($.trim($(this).text())) >= 0) { | |
| $('body').append('<iframe id="dl_iframe_'+i+'" style="display:none;">'); | |
| document.getElementById('dl_iframe_'+i).src = $(this).data('web'); | |
| } |
| #cloud-init | |
| # https://docs.chef.io/packages.html#enterprise-linux | |
| # vendor chef-repo to /var/lib/chef with cookbooks in /var/lib/chef/cookbooks | |
| yum_repos: | |
| chef-stable: | |
| name: chef-stable | |
| baseurl: https://packages.chef.io/stable-yum/el/7/\$basearch/ | |
| enabled: true | |
| failovermethod: priority |
| /* | |
| After purchasing a humble book bundle, go to your download page for that bundle. | |
| Open a console window for the page and paste in the below javascript | |
| this fork downloads all formats and does so without using jquery (since that didnt work for me) | |
| note that if you are in chrome, chrome will not download the pdfs for you by default, to fix this | |
| type “about:plugins” in the address bar and disable chrome's pdf viewer | |
| */ | |
| var pattern = /(MOBI|EPUB|PDF)$/i; |
| #!/bin/sh | |
| # in case it's already installled | |
| vagrant plugin uninstall vagrant-libvirt | |
| # vagrant's copy of curl prevents the proper installation of ruby-libvirt | |
| sudo mv /opt/vagrant/embedded/lib/libcurl.so{,.backup} | |
| sudo mv /opt/vagrant/embedded/lib/libcurl.so.4{,.backup} | |
| sudo mv /opt/vagrant/embedded/lib/libcurl.so.4.4.0{,.backup} | |
| sudo mv /opt/vagrant/embedded/lib/pkgconfig/libcurl.pc{,.backup} |
| # Requires Python 3 | |
| import requests | |
| import locale | |
| from typing import Dict, Tuple, List | |
| from calendar import monthrange | |
| from datetime import datetime | |
| FASTLY_URL = "https://api.fastly.com/stats/usage_by_month?billable_units=true" |