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
| M42 P4 S255 ; led green | |
| M42 P5 S50 ; led red | |
| M42 P6 S50 ; led blue | |
| M104 S0 ; nozzle heater off | |
| M140 S0 ; bed heater off | |
| G92 E1 ; relative positioning mode | |
| G1 E-1 F300 ; Retract the filament | |
| G28 X ; Home the X axis | |
| G0 Y280 F600 ; Bring the bed to the front for easy print removal |
| #!/bin/bash | |
| # Automatically setup routing and DNS for a PiZero connected over a USB-network | |
| # NOTE: Before running this script for the first time, you need to run the | |
| # following two commands on your Linux PC | |
| # sudo sysctl -w net.ipv4.ip_forward=1 | |
| # sudo iptables -t nat -A POSTROUTING -s 169.254.0.0/16 -o eth0 -j MASQUERADE | |
| # (replace eth0 in the second command with your internet-facing network device, | |
| # e.g. wlan0 on a laptop) | |
| # The Avahi-discovered hostname |
| #!/usr/bin/env python | |
| """ | |
| Prepare an HTML file from SnakeViz for use as a static page. | |
| This makes it so all static files are loaded from a CDN instead | |
| of from the local server. | |
| To get the SnakeViz HTML file run the snakeviz CLI to load a profile | |
| in your browser, than save that page as an HTML file to your computer. | |
| Finally, run this script on that HTML file. |
| Remove osxfuse if installed via homebrew: | |
| > brew uninstall osxfuse | |
| Install osxfuse binary and choose to install the MacFUSE compatibility layer: | |
| http://sourceforge.net/projects/osxfuse/files/latest/download?source=files | |
| Reboot (optional but recommended by osxfuse) | |
| Install ntfs-3g via homebrew: | |
| > brew update && brew install ntfs-3g |
| # post_loc.txt contains the json you want to post | |
| # -p means to POST it | |
| # -H adds an Auth header (could be Basic or Token) | |
| # -T sets the Content-Type | |
| # -c is concurrent clients | |
| # -n is the number of requests to run in the test | |
| ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/ |
| # Customize BASH PS1 prompt to show current GIT repository and branch. | |
| # by Mike Stewart - http://MediaDoneRight.com | |
| # SETUP CONSTANTS | |
| # Bunch-o-predefined colors. Makes reading code easier than escape sequences. | |
| # I don't remember where I found this. o_O | |
| # Reset | |
| Color_Off="\[\033[0m\]" # Text Reset |
| #!/bin/bash | |
| # Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/ | |
| set -e | |
| sourceApp="$1" | |
| targetApp="$2" | |
| while read key value; do |
| # to generate your dhparam.pem file, run in the terminal | |
| openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
| import os | |
| import tempfile | |
| file_descriptor, file_path = tempfile.mkstemp(suffix='.tmp') | |
| # You can convert the low level file_descriptor to a normal open file using fdopen | |
| with os.fdopen(file_descriptor, 'w') as open_file: | |
| open_file.write('hello') |