Thursday, December 31, 2009

gvim - fatal error: can't find import: fmt?

I have setup go related environment variables in my ~/.bashrc as follows


When I compile from vi (:make) in terminal, everything is fine. However, when I do the same from gvim (window), I was getting

fatal error: can't find import: fmt

A quick google search pointed me to this

So, gvim is not seeing those environment variables. I confirm in gvim with

:echo $GOROOT

Reports an empty string. So I edit $MYVIMRC (:e $MYVIMRC) and add the following

:let $GOROOT='/home/amitava/go'
:let $GOARCH='amd64'
:let $GOOS='linux'

Worked like a charm!

Wednesday, December 30, 2009

My exploration of Google "go" programing language

1. return
Named return variables are available within the scope of the function. Consider the following funciton

func SomeFunc() (foo int, bar int) {
// notice how foo and bar is already defined in the body and a return w/no arg returns those values
foo = 10
bar = 20
return // compiler knows it has to return foo & bar

2. Type Assertion (ala dynamic_cast)
Given an interface type, it can be coerced to another interface type (at runtime) provided the underlying type supports both the interfaces

Look for type assertion here (Go For C++ Programmers). You have to scroll down to the relevant section. Just use browser search - use type assertion

3. defer - a piece of code to run when the surrounding function returns. Cool feature! See Here

4. dot import

Import declaration Local name of Sin
import . "lib/math" Sin (as opposed to math.Sin)

See go-doc - import

Sunday, December 13, 2009

Xen block device

While reading "The Book of Xen", I ran into a snag with attaching a block device in dom0

# xm block-attach 0 duncan. img /dev/xvda1 w 0

I am expecting /dev/xvda1 to show up now, but it doesn't. As suggested in the book, I try

# /mknod /dev/xvda b 220 0

Doesn't work (btw, the book has a typo, it should be 202 not 220)

Turns out, the xenblk kernel module was not loaded. Do this
# modprobe xenblk
# lsmod | grep xenblk

Now xm block-attach works like a charm

Monday, November 9, 2009

ssh - authorized_keys (password-less login)

Gotta make sure the permissions are the following

[amitava@collab ~]$ ls -ld .ssh
drwxr-xr-x 2 amitava amitava 4096 Nov 9 12:27 .ssh

[amitava@collab ~]$ ls -l .ssh
total 8
-rwx------ 1 amitava amitava 611 Nov 9 12:26 authorized_keys

Monday, July 20, 2009

Thursday, July 16, 2009

mini mac - can't eject cd while trying to install ubuntu

I was trying to install x86_64 version of ubuntu 9.04 server on my mini mac. However, mac mini can't handle x86_64 and needs i686. But now I can't eject the cd and I am stuck. After some googling I found out that you need to keep the option key pressed while booting up. This brought up a menu allowing me to boot off the hard-disk. Phew!

I found this today (07/20/09) - while booting up press the mouse button to eject the media from your CDROM drive

Thursday, July 9, 2009

X11 port forwarding in macosx

I am running KVM virtual machines on ubuntu server host (on a mini mac). To gain access to the VM console from my macosx client, I use ssh X11 port forwarding like below

$ ssh -Y myhost

From within this ssh session, I run
$ xvncviewer

The Y option from man pages brings up the following:

-Y Enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.

Sunday, February 8, 2009

Batch compile elisp files in emacs

emacs -batch -f batch-byte-compile *.el