Install Google’s Go programming language using a proxy

Installing the Go Programming Language is pretty easy, but can be a pain when done behind a firewall and there isn’t one page with all the information necessary. So, here is the one page.

For step: “$ sudo easy_install mercurial”

“mercurial” is probably already in your favorite distro, it is for debian at least. So instead of using the easy_install script, try your distro’s package management app. For debian, apt-get install mercurial did the trick.  If you insist on doing it manually, you might need a proxy statement in your env like:

export http_proxy=”http://user:pass@myproxy.example.com:1234/”

For step: “hg clone -r release https://go.googlecode.com/hg/ $GOROOT”

You should probably have an .hgrc file with proxy information in it, including the user name and password for the proxy (be sure to take the credentials out again after install, and only put em in when using hg again)

———– .hgrc with just the minimum necessary contents —————-
[http_proxy]
# Used to access web-based Mercurial repositories through a HTTP proxy.

host=myproxy:1234

passwd=mysecretpassword

user=myuser
——————————————————-

For step: “$ ./all.bash”

At the moment there are tests ran during the build, requiring network connectivity. There is discussion on the go-nuts mailing list about fixing it,  but until then removing “http” and “net” from tests in the make file:

$GOROOT/src/pkg/Makefile

will get you “Go”-ing again.

To do this, search for NOTEST and add entries “http\” and “net\” to the end, using tabs for the indentation. The complete list should look like the following when complete:
NOTEST=\
debug/proc\
exp/draw\
go/ast\
go/doc\
go/token\
hash\
image\
image/jpeg\
malloc\
rand\
runtime\
syscall\
testing/iotest\
xgb\
http\
net\

I love reading and writing Regular Expressions

Reading and writing Regular Expressions is the only time I feel I do what people think computer programmers do.

s/(R\w{6}([ ](\w{2,11}|I)){18}\.)/It is like magic\./g

Batch resize images with imagemagick (convert)

I am often asked how to resize a directory full of images, for free. This is definitely possible and probable there are many ways to do it, but I like to use ImageMagick for this. ImageMagick is available for almost any OS here:

http://www.imagemagick.org/script/index.php

Here is an example of converting a directory of JPEGs using a little scripting and imagemagick:

for i in $( ls *.jpg); do convert $i -resize 1024x768 sm_$i; done;

For loop in bash (can be used on command line or in script)

There are so many versions of Bash around and it can be frustrating, to me at least, to do some things for not knowing what is available on a given machine. Well here is one, the for loop. Here are a few different ways to do the same thing (and I am sure there are many others) . The first two below work on current linux machines but only the third works on Solaris 5.8′s version of Bash. Enjoy

for ((i=0;i<=5;i+=1));  do echo anda$i; done;
for seq 6 7;  do echo anda$i; done;
for i in 8 9 10 11 12; do cvs tag -d  anda$i; done;

use vi editor to insert newline char in replace

Something else I have to do and cannot remember and then have to look up.

In vi to insert a newline character in a search and replace, do the following:

:%s/look_for/replace_with^M/g

the command above would replace all instances of “look_for” with “replace_with\n” (with \n meaning newline)

to get the “^M”, enter the key combination “ctl-V” then after that (release all keys) press the “enter” key.

Get PS to display the complete path (on Linux)

Something else I can never remember and waste time looking up is how to display long long long paths when looking at processes with “ps”. Well just a couple of “W” does the trick.

ps -auxww

More on why, later but wanted to put it down while it was fresh

Follow

Get every new post delivered to your Inbox.