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

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.

Customizing Gnome 3 Desktop Environment in Arch Linux

Arch Linux is known for being a lightweight do-it-yourself distribution. Unlike some other distributions like Ubuntu and Linux Mint that come with a preconfigured desktop and all the programs installed, Arch Linux let's you build things up from the ground up yourself. For the uninitiated this can be an intimidating task, but it's not that once you wrap your mind around it. I'm going to go over customizing a Gnome 3 desktop environment including icons, cursors, themes, wallpapers, etc.

Customizing Openbox Window Manager in Arch Linux

This article will walk through all the steps needed to create a unique and personalized desktop. I'll cover fonts, icons, mouse cursors, GTK themes, Openbox themes, Openbox menu generation, wallpaper and system monitors. In my example I will will make references to packages contained in Arch Linux. The same packages should be available for any popular Linux distribution, although the names may change slightly.

Installing, Configuring and Customizing Arch Linux

Arch Linux is a great distro that boasts bleeding edge up-to-date rolling releases as well as a very light and efficient base install. There is no graphical install and it expects you to have some basic Linux chops already just to perform the installation. Beginners shouldn't be scared away though because Arch Linux has a great wiki and awesome documentation.

Installing and Configuring FreeNAS 8.3.1

FreeNAS is a great option for home or enterprise level network attached storage(NAS.) It is based on FreeBSD so it benefits from many of the unique BSD tools like jails. Jails are a secure way of segmenting a process. The plugins available run in jails to help with security. Installing FreeNAS itself is as simple as following the prompts. I'm not going to cover the base installation because it is simple, but will focus more on the post-install configuration. Note that the drive you install FreeNAS to can't be shared over the network.

AJAX Pagination and Sorting with CakePHP 2.x

CakePHP comes with a core JsHelper that allows a developer to call PHP functions that will create the JavaScript using a number of libraries including jQuery and Prototype. Pagination in CakePHP is a very common task and it can be enhanced using AJAX. Fortunately the Pagination component/helper are built to handle the AJAX. You can set the pagination defaults in the controller with the code below. Alternatively you could set specific elements of the array inside an action with a call like $paginate['conditions'] = array();

Living Without Adobe Flash Player

Richard Stallman founded the GNU Project and the Free Software Foundation. They have done a lot for the free software movment. Richard Stallman has a pretty hardcore philosophy and he is quite a character, but he is the leading role model for living life with only free software. For example, he uses a specific laptop brand because he wants to use a free bios. He doesn't use a cell phone because there are no totally free phones available. He is willing to make sacrifices to avoid something he has deemed unethical.

Exchange 2010 Calendar and Mail with Thunderbird

There is a way to get your exchange mail and calendar in Thunderbird, however I'll be honest I still had issues with the calendar after doing all of this. The calendar would load once, but then not load again. I'm going to provide this for reference. Perhaps in the near future some bugs will be sorted out in these addons, and maybe someone will have a comment on the configuration. I have included specfic versions numbers. If you want GOOD Exchange 2010 support, I recommend using Evolution.

Web Scraping Tutorial in JavaScript (Node.js)

Node.js is, according to their website, "a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices." It is essentially a javascript interpreter for the command line. With Node.js, you can write scripts in JavaScript just like you would with PHP and Python.

Advertisement

Advertisement