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
| package main | |
| import ( | |
| "fmt" | |
| "strings" | |
| ) | |
| func main() { | |
| var string_a string = "My super \nsweet \nstring has \nmany newline\n characters" |
| import urllib.request | |
| import json | |
| api_key = '7ba14b76dcea0086a03f8eca5a3a801f:1:74295566' | |
| category = 'editorial' | |
| for i in range(5): | |
| url = "http://api.nytimes.com/svc/search/v2/articlesearch.json?" \ | |
| "q={0}&api-key={1}&page={2}".format(category, api_key, i) | |
| h = urllib.request.urlopen(url) | |
| result = json.loads(h.read().decode('utf-8')) |
| # Be sure to save your config files. Optional but I do: | |
| sudo cp /etc/postgresql/9.3/main/postgresql.conf ~ | |
| sudo cp /etc/postgresql/9.3/main/pg_hba.conf ~ | |
| # Package repo (for apt-get) | |
| wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
| sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list' | |
| # Also probably optional but I like to update sources and upgrade | |
| sudo apt-get update |
| package main | |
| import ( | |
| "fmt" | |
| "gopkg.in/mgo.v2" | |
| "gopkg.in/mgo.v2/bson" | |
| ) | |
| type msg struct { | |
| // Msg string `bson:"msg"` |
| package main | |
| import ( | |
| "fmt" | |
| "labix.org/v2/mgo" | |
| "labix.org/v2/mgo/bson" | |
| "time" | |
| ) | |
| type Person struct { |
As configured in my dotfiles.
start new:
tmux
start new with session name: