- Download from the Apple Site
- Install
sudo easy_install pip
sudo easy_install pip
| #!/bin/sh | |
| printf "\e[32mRemoving merged branches:\n\033[0m" | |
| git branch --merged master | grep -v master | |
| read -p "Are you sure? " -n 1 | |
| echo "\n" | |
| if [[ ! $REPLY =~ ^[Yy]$ ]] | |
| then | |
| exit 1 |
| git for-each-ref --sort=-committerdate --shell --format="echo %(refname:short) by %(authorname) && git log -n 1 --format=format:\" %%cd%%n %%B\" %(refname)" refs/heads/ | sh | less -R |
I visited with PagerDuty yesterday for a little Friday beer and pizza. While there I got started talking about Go. I was asked by Alex, their CEO, why I liked it. Several other people have asked me the same question recently, so I figured it was worth posting.
The first 1/2 of Go's concurrency story. Lightweight, concurrent function execution. You can spawn tons of these if needed and the Go runtime multiplexes them onto the configured number of CPUs/Threads as needed. They start with a super small stack that can grow (and shrink) via dynamic allocation (and freeing). They are as simple as go f(x), where f() is a function.
| package math | |
| import ( | |
| "errors" | |
| m "math" | |
| ) | |
| // Finds the minimum value in a slice of numbers | |
| func Min(xs []float64) (float64, error) { | |
| if len(xs) == 0 { |
| $ rethinkdb -j "172.16.42.218:28015" | |
| info: Running rethinkdb 1.6.1 (CLANG 4.2 (clang-425.0.28))... | |
| info: Running on Darwin 12.4.0 x86_64 | |
| info: Loading data from directory /Users/nickp/rethinkdb_data | |
| info: Listening for intracluster connections on port 29015 | |
| info: Attempting connection to 1 peer... |
| ## CALLING CODE | |
| from django.conf import settings | |
| def my_function(): | |
| foo = getattr(settings, 'foo', None) | |
| if foo: | |
| return foo.BAR | |
| return BAZ |
| class MyRouter(object): | |
| def db_for_read(self, model, **hints): | |
| if model._meta.object_name == 'SpecialModel': | |
| return 'special' | |
| return False | |
| def db_for_write(self, model, **hints): | |
| return self.db_for_read(model, **hints) | |
| def allow_syncdb(self, db, model): |
| package main | |
| import ( | |
| "fmt" | |
| "net/http" | |
| ) | |
| func handler(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "Method: %s\n", r.Method) | |
| } |
| // trunecateString trunecates a string up to a maximum of length characters. | |
| func truncateString(s string, length int) string { | |
| l := utf8.RuneCountInString(s) | |
| if l < length { | |
| length = l | |
| } | |
| out := make([]string, length) | |
| var ch rune | |
| var size int | |
| i, curr := 0, 0 |