<commit_before>---
layout:     post
title:      "1.3 Virtualization, CoreOS, and the command line"
subtitle:   "The tools and knowledge you'll need to work on your local machine."
date:       2015-03-29 12:00:00
author:     "Dcycle"
header-img: "img/post-bg-01.jpg"
class:      1
parent:     "<a href=\"/class-01-basics\">Class 1: Basics</a>"
---

Virtualization
-----

In lesson 1.1. we saw how to set up our first project and make changes to it. This was all done on the GitHub web interface, which has its limitations.

The next logical step is to figure out how to develop (i.e. make changes to a project) on your local machine.

However, everyone's local machine has different operating systems, different software, end even when two developers have the same software, they often have different versions of the same software, or the software is configured differently.

This is a headache that we will completely remove from our workflow by using virtualization: the only required software you need to install on your machine is the software which will allow you to launch _virtual machines_.

Think of virtual machines (VMs), as well as more lightweight "containers" (we'll see the difference later on), as temporary, virtual computers which run on your laptop.

VMs and containers are "guests", and your laptop is the "host".

Guests are isolated from the host, which means whatever you do on the guest won't affect the host; if you screw something up on the guest, you can simply destroy it and start from scratch. Likewise, if you must update software on your host computer, it won't affect the guest; If you lose your computer, all you need to do to get up and running again is find a new computer, install the few pieces of software we will introduce in this lesson, download whatever site it is you're working on, and get on with your job.

In this approach, whatever it is your software requires to run properly (a webserver, a specific version of PHP, etc.), is defined along with your software itself. This same information can then be used to set up local development environments, but also testing and production environments. This approach is known as DevOps and will save you dozens, even hundreds of hours in the coming years. (DevOps is a contraction of _development_ and _operations_, and aims to bring together two traditionally separate aspects of software creation: the code---development---and the servers and environments---operations).

Let's get started!

Installing Vagrant and VirtualBox on your local machine
-----

Whether you are running Mac OS, Linux, or Windows, you only need to install the following open-source software on your machine in order to develop anything we'll touch upon in this course:

 * **VirtualBox**, which allows you to create Virtual Machines on your laptop.
 * **Vagrant**, a command-line interface for VirtualBox (we want to move away from graphical user interfaces and do most of our work on the command line, like professionals).
 * **coreos-vagrant**, A virtual machine running a system called CoreOS and created with Vagrant.
 * A **plain text editor**, to allow you to edit plain text (unformatted) files. This is essential to write and edit code.

VirtualBox
-----

[VirtualBox](https://www.virtualbox.org) allows you to easily simulate any number of computers (limited only by your system RAM and storage) running on your host computer.

Install it [using the installation instructions for your platform](https://www.virtualbox.org/wiki/Downloads) and look for help (as discussed in the previous lesson), then [file a support issue](https://github.com/dcycleproject/dcycleu/issues) if you get stuck.

Vagrant
-----

[Vagrant](https://www.vagrantup.com) is a command-line wrapper around VirtualBox, among other things.

Download and install it [using the installation instructions for your platform](https://www.vagrantup.com/downloads.html).

Make sure you can open the `Terminal` application which comes with your Mac OS or Linux computer, or, on Windows, the Command Prompt (Windows users might have to install more software like PuTTy -- [more info on Vagrant for Windows here](http://www.sitepoint.com/getting-started-vagrant-windows/)), and type:

    vagrant up

You should be seeing something like:

    A Vagrant environment or target machine is required to run this
    command. Run `vagrant init` to create a new Vagrant environment. Or,
    get an ID of a target machine from `vagrant global-status` to run
    this command on. A final option is to change to a directory with a
    Vagrantfile and to try again.

<img src="/img/2015-03-28-01-command-line-vagrant.png" />

The fact that you're getting this notice means that Vagrant has been correctly installed. It is telling you that you need to tell it more about the virtual machine you want to set up before using `vagrant up`. We'll get to that.

Deciding on a development folder
-----

Figure out where on your computer you want your development to take place, and determine what the path is to that directory. For example, on Mac OS X or Linux, "Documents" in your home folder (whatever it is), can be noted as `~/Documents`. In your terminal, change the current directory to your development directory using the `cd` (change directory) command:

    cd ~/Documents

The tilde (`~`) means the home folder of the current user.

Windows uses a [different notation](http://www.wikihow.com/Change-Directories-in-Command-Prompt) I'm not familiar with, but might look something like this (the `~` does not seem to work with Windows, so the following assumes that your username is `username`):

    cd C:\Users\username\Documents

coreos-vagrant
-----

The final piece of software you'll need is [coreos-vagrant](https://github.com/dcycleproject/coreos-vagrant). [Download it](https://github.com/dcycleproject/coreos-vagrant/archive/master.zip) and unzip so that the `coreos-vagrant` exists in your development folder. For example, if you've decided to use `~/Documents` for your development folder, you should be able to `cd` into `coreos-vagrant` by typing:

    cd ~/Documents/coreos-vagrant

A plain-text editor
-----

A plain text editor is different from Word or OpenOffice in that it only edits text. Often, it will also highlight special keywords in html, php, or other programming languages. Everyone seems to have their preferences for this, but to get started you could try the free [TextWrangler](http://www.barebones.com/products/textwrangler/) for Mac OS X. The article [The Best Free Text Editors for Windows, Linux, and Mac, on How-To Geek](http://www.howtogeek.com/112385/the-best-free-text-editors-for-windows-and-linux/) provides a list of editors. If you have your own editor, [submit an issue](https://github.com/dcycleproject/dcycleu/issues) suggesting it be added to this section, and why.
<commit_msg>Issue #3 text editor, add Smultron<commit_after>---
layout:     post
title:      "1.3 Virtualization, CoreOS, and the command line"
subtitle:   "The tools and knowledge you'll need to work on your local machine."
date:       2015-03-29 12:00:00
author:     "Dcycle"
header-img: "img/post-bg-01.jpg"
class:      1
parent:     "<a href=\"/class-01-basics\">Class 1: Basics</a>"
---

Virtualization
-----

In lesson 1.1. we saw how to set up our first project and make changes to it. This was all done on the GitHub web interface, which has its limitations.

The next logical step is to figure out how to develop (i.e. make changes to a project) on your local machine.

However, everyone's local machine has different operating systems, different software, end even when two developers have the same software, they often have different versions of the same software, or the software is configured differently.

This is a headache that we will completely remove from our workflow by using virtualization: the only required software you need to install on your machine is the software which will allow you to launch _virtual machines_.

Think of virtual machines (VMs), as well as more lightweight "containers" (we'll see the difference later on), as temporary, virtual computers which run on your laptop.

VMs and containers are "guests", and your laptop is the "host".

Guests are isolated from the host, which means whatever you do on the guest won't affect the host; if you screw something up on the guest, you can simply destroy it and start from scratch. Likewise, if you must update software on your host computer, it won't affect the guest; If you lose your computer, all you need to do to get up and running again is find a new computer, install the few pieces of software we will introduce in this lesson, download whatever site it is you're working on, and get on with your job.

In this approach, whatever it is your software requires to run properly (a webserver, a specific version of PHP, etc.), is defined along with your software itself. This same information can then be used to set up local development environments, but also testing and production environments. This approach is known as DevOps and will save you dozens, even hundreds of hours in the coming years. (DevOps is a contraction of _development_ and _operations_, and aims to bring together two traditionally separate aspects of software creation: the code---development---and the servers and environments---operations).

Let's get started!

Installing Vagrant and VirtualBox on your local machine
-----

Whether you are running Mac OS, Linux, or Windows, you only need to install the following open-source software on your machine in order to develop anything we'll touch upon in this course:

 * **VirtualBox**, which allows you to create Virtual Machines on your laptop.
 * **Vagrant**, a command-line interface for VirtualBox (we want to move away from graphical user interfaces and do most of our work on the command line, like professionals).
 * **coreos-vagrant**, A virtual machine running a system called CoreOS and created with Vagrant.
 * A **plain text editor**, to allow you to edit plain text (unformatted) files. This is essential to write and edit code.

VirtualBox
-----

[VirtualBox](https://www.virtualbox.org) allows you to easily simulate any number of computers (limited only by your system RAM and storage) running on your host computer.

Install it [using the installation instructions for your platform](https://www.virtualbox.org/wiki/Downloads) and look for help (as discussed in the previous lesson), then [file a support issue](https://github.com/dcycleproject/dcycleu/issues) if you get stuck.

Vagrant
-----

[Vagrant](https://www.vagrantup.com) is a command-line wrapper around VirtualBox, among other things.

Download and install it [using the installation instructions for your platform](https://www.vagrantup.com/downloads.html).

Make sure you can open the `Terminal` application which comes with your Mac OS or Linux computer, or, on Windows, the Command Prompt (Windows users might have to install more software like PuTTy -- [more info on Vagrant for Windows here](http://www.sitepoint.com/getting-started-vagrant-windows/)), and type:

    vagrant up

You should be seeing something like:

    A Vagrant environment or target machine is required to run this
    command. Run `vagrant init` to create a new Vagrant environment. Or,
    get an ID of a target machine from `vagrant global-status` to run
    this command on. A final option is to change to a directory with a
    Vagrantfile and to try again.

<img src="/img/2015-03-28-01-command-line-vagrant.png" />

The fact that you're getting this notice means that Vagrant has been correctly installed. It is telling you that you need to tell it more about the virtual machine you want to set up before using `vagrant up`. We'll get to that.

Deciding on a development folder
-----

Figure out where on your computer you want your development to take place, and determine what the path is to that directory. For example, on Mac OS X or Linux, "Documents" in your home folder (whatever it is), can be noted as `~/Documents`. In your terminal, change the current directory to your development directory using the `cd` (change directory) command:

    cd ~/Documents

The tilde (`~`) means the home folder of the current user.

Windows uses a [different notation](http://www.wikihow.com/Change-Directories-in-Command-Prompt) I'm not familiar with, but might look something like this (the `~` does not seem to work with Windows, so the following assumes that your username is `username`):

    cd C:\Users\username\Documents

coreos-vagrant
-----

The final piece of software you'll need is [coreos-vagrant](https://github.com/dcycleproject/coreos-vagrant). [Download it](https://github.com/dcycleproject/coreos-vagrant/archive/master.zip) and unzip so that the `coreos-vagrant` exists in your development folder. For example, if you've decided to use `~/Documents` for your development folder, you should be able to `cd` into `coreos-vagrant` by typing:

    cd ~/Documents/coreos-vagrant

A plain-text editor
-----

A plain text editor is different from Word or OpenOffice in that it only edits text. Often, it will also highlight special keywords in html, php, or other programming languages. Everyone seems to have their preferences for this, but to get started you could try the free [TextWrangler](http://www.barebones.com/products/textwrangler/) for Mac OS X. The article [The Best Free Text Editors for Windows, Linux, and Mac, on How-To Geek](http://www.howtogeek.com/112385/the-best-free-text-editors-for-windows-and-linux/) provides a list of editors. If you have your own editor, [submit an issue](https://github.com/dcycleproject/dcycleu/issues) suggesting it be added to this section, and why.

Some of the editors used by my colleagues include:

 * [Smultron](https://www.peterborgapps.com/smultron/) (commercial)
 * [Taco](http://tacosw.com) (commercial)
 * [Netbeans](https://netbeans.org) (open source)

{'fraction_non_alphanumeric': 0.07410329985652797, 'fraction_numerical': 0.005810616929698709, 'mean_word_length': 4.186383928571429, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 18, 'lorem ipsum': 0, 'www.': 17, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4422958', 'n_tokens_mistral': 3686, 'n_tokens_neox': 3535, 'n_words': 1967}