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

Preventing Cross-site Scripting (XSS) with CakePHP 2.x

Without proper care, developers can leave their CakePHP website open to cross-site scripting attacks. Controllers using scaffold functions do not take care to sanitize data, and leaves the website vulnerable. When using the bake tool in the console, it generates controllers as simple as the scaffold version. Some suggest storing the unsanitized data and escape the dangerous characters on output. In a perfect world I would agree with this approach, but it is easy to forget to sanitize output every time, or for an amateur developer to be ignorant of the dangers.