-
2 oz Rye
-
1 oz sweet Vermouth
-
3 dashes Angostura bitters
Stir, served Up in a coupe glass
- 2 oz Gin
func f() error { | |
// might return an error | |
} | |
func somethingElse() { | |
switch err := f(); err { | |
case mgo.ErrNotFound: | |
// a specific error that is recoverable | |
case nil: | |
// no error occurred. Usually this is just a break statement. |
package main | |
import ( | |
"bufio" | |
"encoding/json" | |
"log" | |
"net/http" | |
) | |
func main() { |
package main | |
import ( | |
"bufio" | |
"encoding/json" | |
"log" | |
"net/http" | |
) | |
func main() { |
var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" | |
// generates a random string of fixed size | |
func nonce(size int) string { | |
buf := make([]byte, size) | |
for i := 0; i < size; i++ { | |
buf[i] = alpha[rand.Intn(len(alpha)-1)] | |
} | |
return string(buf) | |
} |
import Leap, sys, OSC | |
class Listener(Leap.Listener): | |
def __init__(self): | |
super(Listener, self).__init__() | |
client = OSC.OSCClient() | |
client.connect(('127.0.0.1', 9000)) | |
self.client = client |
class Voice { | |
int id; // id of the finger on the leapmotion | |
OscRecv in; // inbound communication | |
ADSR env => Pan2 pan => dac; // setup an ADSR envelope | |
Osc @ osc; // reference to the current oscillator | |
float x; | |
float y; | |
float z; | |
0 => int state; |
Use Vim settings, rather then Vi settings (much better!). | |
" This must be first, because it changes other options as a side effect. | |
set nocompatible | |
set backspace=indent,eol,start | |
set autoindent | |
set smartindent | |
set tabstop=4 | |
set expandtab " holy war | |
set smarttab " I don't know what this does. |
I missed a payment on my Time Warner Cable bill. Prior to this, the hostname of my laptop was "yupa" (after Master Yupa, from Nausicaa of the Valley of the Wind, because it's a MBA, get it, air? ok, sorry, that's fucking awful I know). Anyway, look at what my hostname is now:
jordanorelli@auto-prov[0] ~: hostname
auto-prov.rr.com
umm, excuse me, I never changed my hostname. Anyway, let's back the fuck up and see how I even discovered this.
When I got home today, I opened my MBA and fired up Chrome. On startup, it tried to open up all the tabs that were open when I closed it. Some of these included a google.com page. All of them were, instead, redirected to whatever hostname they were talking to, with ap_index
tacked on the end. E.g., refreshing a Google page bounced me to google.com/ap_index
, which is the automatic provisioning page that a Time Warner Cable tech is supposed to see when they start up the computer. My brother (who is also my roommate) opened the account and has all the i
Most developers that are familiar with dynamic scripting language like Ruby, JavaScript, or Python have been exposed to higher-order functions. Coming from a scripting background, it can be hard to translate that knowledge into Go, since the type system seems to get in the way. On the other hand, coming from a statically typed, primarily object-oriented language like C++, C#, or Java, the problem may be the opposite: static type systems are less of a stumbling block, but the usage of higher-order functions may be less intuitive. For programmers with functional experience, most of this knowledge may come across as very pedestrian, but hopefully this article will at least demonstrate how to use Go's type system with respect to functions.
In this article, we'll look at a few situations where function types in Go can be very useful. The reader is not assumed to be an experienced Go programmer, although a cursory knowledge of Go will certainly be helpful