Stephen C Wright Creative Development

Workflow on Windows

I’ll admit, most of my development is done on OSX. My primary “work”station at home is my early 2015 15” rMBP, and i’ve got a pretty optimized workflow on there for web development. However, for application development and games development my new desktop is my powerhouse…and it is a powerhouse!

Node, Ruby and Git

That being the case, I don’t feel like Windows has the right command-line integration to truely be as optimised for the kind of gem and npm work that comes with web development. So the first thing that we’re going to want to do is get Windows playing happily with those two.

Node & NPM

First off, you want to install node and npm. To do that, head over to nodejs.org and download whichever version of Node that you want (either the LTS version or the Current). If you’re confused by which one you will need, this link has the details for the release plan. The Node installer comes with NPM now (it didn’t used to), so once you run the installer, you should be all set!.

To validate node, open Command Prompt or Windows Powershell and run:

node -v

You should get a response that looks something like:

v4.2.6

To check NPM, it’s the same thing:

PS C:\Users\Stephen> npm -v
2.14.12

OK Cool! So that’s Node/NPM installed!

Ruby & GEM

The next thing you’re going to want to do is install Ruby. This is slightly more tricky than Node, but not by much.

First, grab the Ruby Installer. You’re going to want the Ruby Installer for Windows (I chose the 2.2.4 x64 variant), and you’re also going to want the DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe (The Ruby Development Kit, you’ll see why in a sec..)

So go ahead and install Ruby. It’ll install it somewhere like C:\Ruby2.2.4, which is fine. Check that it’s installed by issuing ruby -v, which should output something like:

ruby 2.2.4p230 (2015-12-16 revision 53155) [x64-mingw32]

Once that’s done, you’re going to want to install the Ruby Development Kit that you also downloaded. This one is slightly more tricky.

  • Firstly, run the .exe that you downloaded and have it extract somewhere that it’s going to live (I extracted mine to C:\RubyDevKit).
  • When it’s finished extracting, you need to cd into that directory and run ruby dk.rb init, which generates a config file containing the path to your Ruby installation.
  • Once you’ve validated the config.yml file that it creates (you can use ruby dk.rb review for that), run ruby dk.rb install to complete the installation.
  • Finally, to validate that you’ve installed GEM correctly, you can do something like:

    gem install json –platform=ruby

  • and then

    ruby -rubygems -e “require ‘json’; puts JSON.load(‘[42]’).inspect”

Which will confirm that both GEM and Ruby are working.

So now you also have Ruby installed on the command-line. Good Job!

Git

The final piece of this puzzle (from a toolchain point of view), is Git. On Linux and OSX this is really straightforward (either sudo apt-get install git, or install xcode tools), but on Windows it’s a separate application that hooks (optionally) into cmd.

Head over to the git website and download the git tools for Windows. Once downloaded, you need to start the installation, but change a couple of the install options along the way.

  • Make sure that the “Use git on Windows Command Prompt” option is selected, otherwise you will only be able to use git tools in git-bash (custom bash instance)
  • Make sure that you use “pull files as-is, push as Unix line-endings” if you are doing cross-platform development
  • Make sure that you allow GIT to use the command prompt options

Once that’s installed, you can validate it by doing:

PS C:\Users\Stephen> git --version
git version 2.7.1.windows.1

Awesome!

With these three tools, you should be able to happily develop feature-rich full-stack web applications using either Ruby-on-rails, or Javascript, and use the power of git to control your source code versioning.

Getting Started with GitHub Pages

Until last week I had 4 sites hosted on a Linode VPS. Personally, I have never had any issues with Linode, and I would actually recommend them as a VPS provider, but there have been recent issues, and although I found that in general they dealt with this problem pretty promptly, the whole thing has made me rethink how I host stuff.

Out with the old…

Having 4 sites is sort of unnecessary for where I am as a developer right now. I was previously hosting:

So I decided to shut down the wedding website, get my free-loading sister to move her Wordpress-based portfolio off my VPS(!), and move both my personal blog and the landing page for Trailio over to GitHub Pages. My “organizational” page is hosting my blog (which would be pointed at scwright1.github.io), and the project page for Trailio sits as a subdomain of that by default.

In with the new!

I didn’t really care about any of the content from my old personal blog, but I have it as a backup from my VPS should I choose to host it here again some time in the future. (For reference, I was previously using a ghost powered blog, which was pretty cool!)

GitHub pages has good integation with the Jekyll “hacker” blogging site generator. What it actually does is compile a bunch of markdown and layout pages, and serve that out as a static site. I don’t really blog enough to need a powerful CMS, so this suits me, and also allows me to write posts in Sublime Text!

Getting Jekyll up and running was a fairly simple task. I chose Lanyon as my Jekyll theme, as it’s quite similar to my old theme Uno for Ghost. You basically create a new repository called github_username.github.io, clone the lanyon repo into that repository, and commit it, and GitHub does the rest!

The slightly tricky bit was mapping my custom URL to my organizational page. My domains are currently with 1and1. I’m not linking them because frankly they’re complete shit and i’m looking to move each of my domains over to Namecheap as soon as each come up for renewal. At any rate, in order to map your domain to GitHub pages, this is what you need to do:

  • Remove any existing DNS settings from the domain (mine were currently set to Linode’s DNS)
  • If your domain supports ALIAS records, fantastic! Map your alias record to your github.io URL and you’re done! ———- Otherwise… ———–
  • Create a new subdomain for www (stupid, I know, but 1and1 don’t support ALIAS records…)
  • For the APEX (@) domain, you need to map the A record for it to one of the two GitHub IPs (192.30.252.153 in this case)
  • For the www subdomain, map the A record for it to the other GitHub IP (192.30.252.154 in this case)
  • In your pages repository, create a new file called CNAME, and put a single line in there for your URL (in this case, stephencwright.co.uk)
  • Once you’ve done all that, wait for various DNS caches to flush, and you should be up and running!

To double check, you can use the following command: dig example.com +nostats +nocomments +nocmd

It should look something like this:

; <<>> DiG 9.9.5-3ubuntu0.7-Ubuntu <<>> stephencwright.co.uk +nocmd +nostats +nocomments
;; global options: +cmd
;stephencwright.co.uk.      IN  A
stephencwright.co.uk.   3600    IN  A   192.30.252.153

For a project page, the steps are exactly the same. The important piece of work in this is the creation of the CNAME file. (Don’t ask me how it maps, I have no idea!)

Speaking out

In order to post, all you need to do is create a new file in the _posts directory called YYYY-MM-DD-post-title.md, and you will be able to write markdown to your heart’s content! Then commit the file, and the Jekyll engine running on GH will auto-magically convert everything to static pages and host it for you.

Job Done!