Application deployment and Docker

One of the more challenging parts of working in software business is getting your application deployed and working correctly. I came across a new tool that promises to ease the process.

Docker is an open-source tool that automates the deployment mechanism of an application as a portable and self-sufficient container that will run on corresponding architectures (Linux).

It promises to deliver build the container once and deploy anywhere i.e. dedicated server, laptop, VM or OpenStack clusters. The big sell for the developer is an easy to use and repeatable deployment mechanism for deployment of applications to any suitable target.

I’ll investigate Docker and write an in-depth post.

Installing VoltDB on Ubuntu 13 (64 bit)

VoltDB is an example of a NewSQL type of database, it’s based on the H-Store DBMS.

This is an example of how to get going with VoltDB on Ubuntu 13 (64 bit only), This is assuming a pre existing installation of Ubuntu 13 64 bit edition.

1) Register and download the software on the VoltDB website, I’ve selected the VoltDB Open Source Edition Download for Linux. There is an Enterprise edition which offers a wider feature set.

The zip archive is named: LINUX-voltdb-3.7.0.4.tar.gz

2) Copy the file to your installation directory, I’ve chosen /opt

Change directory to /opt: cd /opt

3) Inflate the archive file

Use the command: tar zxvf LINUX-voltdb-3.7.0.4.tar.gz

4) Check the prerequisites are installed

Install aptitude

apt-get install aptitude

Install the build essentials package

aptitude install build-essential

Install a Java jdk (openJDK in this instance)

aptitude install openjdk-7-jdk

5) We should be able to run the VoltDB demos, the voter demo in this instance:

Open the file: file:///opt/voltdb-3.7/tools/demo/index.htm in your browser

To run the Voter demo:

Start the Server: sh /opt/voltdb-3.7/examples/voter/run.sh

Start the client: sh /opt/voltdb-3.7/examples/voter/run.sh client

Volt1

Open the performance monitor to view the running demo application: file:///opt/voltdb-3.7/examples/voter/LiveStats.html

Volt2

View the data via SQL queries with the built in studio file:///opt/voltdb-3.7/tools/studio.web/index.htm?startup=query – You can issue SQL queries against the VoltDB database.

Volt3

C# .Net indexed foreach

A quick demo on how to use an indexed foreach in C#.

using System;
using System.Linq;

namespace CsharpIndexedForeachDemo
{
    class CsharpIndexedForeachExample
    {
        static void Main()
        {
            // Create a range of integers
            var myRange = Enumerable.Range(0, 100);

            // Iterate over range
            foreach (var i in myRange.Select((x, i) => new { Value = x, Index = i}))
            {
                Console.WriteLine(i.Index);
                // Break on 10 results
                if (i.Index >= 10)
                    break;
            }
            Console.ReadKey();
        }
    }
}

JavaScript check if a variable is defined

A good way to check if a variable has been defined is to make use of JavaScript typeof:

<script type="text/javascript">
    var varA = "Hello World!";

    if (typeof varA !== "undefined") {
        console.log("Defined");
    } else {
        console.log("Undefined");
    }
    
    // Undefined variable
    if (typeof varB !== "undefined") {
        console.log("Defined");
    } else {
        console.log("Undefined");
    }
</script>