Advertisement

Advertisement

2D Arrays and Slices in Go

Two dimensional arrays and slices are useful for many situations. When creating an array in the Go programming language it is automatically initialized to the empty state, which is usually a 0. Arrays cannot be expanded. Arrays live in the stack and take up space in the compiled executable. Arrays are also passed by copy whereas slices pass pointers. Slices require a little more initialization at first but are more versatile. You can grab subsets of the arrays if needed, access elements directly, or expand the slices. Slices are thin wrappers around arrays and hold pointers to the array. They are initialized during run time and live in the heap.

Using .tpl Template Files in Custom Drupal 7 Modules

In Drupal 7 the theme and template layer can easily be over complicated, but this is the quickest and most effective way in my opinion to get started using template files in your custom modules. Get in the habit of using a template file instead of putting pieces of HTML inside your module code. This system is pretty flexible and you can create a template for a small item or for a whole page.

Arch Linux VPS Host Options

Arch Linux is my preferred Linux distribution. Not many of the VPS providers offer Arch Linux though. Here is my review of three options. It is worth mentioning that using Arch Linux for a critical server that needs to stay up is generally not recommended. Updates are frequent and they sometimes come with big changes. There are situations where the only way to fix something that breaks after an update is to read the news on the Arch Linux website. CentOS and Debian are good reliable choices.

Unit Testing TCP Server & Client with Python

Unit testing a TCP server and client can be tricky at first. Let me share what I've come up with for unit testing them. I will not provide full test class code just invidual test methods. If you don't know how to use unittest with Python and get your tests running refer to the unittest documentation. GameServer.Server and GameClient.Client are the classes that are being tested and which should be implemented elsewhere.

Beginner Lisp Programming

Lisp goes back to the 50s and was popular in the 80s. It is one of the oldest programming languages. According to Wikipedia, Fortran is the only high level programming language older than Lisp. There were many dialects back then, but Common Lisp is the dialect of our age. It has been called the programmable programming language. It has a very interesting history.

How to Write Command Line Tools

The shell is a powerful tool that I think most people underestimate and under-utilize. Bash is probably the most common in the community, so we will refer to bash in all the examples, but all shells should support the same concept of redirection and piping. Below are some things to keep in mind when writing a program that is intended to run on the command line and play well with the shell.

HTML Templates in Go

Here is a quick example of how to use Go's html/template package to loop through a slice of structs and print out the contents. Note that in the templates {{.}} prints all the template variables, and . refers to the data passed.

type Person struct {
  var Name string
  var Age int
}

Simple struct definition for our Person

Why I Like Go

I think Go is a well designed and fun language to use. The standard library is pretty amazing, but here are a few things I like about Go. At the end are several references and links if you want to learn more about Go! Also check out my code snippets and references on GitHub github.com/NanoDano/reference

Advertisement

Advertisement