In this post I’ll be going over how to install Sublime Text under Ubuntu and add in the plugins for GoSublime and GoToDoc which add in enhancements to Sublime for the Go programming language. First you’ll want to download Sublime itself: http://www.sublimetext.com/2

Once that’s done, open up a command line and unpack and install the files. In the below I’ll be assuming Sublime was downloaded into Downloads and I’ll be installing it under /opt/

cd Downloads
tar xvfj Sublime\ Text\ 2.0.1.tar.bz2
sudo mv "Sublime Text 2" /opt/Sublime_Text_2

Next add /opt/Sublime_Text_2 to your PATH in ~/.bashrc

echo "export PATH=\$PATH:/opt/Sublime_Text_2" >> ~/.bashrc

source ~/.bashrc

You’ll now be able to start up the software simply by running the command: sublime_text

The base Sublime install doesn’t include good support for Go. For that you’ll need a couple of external packages. To make these packages easier to install you’ll want to install something called Package Control. Package Control allows you to easily install packages from within Sublime.

Open up Sublime and press the Control key plus the ` key. This will open up the Sublime console. Copy and paste the below into it:

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'

Once that’s done you’ll be prompted to restart Sublime. Now that you have Package Control installed you can install GoSublime and GoToDoc. Fire up Sublime again and press Control Shift and P. This will bring up a text prompt at the top of the screen. Start typing in Package and choose the Package Control: Install Package from the drop down list.

Choosing that will prompt you for a package to install. Start typing in GoSublime and choose that.

GoSublime requires two other packages to handle syntax highlighting and other Sublime features. Press Control Shift and P again and start typing in “GoSublime: Install/Update MarGo and Gocode” and choose that.

Once that’s done we can install GoToDoc. Press Control Shift P again, start typing in Package, choose Package Control: Install Package and when prompted for the package to install start typing in GoToDoc.

For an example on how to use these plugins open up a simple “Hello World” hello.go file. Once that’s open in Sublime press and hold the Control key, then press comma and then R. That will run the code.

Most command for GoSublime use Control plus comma plus something else. You can see a list of what you can do by typing Control Shift P and start typing in GoSublime. That’ll give you a list of GoSublime functions and the hot key combinations to run them.

To use GoToDoc simply highlight a package name in the file(like fmt for example) and press Control Alt E. That’ll bring up a window in your web browser that goes to the documentation for that package. GoToDoc also has a Control Alt L function, but that conflicts with Ubuntu’s screen locking. So if you want that functionality(read more on it on the GoToDoc page) you’ll either need to remap it or remap Ubuntu’s screen locking.

In this post I’ll be going over how to setup Google’s Go in Ubuntu 12.04 64bit version. If you follow these steps you’ll have the build tools for Go installed which can compile for 386 or amd64 systems.

First you’ll need to install Subversion, Git and Mercurial which Go uses to download packages. In addition you’ll need some basic C build tools installed which will be used to compile Go itself. From the command line run the following:

sudo apt-get install mercurial git subversion gcc libc6-dev libc6-dev-i386

Next make sure you’re logged in as your normal user account. Add the below to your .bashrc file:

#This line will tell the Go installer where to place the source code before compilation
export GOROOT=$HOME/go

#With this line, you choose the architecture of your machine.
#Those with 64 bit CPUs should enter "amd64" here.
export GOARCH=amd64

#Your operating system
export GOOS=linux

#And now the location where the installer will place the finished files
#Don't forget to create this directory before installing
export GOBIN=$GOROOT/bin

#Include Go binaries in command path
export PATH=$PATH:$GOBIN

When you do the above either run “source ~/.bashrc” to load the new settings or close and re-open a new terminal window.

Now you can install Go itself:

cd ~
hg clone -u release https://code.google.com/p/go

cd go/src/
./all.bash

cd ~

This should install the basic Go build tools. Test this by putting the below code into a hello.go file:

package main

import "fmt"

func main() {
fmt.Printf("hello, world\n")
}

And then compile and run it:

go build hello.go

./hello

The above will have created a 64bit binary. But we can also setup Go to be able to compile i386 binaries:

cd ~/go/src/
GOARCH=386 ./all.bash

Once that’s done, go back and re-compile hello as an i386 binary:

cd ~
GOARCH=386 go build hello.go

Note that this binary will still run on your 64bit Ubuntu system since you have 32bit compatibility libraries installed on your system.

I’m not a heavy programmer. I started in on it back in the 80’s and made a split career of programming and building systems in the 90’s, but by the mid 2000’s I went off into Systems Engineering and focused on “programming” large scale virtual server environments. Most of my job revolves around writing code to automate the monitoring and upkeep of these systems. For this level of work interpreted languages like Perl, Python and Ruby work just fine. I also work with developers in helping them deploy their code into production and again for most of what they do the “easy” languages of Perl, Python, Ruby and PHP work very well. I’d also place Java in that lineup, for while it compiles down to bytecode the JVM is really just another interpreter and the language is a far cry from the heavyweights of C and C++ that compile down into native code. The Java, Ruby, Python, Perl and PHP kids are all eating at the same table in the cafeteria while the C and C++ guys sit with their long beards in the corner arranging their peas into organized rows before eating.

One big problem with interpreted languages is deployment. A prime example is one tool I’m dependent on for day to day work, Puppet. Puppet is a program that runs on each server and checks into a master server. It downloads scripts from the master server and runs them. This let’s a sysadmin install software, add users, create cron jobs and a lot of other things across hundreds of servers simply by changing a single config file on the master server. It’s an invaluable tool and is a good use example of software written in Ruby. It doesn’t have to run quickly, it doesn’t have to have a small footprint, it just needs to work well. Which is does, many companies use it including Google.

But it’s also a good example of what’s bad about languages like Ruby. If your OS is say, CentOS 5, it may ship with Ruby version 1.8.5. This version of Ruby causes a problem with Puppet which ends up with the program gobbling up ram. So you need to upgrade to 1.8.6 which requires adding the EPEL repository for CentOS/Red Hat. On the other end of that, the newest version of Ruby is 1.9 and soon you can expect distributions to ship with it. Only Puppet doesn’t work with that version of Ruby yet. So in order to use Puppet you need this narrow window of Ruby which may or may not be easy to install on your platform of choice.

Pretty much all of the interpreted languages suffer from this. Java can break if you’re not using the right JVM. Python and Perl are pretty safe with the core interpreter, but any software you run that uses either will depend on outside libraries. PHP is the same way, depending on php-mysql, PECL, or any number of extra library addons.

Enter Go. Go is a new language released by Google that has its foundation in C but is modernized. In use it feels a lot like the newer interpreted languages, but it compiles down to native code like C and C++ do. It comes with a rich standard library which has been the foundation for people writing new libraries for MySQL, SSH, SNMP, web frameworks and so on. The language works very well with threading, is strongly typed but doesn’t require you to be wordy with it, is garbage collected, compiles quickly, and statically links all compiled binaries. And it’s that last bit which makes the language really interesting.

Here’s your standard Hello World program:

package main

import "fmt"

func main() {

fmt.Println("Hello World")
}

Building and running it looks like this:

$ go build hello.go
$ ./hello
Hello World

I can take that compiled hello program and run it on any 64bit Linux machine. I can even compile it for 32bit platforms on my 64bit machine if I wanted to. It doesn’t depend on any outside library. No, really:

ldd hello
not a dynamic executable

But let’s get a little more complicated. Let’s write a program that queries a remote database using a 3rd party MySQL library written in Go: https://github.com/ziutek/mymysql

package main

import (
"os"
"github.com/ziutek/mymysql/mysql"
_ "github.com/ziutek/mymysql/native" // Native engine
)

func main() {
db := mysql.New("tcp", "", "192.168.177.225:3306", "testuser", "TestPasswd9", "test")

err := db.Connect()
if err != nil {
panic(err)
}

rows, _, err := db.Query("select * from a where id > %d", 20)
if err != nil {
panic(err)
}

for _, row := range rows {
for _, col := range row {
if col == nil {
// col has NULL value
} else {
// Do something with text in col (type []byte)
}
}
// You can get specific value from a row
val1 := row[1].([]byte)

// You can use it directly if conversion isn't needed
os.Stdout.Write(val1)

}
}

So here this program is using the MyMySQL library to connect to a remote database on 192.168.177.225 and run a select query. Pretty standard stuff and it builds and runs like:

$go build mysqltest.go
$./mysqltest
4042

Like I said, pretty standard stuff. Let’s look what this software depends on:

$ objdump -p mysqltest | grep NEEDED | awk '{print $2}'
libpthread.so.0
libc.so.6

I basically just need 2 standard core C libraries to run this app. I don’t even think Linux will boot without these libraries. I don’t need MySQL libraries at all to run my MySQL program. As an example I can throw this app on another machine without the MySQL C libraries installed:

# rpm -qa | grep -i mysql
# ldconfig -v | grep -i mysql
ldconfig: /etc/ld.so.conf.d/kernelcap-2.6.18-194.26.1.el5.conf:6: duplicate hwcap 0 nosegneg
ldconfig: /etc/ld.so.conf.d/kernelcap-2.6.18-238.9.1.el5.conf:6: duplicate hwcap 0 nosegneg
ldconfig: /etc/ld.so.conf.d/kernelcap-2.6.18-238.el5.conf:6: duplicate hwcap 0 nosegneg

# ./mysqltest
4042

Keep in mind that I can’t even run a C program that uses MySQL without libmysqlclient.so being installed on the system. But Go doesn’t care.

This is where I think Go really becomes interesting and wins out against other languages. Imagine deployments where all you care about is 32bit or 64bit. You don’t need libs on your target machine, you don’t need complicated deployment systems that make sure a target machine has X, Y and Z. You simply build a binary and can push it out to anything built in the last decade.

Go brings along a lot of other advantages if you’re coming from an interpreted background. Compiled code is always going to be faster than interpreted(though at the moment Go’s speed is still being worked on) and it has extremely good threading support, something which a lot of interpreted languages are pretty bad with. On the down side it does away with certain concepts in the name of simplicity and code readability(generic types and polymorphism being two examples) and while it has a pretty solid core library it still lacks the decade of tools and libs that other languages have built up.

Creating your own POGs

Rather than invest a lot of money in minis I’ve come up with a cheap way to create my own POGs, which are small little disks you can use for tabletop games. To make them I use , a standard ink jet printer with 67lb paper and a 1 inch hole punch.

First you’ll need to find some suitable images. I usually use Google image search, although Deviantart has a lot of good drawings.

Open up your image in Gimp and the first thing you’ll want to do is change the print size to be 300. This will ensure that everything you do matches up properly for when you go to print things out.

After changing the print size, select the circle select tool, click on Fixed aspect ratio and change the size measurement to inches.

Use the select tool to create a 1 inch circle. Odds are the circle won’t match up with what you want your POG to look like.

In that case, you’ll need to resize the image. Go to Images->Scale Image and make the image larger or smaller as needed. In this case I’ll be making the image 50% smaller.

Once the image is scaled re-draw your select circle. Keep re-sizing the image until it fits the way you want it to in the 1 inch circle.

Once it fits properly, go to Image->Crop to Selection and then Select->Invert. Click on the eraser tool, choose a larger brush size and erase all the edged of your circle. Because of the inverted select tool you won’t be able to erase your POG, just the edged, so this is quick and easy to do.

This gives you one side of your finished POG. Go ahead and save this as a PNG file. I also like to do a reverse side of the POG and since I’m using Savage Worlds right now I have the flip side of the POG be for when the character is shaken. For this I go to the Text tool, choose Sans Bold, up the font size to 60 and choose either red or yellow for the font color. I then write SHAKEN into the tool and position it on the POG.

I then save that version of the POG as another PNG file.

After creating several POGs that I want to print out, I’ll create a new file using the US-Letter template.

Then I’ll open up all my POG images, the normal and shaken versions, and for each image I’ll do an Edit->Copy on it. After that, select the brush tool.

On the right hand side of Gimp you can select your brush. One of the brushes will be your copied POG.

Select it and stamp it out onto your US-Letter blank sheet. Do the same for all your other POGs and stamp them all out on your sheet.

Once your done with that you can print the entire sheet out to a PDF file. Choose File->Print, select to print to a file, PDF and give it a filename.

After that you can open up your saved PDF file and print it to your printer or send it off to Staples to be printed for you.

Once you’ve printed out the sheet you can punch them out and glue them onto 1 inch disks. You can buy 1 inch washers from Home Depot or your local arts and crafts store should have wooden disks. The craft store will also have other sized disks so you can make 1.5, 2 inch or even 3 inch POGs if you want to make larger monsters. Normal stick glue works fine and you can re-use the disks simply by soaking them in water which will remove the glue.

And the finished POGs:

TokenLab for Maptools, part 2

I’ve put together a new screencast for using Herolab, Tokenlab and Maptools using better screencast software and showing off some more of Maptool’s features.

Maptools and Tokentool can be downloaded from RPTools.net

HeroLab is one of my “must have” tools for Pathfinder and it can be found at Hero Labs

TokenLab can be downloaded from the TokenLab Github Homepage and the 2 gig torrent full of mapping objects(CSUAC) shown in the tutorial can be downloaded from RPTools Tutorial Downloads

TokenLab for Maptools

In the Virtual Tabletop gaming space there’s two big players: Maptools and Fantasy Grounds 2. Maptools is an open source project put together by the folks at rptools.net while Fantasy Grounds is a commercial product put together by Smiteworks LTD. Both are great ways to play a pen and paper RPG online, but neither is very newbie friendly to get up and running with.

But if you’re playing Pathfinder and own Hero Lab you can use a new 3rd party tool called TokenLab to get up and running with Maptools pretty quickly and effortlessly. It allows you to create PCs, NPCs, and even use Hero Lab’s bestiary and convert them into Maptool.

To show how easy it is to work with TokenLab and Maptools I’ve created a quick little demo on their use. This tutorial will cover exporting an encounter from Hero Lab, using TokenTool to create a POG(a picture you’ll drag around on the map), using TokenLab to put the two together and then how to run a quick encounter in Maptools.

The player will show in this paragraph


Maptools can be found at RPTools.net while TokenLab can be found at TokenLab Github Homepage.

If you want to download this video, right click and save the full version onto your desktop and watch it there.

I live on a boat and I love living on a boat. There’s nothing better than coming home after a hard day’s work to a view of the gentle swaying of sailboat masts in the wind, the sound of sea birds and the crisp smell of salt in the air. The weekends are even better. Nothing beats lounging around in the cockpit of your own sailboat reading the latest rpg book or novel on a cool afternoon day.

But some aspects of living on a boat sucks. For one, the internet access is… interesting. I get free internet from the marina and it’s high speed, but it’s wifi. That means to get it on my boat I need a high power wifi antenna. These antennas are around 20-30 times more powerful than what you have in your laptop and I can mount it externally. Nothing helps your signal reception more than having a high powered, cancer causing antenna on top of a 45ft mast. But the device has its own firewall. Also, since I like to use my latop without a cord and I have a wireless tablet, I have a Linksys wireless router on my boat that gives me my own local wireless LAN.

So I have 3 firewalls before I hit the internet. My own linksys router(which I can control), the high power ranged ship antenna(which I can’t tune) and then the marina’s firewall that sits right on the internet itself. Needless to say this makes hosting my own games a little awkward.

But I also have my own public internet server. It’s a cheap little $5 a month virtual private server. You can’t do much with it, but it’s great for hosting things like Teamspeak, sharing files and putting up blogs that no one will ever read. The other thing owning a small little server like this on the internet lets you do is bypass firewalls for hosting games.

There’s lots of complicated and neat ways to do this. For Linux I use OpenVPN and create my own private little network across all my systems. Unfortunately while I’m a Linux guru my Windows kung fu is lacking, so this setup didn’t work as well for me when I’m logged into Windows at home. Fortunately there’s a very simple way to handle this in Windows using a simple tool called Putty.

Putty is a SSH client. SSH is a way to log into remote servers. It’s been around for over a decade and is a more secure replacement of an older tool called Telnet. One of the neat things SSH can do is called tunneling. For example, I can log into a remote computer over SSH and start up Firefox and have the window show up on my local computer. In that case, SSH is tunneling the graphics protocol(called X in Linux).

But in our case what we want to do is use SSH to tunnel remote connections to port 1802 from the server to our local computer.

SSH Tunnel

How this works is we’ll use Putty on our home Windows computer and SSH into the remote server. Then SSH on the remote computer will take incoming requests to port 1802 and funnel them though port 22 on SSH to us at home. Then at home Putty will forward those request to port 1802 on our local computer, which is where Fantasy Grounds runs. In this way people can point their Fantasy Grounds client at tarsis.org and it’ll connect to our home PC as long as we keep that SSH connection up and running.

First we need to make a change on the destination server. There’s a file called /etc/ssh/sshd_config that exists on Linux servers running SSH. You need to edit this file and add the below line to it:

GatewayPorts yes

This will allow Putty to open up a remote port on the server and listen for connections. Once that’s done and you restart your SSH service, we can then go back to our client home PC and configure Putty.

If you haven’t already, download and install Putty: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Next we’ll start up Putty and configure the host information we’ll be connecting to.

Putty host configuration

 

In my case, my server is tarsis.org. Once that’s done, on the left hand side find Connection -> SSH -> Tunnels

Setting up the remote tunnel

 

In this tab, you’ll want to enable “Remote ports do the same”, put 1802 in the Source port field, put “localhost:1802” in the Destination field and select Remote.

This is telling Putty we want to open up a port on the remote end, allow any connection to it and then forward it back to the home PC on port 1802.

Click Add

The reverse tunnel added

 

We now have the reverse tunnel configured. You can click Open and a Putty window will open asking you to log into the remote server. Note that if you don’t want to set this up every time you start Putty, you’ll need to go back to Sessions on the left hand tab and save this session so you can reload it the next time you open Putty.

Once you open the Putty session and log in, you’ll now be redirecting port 1802 back into your home PC from the server.

Connect to the server

 

For my example, I’ll first start up a copy of Fantasy Grounds and load a campaign in DM mode. Then I’ll open up another copy of the game and choose to join in on a game. For the connection window I’ll use my public server as my Host address(tarsis.org).

Two copies running

 

And as you can see, I can connect in and join the game over the public server IP.

The nice thing about this setup is that it can be done with any public Linux server that you can configure SSH on. This allows you to publicly host your Fantasy Grounds games through firewalls from your home PC without forcing your players to setup and use a VPN client. The only downside is if your Putty session closes you’ll lose your tunnel and all your client connections.