Friday, December 18, 2015

How to base data with PostgreSQL

The world's most advanced open source database.
  1. Knowledge
    1. PostgreSQL is an open-source database.
  2. Strategy
    1. Install on AWS EC2 Ubuntu.
    2. Configure the database.
    3. A example Python script is provided.
  3. Execution

Thursday, December 17, 2015

How to store data with Druid

Fast column-oriented distributed datastore.
  1. Knowledge
    1. Druid is an open-source distributed data store, currently utilized by Netflix, Yahoo and others.
  2. Strategy
    1. Download the tarball.
    2. Dependencies
      1. Apache Derby
        1. Install the tarball.
        2. Configuration.
      2. Zookeeper
        1. Install by tutorial instructions.
    3. Run the server.
    4. Execute a simple query.
    5. Execute a complex query, fast.
  3. Execution

Friday, December 11, 2015

How to contain software with Docker

Lightweight. Open. Secure.
  1. Knowledge
    1. Docker allows you to package an application with all its dependencies into a standardized unit for software deployment.
  2. Strategy
    1. Linux
      1. Tutorial
    2. Mac OS X
    3. Windows
  3. Execution

Thursday, December 10, 2015

How to teach a machine to learn

Machine learning in Python.
  1. Knowledge
    1. Scikit-learn is a toolkit for machine learning in Python.
    2. It explains how it solves machine learning problems
  2. Strategy
    1. Scikit-learn provides a tutorial for getting started.
    2. Although, where do we even start if our application is huge, nuanced and complex? Let's use nearest-neighbor thinking to build off a similar solution! (a quick google search found it)
  3. Execution

Wednesday, December 9, 2015

How to keep secrets with Vault

A tool for managing secrets.
  1. Knowledge
    1. Vault is a data-store for your infrastructure's tokens, passwords, certificates, API keys, and generally all things secret.
  2. Strategy
    1. Installation
      1. Download and install the binary.
    2. Configuration
      1. A config file is loaded with the Vault CLI -config flag.
      2. Two fields are required, Backend and Listener.
        1. Backend is where the Vault data is stored.
        2. Listener is where Vault receives API requests.
  3. Execution

Thursday, December 3, 2015

How to monitor services with Consul

  1. Knowledge
    Service discovery and configuration made easy

  2. Strategy
    1. Installation
    2. Configuration
  3. Execution

Wednesday, December 2, 2015

How to add dynamic text to Rails applications

How can you change your application from this...
To this?
It's simple! Just use embedded ruby!

EDIT: Thanks to Action Dan for some feedback that picks into the niche differences of web application frameworks.

Bear in mind this is a Rails specific post, but I will say that for purposes of building larger applications, the ability to organize and refactor code begins to become a problem



Rails also offers uniform ways to add and remove helper functions through package management, so I'm actually using the current_user function generated by adding the Clearance gem to my project. 

The simple markup syntax is one small reason people like using Ruby on Rails to develop web applications.

Using a helper function (that I didn't even have to write) are two "behind the scenes" benefits of using Rails to develop.

If your confused about the current_user helper I'm using, read more here.

Program on!

Saturday, October 10, 2015

Software Licensing Overview (Open Source and Closed Source)

This is a cross-post from Lockboxx!! Read dat shiiii

The world of Free Software licenses and Open Source Software licenses can be massive and confusing, compiled with the endless Proprietary Software licenses (regardless if Commercial or not), it can be hard to understand from a distance. I wanted to take a second to set aside some general high level categories with examples in each camp, to give people a general / quick idea of what a license might mean and which direction they want to head. I don't mean to water down the huge world of open source software licenses, but simplify peoples approach and understanding. It should also be noted that while I am a fan of law / ethics / philosophy in computer science, I am not a lawyer. I also found a really great site to help me make my choice.

Highly permissive software licenses:
These licenses generally provide free software with few constraints on derivative works:
Unlicense
WTFPL
MITBSD
Apache 2.0

Copy Left software licenses:
Most of these have some requirement of derivative works having the same software license agreement or similar qualities:
GPL
GNU GPL 2.0
GPLv3
Mozilla Public License 2.0

Highly restrictive / special conditions licenses:
These are typically representative of specific service agreements between two individual parties:
No License (same as Copyright)
EULAs (End User License Agreements)
Proprietary software licenses

What really started this conversation for me, was that publishing public code on Github didn't give other Github users the rights I thought it did. For example, code published on Github (based on Github EULA) without a license gives other Github users the right to view and fork the code, but beyond that the code is protected under Copyright, potentially scaring many developers away. I also feel like a big part of understanding software licensing is understanding the history of software licensing. At the end of the day the choice is yours and you should make the choice based on protecting and propelling the software you care about into the world.



Sunday, October 4, 2015

Raspberry Pi Model Differences

Hey All, sometimes I get confused between all of the different Raspberry Pi models out there, so I thought I would document a few of them here for quick and easy reference. Remember that the biggest difference is the Model 1 uses ARM v6 and Model 2 uses ARM v7, so the same operating system won't run on both platforms!!

And some more facts about each model:

Pi Model 2 B

Pi Model 1 B+

Pi Model 1 B

Pi Model 1 A+ (not shown here)

Pi Model 1 A   (not shown here)

Thursday, October 1, 2015

How to be successful

Check this out, now.

He hits the mark on a lot.

Namely, when you fail, you learn.

He speaks about three things.
  1. Knowledge
  2. Strategy
  3. Execution
Seriously, watch it...

The first half is the important part.  Second half is about selling his program. lol. torrentz ftw.

How to prepare a 15 minute demo

Hey all,

I'm giving a 15 minute demonstration on ChatOps, so I'll walk through my process while I'm at it.

Fifteen minutes isn't a lot of time to demonstrate features, so I'll need to do a fairly quick overview.

There are a few main use-cases that I want to demonstrate along with an introduction and conclusion.

Whenever I want a task to go well, I build a tool that assists in the execution of this task.

For my presentations, that tool is normally a well-rehearsed slideshow.

Usually, either Google Drive or Microsoft PowerPoint is my go-to.

Using each slide as a single idea lends to presentational structure.

Well, I need to find out how many use cases I'll be focusing on, so I can start to actually build out the presentation.

Looking... (this is a process I do when I need to borrow an experts structure so my case has a stable base)

Okay, I found four target use-cases that I can make a strong case for:


These are the use-cases StackStorm has proven successful in promoting their solution with and I should be able to do the same.

4 (use-cases) + 2 (intro/conclusion) = 6 total slides

Doing that now...

Okay, after an hour or so, here's what I got:



Not bad, but I still need to go over my oral presentational strategy.

The basic idea is for each slide:

  1. introduce the overview
  2. discuss the body at a high level for ~ 3 minutes 
  3. then transition to the next slide.


And that's how to make a 15 minutes demo presentation.

Wednesday, September 30, 2015

Tuesday, August 25, 2015

Installing a Salt Minion on a Raspberry Pi

OVERVIEW:

Today I'm going to take you over some of the pitfalls and roads to success that I've encountered when trying to set up a custom Raspberry Pi device that is connected as a Minion back to a SaltStack Master.
For those unfamiliar, Salt is a powerful systems administration framework, allowing for asynchronous communication and the ability to manage tons of end points (nice salt cheat sheet).
Minions are endpoint nodes in a SaltStack, where as Masters are accessible control nodes. Putting a Salt Minion on Raspberry Pis provided us the ability to control many Pi devices with a Internet of Things / Smart Home / Automated  (orchestration) approach.

PITFALLS:

We originally approached the problem with a Raspberry Pi 1 Model B+, with a Raspbian operating system, however this proved very difficult as Raspbian would repeatedly have issues in running or reading the configuration files. This led us to try Arch for Arm on the Raspberry Pi, using the Noobs boot disk to install.

HOW-TO:

After that, installing and configuring the Salt Minion on Arch Linux was super straight forward and worked like a charm.
Later, we upgraded to a Raspberry Pi 2 Model B, for a better CPU and mode RAM, and thought we would take another shot at Raspbian, as we heard it worked better with this architecture. This was only slightly true, we were able to successfully install Salt Minions on Raspbian this time, using this method, but ultimately the Minions had issues connecting back to the Master.
Going with Arch on the Raspberry Pi 2 Model B, no longer supports NOOBS, but the installation is still pretty easy. Installing the Salt Minion on the Raspberry Pi 2 running Arch was just as simple as the first time and also just as successful, installing and connecting back flawlessly on Arch on Arm.

CONCLUSION:

So ultimately, if you are looking to run Salt Minion on a Raspberry Pi, we strongly recommend going with Arch Linux to avoid issues.

Friday, July 10, 2015

How to pick an Orchestration component

This is a fantastic comparison I found on http://www.infoworld.com

Absolutely worth the 5 minutes read. 10/10

Wednesday, July 8, 2015

Deploying Custom Amazon Images with the AWS CLI on Demand

Hey All! Today I am going to go over how to make a gold image of an Amazon EC2 instance, then deploy copies of that instance on demand with a simple AWS CLI script! 

First of all, this tutorial assumes you have already installed the AWS CLI tools on your client architecture. You will also want to create a new IAM user such that you aren't using your root credentials to hit the AWS API, and make sure this new user has enough permissions to create new instances. Make sure to use that user's Access Key ID and Secret Access Key in your AWS CLI config. Finally, we will want to have launched default AMI, configured this system like we want every subsequent system (this includes setting up the AWS access keys, security group, and subnet) , and then turn this into a custom AMI using the Web Console:


Next, we are going to launch a copy of that instance using the following AWS command line script:

ec2-run-instances ami-xxxxxxxx -t t2.medium -k my-key-xxxxx -s subnet-xxxxxxxx -g sg-xxxxxxxx --associate-public-ip-address true

And boom! This will return all the details of the new instance it has just launched in the console, making it easy to script this simple command and parse the output to chain even more automated deployment (like then ssh-ing to the server and running some updated configuration scripts)!

Saturday, June 20, 2015

How to migrate from the MySQL Extension to PDO

My team's start-up has a web application that is currently using MySQLi Extensions.

Switching to PDO has many advantages:
  • offers a consistent API to work with a variety of databases
  • exposes high-level objects for the programmer to work with database connections
  • low-level drivers perform communication and resource handling with the database server

Basic Workflow

The basic workflow for working with a database can be thought of as a 5-step process:
  1. Establish a connection to the database server and select the database you’ll be working with
  2. Construct a query to send the server
  3. Send the query
  4. Iterate over the returned result rows
  5. Free the resources used by the result and possibly the database connection
With PDO, the same process can be followed and looks like this:

















<?php
// Step 1: Establish a connection
$db = new PDO("mysql:host=localhost;dbname=testdb", "testusr", "secretpass");
// Step 2: Construct a query
$query = "SELECT * FROM foo WHERE bar = " . $db->quote($zip);
// Step 3: Send the query
$result = $db->query($query);
// Step 4: Iterate over the results
while($row = $result->fetch(PDO::FETCH_ASSOC)) {
    print_r($row);
}
// Step 5: Free used resources
$result->closeCursor();
$db = null;

Friday, June 19, 2015

How to create a StackStorm Pack

What is a Pack?

Pack is the unit of deployment for integrations and automations in order to extend StackStorm. Typically a pack is organized along service or product boundaries e.g. AWS, Docker, Sensu etc. A pack can contain ActionsWorkflowsRulesSensors.
It is best to view a pack as the means to extend StackStorm and allow it to integrate with an external systems such as Git, Google. AWS, Jenkins, etc.

Create and Contribute a Pack

Packs have a defined structure that is prescribed by StackStorm. It is required to follow this structure while creating your own pack and is also helpful to know while debugging issues with packs.
# contents of a pack folder
actions/
rules/
sensors/
config.yaml
pack.yaml
requirements.txt
In the classic Proto-Hack fashion, let's just dive right in and build your first pack!

My first pack

If you would like to create a pack yourself then follow these simple steps. In the example below, we will create a simple pack named hello-st2. The full example is also available atst2/contrib/hello-st2.
  1. First, let’s create the pack folder structure and related files. Let’s keep the metadata files such as pack.yaml, config.yaml, and requirements.txt empty for now.
# Use the name of the pack for the folder name.
mkdir hello-st2
cd hello-st2
mkdir actions
mkdir rules
mkdir sensors
touch pack.yaml
touch config.yaml
touch requirements.txt


Monday, June 8, 2015

How to continuously integrate, test and deploy

This post will walk through the steps of setting up a continuous integration server starting with a codebase from Github, automated by StackStorm.

Step 1: Deploy stackstorm on a server, following this guide.
  • There are many ways to install/deploy stackstorm, I'll be using vagrant.
  • I'm using my Windows based work computer to act as the server for this example, so vagrant is a great choice for getting things up and running.
  • First things first, clone the project, cd to the vagrant folder within, and "vagrant up" to get started!
And we're off!

Whoops, looks like vagrant was updated since I cloned the project! Let's fix that...
Great success! It's installed!

This will install all StackStorm components along with the Mistral workflow engine on Ubuntu 14.04 virtual machine. The setup will download additional packages from the internet. While waiting, check out StackStorm 101 Video for quick intro. If setup is successful, you will see the following console output.

Step 2: Create a sensor to integrate with repository commits.

Step 3: Create a rule to merge all branches into the master branch.

Step 4: Create a rule to run all test cases, and if successful, deploy to production server.

Sunday, May 31, 2015

event-driven automation architecture


Here's some original artwork by yours truly. 
Nothing much, just my take on event-driven automation architecture.


This is my personal take on modular orchestration, each node represents a partition or VM.

This bundling draws noticeably strong parallels to hypervisor technology because that's where orchestration (event-driven automation) was born.

Here's an example of setting up infrastructure for a project.

PHYSICAL INFRASTRUCTURE
  • only 1 user? -> pick an architecture, install an operating system
  • >= 2 users? -> pick an architecture, install a hypervisor, install additional operating systems 

VIRTUAL INFRASTRUCTURE
  • only 1 role? -> pick an architecture, install a wizard
  • >= 2 role? -> pick an architecture, install an emperor, install additional wizards
Seems simple enough!