new favorite shortcuts in ubuntu - alt + left click to move a window and alt + middle click to resize the window.
and good reference page for shell commands:
https://help.ubuntu.com/11.04/serverguide/C/index.html
Started off this morning walking through the tutorials for Go App Engine.  I'm reading that I need Python 2.5 installed for App Engine to run.  I'm running Ubuntu 10.04 Lucid Lynx, and the system installed Python is: 2.6.5.  Initially I figured I'd need Python 2.5 installed, and that I'd just do the following:

Go to: http://www.python.org/download/releases/ and check for the latest 2.5 release, currently 2.5.6. Download the bzip2-compressed source code. Open a terminal and:
tar -xjvf Python-2.5.6.tar.bz2
cd Python-2.5.6
./configure
sudo make altinstall
make test
sudo install


but, then I'd have to invoke App Engine by invoking python 2.5 instead of the system default, or I could use virtualenv and pythonbrew.  
OR, let's just try and see if I can skip all of this and just run it with 2.6.5 instead, which is what I'm going to try first, because all of this is annoying.  Wait, this reminds me of why I like Go.

While reading through Gary Burd's oauth.go package I was confused about:



This is declaring an array, but why isn't it {'A':true, 'B':true,...'Z':true,...}
Thanks to Gary for explaining this. When initializing Go's composite literals
for array and slice literals the following rules apply:


Each element has an associated integer index marking its position in the array.
An element with a key uses the key as its index; the key must be a constant integer expression.
An element without a key uses the previous element's index plus one. If the first element has no key, its index is zero.


so, since the second true has no key it uses the previous element's index plus one, which in this case is 'B'. Pretty cool, and lots faster than writing everything out.
writer interface discussion
Reference links for some useful conversations about using go for web programming:

PHP's $_SESSION mechanism
https://groups.google.com/d/topic/golang-nuts/cZ8Pkz6fbtg/discussion

Nobody Cares - microblogging
http://code.google.com/p/nobodycares/

gopages - embed go in webpages
http://code.google.com/p/gopages/

+ [Codelab: Writing Web Applications](http://golang.org/doc/codelab/wiki/)

+ [Generic request/response handing](
http://www.tideland.biz/articles/coding-in-go/generic-request-response-handing)

+ [Make A Basic GO http Server](
http://go.hokapoka.com/go/make-a-basic-go-http-server/)

+ [Serve on multiple hosts / domains with Go](
http://go.hokapoka.com/go/serve-on-multiple-hosts-domains-with-go/)

+ [GO & web.go](http://go.hokapoka.com/go/go-web-go/)

+ [Web chat using WebSockets and Go](
http://gary.beagledreams.com/page/go-websocket-chat)

+ [Deploying Go web services behind Nginx under Debian or Ubuntu](
http://nf.id.au/deploying-go-web-services-behind-nginx-under)

If you're looking for a simple framework to build a website, check out
web.go:
http://github.com/hoisie/web.go

It supports standard fastcgi and scgi environments, which means it
will work behind Apache/lighty/nginx..

https://groups.google.com/d/topic/golang-nuts/GbaswguQ2Ak/discussion
https://github.com/nf/gowiki
http://go.hokapoka.com/go/use-gos-html-templates/#more-86
http://go.hokapoka.com/go/make-a-basic-go-http-server/#more-89
http://go.hokapoka.com/go/serve-on-multiple-hosts-domains-with-go/#more-88
http://go.hokapoka.com/go/embedding-or-nesting-go-templates/
Working on setting up an EC2 instance with boto, and after the initial boot, I'm going to ssh to the new instance and setup my environment. So, I can use Python or Go, so here's an example of using go to script shell commands from the golang-nuts group
package main
import (
"fmt"
"exec"
"bytes"
)
func main() {
cmd := "/bin/sh"
args := []string{cmd, "-c", "ls passwd"}
dir := "/etc"
p, err := exec.Run(cmd, args, nil, dir,
exec.DevNull, exec.Pipe, exec.PassThrough)
if err != nil {
return
}
var b bytes.Buffer
_, err = b.ReadFrom(p.Stdout)
if err != nil {
return
}
err = p.Close()
if err != nil {
return
}
fmt.Println(b.String())
}

swig -go

Working through the Go SWIG tutorial :

Using two files: example.c and example.i
 /* File : example.c */ 
 #include <time.h>
 double My_variable = 3.0; 

 int fact(int n) {
     if (n <= 1) return 1;
     else return n*fact(n-1);
 } 

 int my_mod(int x, int y) {
     return (x%y);
 } 

 char *get_time()
 {
     time_t ltime;
     time(&ltime);
     return ctime(&ltime);
 } 

______________________________________________ 
/* example.i */
 %module example
 %{
 /* Put header files here or function declarations like below */
 extern double My_variable;
 extern int fact(int n);
 extern int my_mod(int x, int y);
 extern char *get_time();
 %} 

 extern double My_variable;
 extern int fact(int n);
 extern int my_mod(int x, int y);
 extern char *get_time(); 

________________________________________________________ 
Then, according to the instructions in http://www.swig.org/Doc2.0/Go.html#Go 
% swig -go example.i
% gcc -c -fpic example.c
% gcc -c -fpic example_wrap.c
% gcc -shared example.o example_wrap.o -o example.so
% 6g example.go
% 6c example_gc.c 

example_gc.c:14 6c: No such file or directory: runtime.h 

After reading golang-nuts thread:

% 6c -I ${GOROOT}/pkg/${GOOS}_${GOARCH} 
-D_64BIT example_gc.c

This works.  


what does an Amazon EC2 instance cost per month?


Output:
Small instance:
variable cost per month: 21.84
fixed cost per month: 9.72
Monthly small: 31.56
Large instance:
vairiable cost per month: 87.36
fixed cost per month: 38.89
Monthly Large: 126.25

Playing with Strings

Received learninggo yesterday and playing around with formatting strings.

Output:
Using the string: "Hello this is Greg" does this have the prefix:He?: true
and how many non-overlapping occurrances of "is?": 2
Hello 23
Hello 23
-23 int
Go-syntax representation of the value:&main.T{a:7, b:-2.35, c:"abc"}
Go-syntax representation of the type of the value:*main.T
Type:[]string Go-rep of the val:[]string{"Hello", "this", "is", "Greg"}
Hello
this
is
Greg

Also started embedding source on this blog using bitbucket's "embed" script after pushing the source code files from my local computer. I'm using gofmt, and after seeing how long my code is, I'm going to look and see if there's an option to wrap lines.
http://www.engineyard.com/blog/2009/ready-set-go/
Interfaces

Interfaces are just a collection of function signatures. Here’s an example of interface use taken from the IO library:

type Reader interface {
Read(p []byte) (n int, err os.Error);>
}

type Writer interface {
Write(p []byte) (n int, err os.Error);
}
This is nothing too earth shattering if you’re familiar with Java. If you’re used to Ruby, this is something a little different: actually having to codify the protocols to which your objects conform (see Jim Weirich’s RubyConf 2009 talk for a discussion of this).

Making the connection between interfaces and the types that implement them is just the opposite. It’s implicit—as it is in Ruby et.al.— not explicit, as it is in Java. For example here is something that can be used whenever a Reader is expected:

type limitedReader struct {
r Reader;
n int64;
}

func (l *limitedReader) Read(p []byte) (n int, err os.Error) { ... }
This example also shows declaring a variable (a struct member in this case) of an interface type.