Coder’s Vacation : Getting Some Names…

Actual Live Status of the NameFactory Project

One of the things I’ve started working on is a #PhatData (re: my renamed version of big data) sample. So far what I’ve created is a JavaScript Application that works something like this. (The actual build status is shown to the right here in the “build status” image)

Step #1: Continuous Integration

The first thing I did was setup a solid node.js project that works on Travis CI (Continuous Integration). This is a pretty quick process. First create a directory and add an appropriate .gitignore and README.md file.

[sourcecode language=”bash”]
$ mkdir NameFactory
$ cd NameFactory/
$ git init
Initialized empty Git repository in /Users/adron/coderz/NameFactory/.git/
$ git remote add origin git@github.com:Adron/NameFactory.git
$ mate README.md
$ mate .gitignore
[/sourcecode]

The mate command is merely textmate, use whatever you’d like though to create the files. I also use Sublime 2 and other things, textmate just happens to be the poison I often choose from the command line. The .gitignore has the following to take care of WebStorm and other files that might pop up.

[sourcecode language=”bash”]
*.idea
.idea
idea
.DS_Store
*.DS_Store

lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

node_modules
npm-debug.log
[/sourcecode]

The README.md I just put the following in. You don’t really need this, but I’m showing you what should be put in a minimal project. In addition to being a good practice, we’ll need the README.md file for plugging in Travis CI in a few steps.

[sourcecode language=”bash”]
Name Factory
===
Description: This is JavaScript Node.js Project for generating random names.
[/sourcecode]

Commit those files.

[sourcecode language=”bash”]
$ git add -A
$ git commit -m ‘Adding gitignore and README.md.’
[master (root-commit) 14b1cf8] Adding gitignore and README.md.
2 files changed, 23 insertions(+)
create mode 100644 .gitignore
create mode 100644 README.md
$
[/sourcecode]

Once that is added there are some other files needed for Travis CI that I’ll add before flipping on the actual CI project on the Travis CI Website. First add a .travis.yml file to the project.

[sourcecode language=”ruby”]
language: node_js

# test on two node.js versions: 0.6 and 0.8
node_js:
– 0.6
– 0.8
[/sourcecode]

The packages file should look like this.

[sourcecode language=”javascript”]
{
"author": "Adron Hall <adronhall@gmail.com>",
"name": "NameFactory",
"description": "A library that creates randomly generated names for insert into various databases.",
"version": "0.0.1",
"homepage": "https://github.com/Adron/NameFactory/wiki&quot;,
"main": "./lib/names",
"repository": {
"type": "git",
"url": "git@github.com:Adron/NameFactory.git"
},
"scripts": {
"test": "vows –spec"
},
"engines": {
"node": ">= 0.4"
},
"dependencies": {},
"devDependencies": {
"vows": "0.6.x"
}
}
[/sourcecode]

At this point add a few tests that you know pass. I added the following examples from the vows site (this is the default example on the site).

[sourcecode language=”javascript”]
var vows = require(‘vows’),
assert = require(‘assert’);

// Create a Test Suite
vows.describe(‘Division by Zero’).addBatch({
‘when dividing a number by zero’: {
topic: function () { return 42 / 0 },

‘we get Infinity’: function (topic) {
assert.equal (topic, Infinity);
}
},
‘but when dividing zero by zero’: {
topic: function () { return 0 / 0 },

‘we get a value which’: {
‘is not a number’: function (topic) {
assert.isNaN (topic);
},
‘is not equal to itself’: function (topic) {
assert.notEqual (topic, topic);
}
}
}
}).run();
[/sourcecode]

…now make sure the tests run ok…

[sourcecode language=”bash”]
$ node test/names_object_should_exist.js
··· ✓ OK » 3 honored (0.003s)
$
[/sourcecode]

So that’ll get the continuous integration via Travis-CI for NameFactory up and running, with a Github NameFactory Repository that is ready for the name generation code to be added. For my next blog entry I’ll leap into some generation strategies, dig up some good name lists (if you know of any, leave a comment w/ a link), and work on figuring out the fastest way to generate names.

Once that’s done, it’s time to setup some distributed databases.
Shout it

Deploy a Framework Friday #4 Some Node.js .gitignore Cloud 9 IDE Sharing toward Cloud Foundry / Iron Foundry Deployment

Today’s “Deploy a Framework Friday” is a little bit of a diversion. Today Richard (@rseroter) and I dove into Cloud9IDE (@Cloud9IDE) to try out some pair programming with the online IDE sharing. We made some minor progress with Matt (@matt_pardee) & Eric (@ang3lfir3) jumping in for a few minutes. The intent of this effort was to pull together a little code to deploy, as Richard wrote about a few months ago in the article “Deploying Node.js Applications to Iron Foundry using the Cloude9 IDE“.

Here’s a video of us all fumbling through attempting to get the .gitignore file setup.

Richard Seroter (@rseroter) and I (@adron) took a stab at sharing some code, with the attempt to do some pair programming. We made a little progress, and even had some people join us live via Twitter and edit some of the code with us. For a short play by play, check out the blog entry here: http://compositecode.com/2012/08/03/deploy-a-frame…dry-deployment/

Questions:

  1. Why did the .gitignore not show up on Richard’s Screen?
  2. What were the intermittent errors that came up?
  3. Why did it say I was setup for “premium” but I couldn’t use express?
  4. Is it supposed to be that the other person can’t make changes while someone is chatting?

I’m not sure what happened (anyone at Cloud 9 IDE know what happened) when the .gitignore totally disappeared  but in the video you can see that I committed and pushed the .gitignore file. I had to recreate it to get anything to show up, and initially it didn’t seem to share either. I’m not sure how that is supposed to work, but am assuming something wasn’t setup correctly in the first place.

As for express I’ll be giving that a try a little bit later.

Next Steps Toward Deployment

Over the next few weeks or so, Richard and I will be going back and forth building a Node.js based web application for deployment from Cloud 9 IDE to our Iron Foundry Environment. Overall, this will be a slightly drawn out “Deploy a Framework Friday“, with its own sub-parts to the series.

We’ll culminate the project in an open source project that will be available on Github and also with a summary on the Iron Foundry Blog. In one of our pending blog entries we’ll draw up the architecture of the application we’ll be building out. So stay tuned!

NOTE: Working in conjunction with these other bloggers / blogs:

Deploy a Framework Friday #3 with node.js + express.js

Time for the node.js “Deploy a Framework Friday”. First get node.js and express.js installed (i.e. npm install express) and then create your node.js application.

[sourcecode language=”bash”]
adron$ express nodejs

create : nodejs
create : nodejs/package.json
create : nodejs/app.js
create : nodejs/public
create : nodejs/public/javascripts
create : nodejs/public/images
create : nodejs/public/stylesheets
create : nodejs/public/stylesheets/style.css
create : nodejs/routes
create : nodejs/routes/index.js
create : nodejs/views
create : nodejs/views/layout.jade
create : nodejs/views/index.jade

dont forget to install dependencies:
$ cd nodejs && npm install
[/sourcecode]

Once the app is installed open up the app.js file and edit the code so that it reflects what is shown below.

[sourcecode language=”javascript”]
var express = require(‘express’)
, routes = require(‘./routes’);

var app = module.exports = express.createServer();

// Configuration

app.configure(function(){
app.set(‘views’, __dirname + ‘/views’);
app.set(‘view engine’, ‘jade’);
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + ‘/public’));
});

app.configure(‘development’, function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure(‘production’, function(){
app.use(express.errorHandler());
});

// Routes

app.get(‘/’, routes.index);

// Cloud Foundry Environment Variables
var port = (process.env.VMC_APP_PORT || 3000);

app.listen(port);
console.log("Cloud Foundry Demo Express server listening on port %d in %s mode.", app.address().port, app.settings.env);
[/sourcecode]

The emphasis is the port variable added for the VMC_APP_PORT. This variable is needed by the Cloud Foundry system to know which port that node will use to host on, which Cloud Foundry will then intelligently map to so you will get the standard default port 80 activity you expect. For more information about all this hosting mess with node.js check out one of my previous write ups on the topic on the New Relic Blog.

Once you’ve setup this file, then just deploy using the with npm support option that states the version of node.

[sourcecode language=”bash”]
vmc push –version=node06
[/sourcecode]

For more information about deploying node apps with npm module dependencies check out this blog entry on “Cloud Foundry supports node.js modules with NPM“.

All done. Yes, there is more Deploy a Framework Fridays coming up, so stay tuned!

OSCON Day #3, #4, and Friday => Bailey’s Taproom, Cloud Camp, Cloud Foundry, Open Shift, PaaS, vert.x, and so much more…

Tuesday night, as usual ended with great technical conversation at Bailey’s Taproom. Bailey’s is basically the epicenter of the Portland tech scene. Almost every programmer, devops, or technical person either goes about once a month or has this establishment as a regular watering hole! It’s great, the atmosphere is chill, the beer is SUPERB, the beer menu kicks ass (see: Beer Dashboard Kick’s Ass) and the list of fun cool things just continues on and on.

This week of course OSCON adds a little spice to the regular roll call at Bailey’s. There were a number of conversations that broke out, which I’ve broken out the key topics below:

vert.x => To summarize as is written on the site itself, “Write your application components in JavaScript, Ruby, Groovy or Java. Or mix and match several programming languages in a single application. Create real, scalable applications in just a few lines of code. No sprawling xml config. Scale using messaging passing and immutable shared data to efficiently utilise your server cores. Super-simple concurrency model frees you from the hassles of traditional multi-threaded programming.

Here’s an example from the site in a few of the languages:

Java

[sourcecode language=”Java”]
import org.vertx.java.core.Handler;
import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.deploy.Verticle;

public class Server extends Verticle {
public void start() {
vertx.createHttpServer().requestHandler(new Handler() {
public void handle(HttpServerRequest req) {
String file = req.path.equals("/") ? "index.html" : req.path;
req.response.sendFile("webroot/" + file);
}
}).listen(8080);
}
}
[/sourcecode]

JavaScript

[sourcecode language=”JavaScript”]
load(‘vertx.js’)

vertx.createHttpServer().requestHandler(function(req) {
var file = req.path === ‘/’ ? ‘index.html’ : req.path;
req.response.sendFile(‘webroot/’ + file);
}).listen(8080)
[/sourcecode]

Ruby

[sourcecode language=”Ruby”]
require "vertx"

Vertx::HttpServer.new.request_handler do |req|
file = req.uri == "/" ? "index.html" : req.uri
req.response.send_file "webroot/#{file}"
end.listen(8080)
[/sourcecode]

Wednesday Roughness

I felt beat up a bit start Wednesday, but rolled into it after a short while. Needless to say, the intensity of conversations (and maybe a few of those rounds of beer) and number of ideas, new things to check out and fitting it all in can wear one out.

The morning sessions were solid, I attended most of “Comparing Open Source Private Cloud Platforms“. Lance did a solid job of laying out the tooling, virtualization software and where these things come together to form a number of OSS options for cloud computing. Check out more from Lance on his @ramereth, his blog Lance Albertson, or check out his band he’s in “The Infallible Collective“.

Wednesday, Thursday and Friday Meets

I met a ton of people. All of whom I must say, I hope to get to talk to again, work with on projects, or just sling some code sometime. Absolutely great people, friendly, intelligent and highly motivated. Some of these people I met included:

Andy Piper (@andypiper) – Part of Great Britain’s contingent of VMware Cloud Foundry advocates and such. We got to hang out and talk about a zillion different topics at a number of events. Andy was kind enough to show me a few tips and tricks he’s been using with Cloud Foundry, the VMC, and in general working with the platform.

Josh Long (@starbuxman) – I met Josh once before on the Cloud Foundry open tour, where he brought COBOL programming… oh no wait, he brought some great Sprint Java samples and such to demo on the Cloud Foundry Platform. I fulfilled Josh’s dreams by telling him that COBOL, could indeed run on Cloud Foundry thanks to the .NET capabilities of Iron Foundry! (ya know, if anybody is into that type of thing)

Erica Brescia (@ericabrescia) – I finally got to meet Erica in person, after chit chatting on Twitter about all the great applications her company Bitnami helps to deploy in the cloud. There are some really great deployment hosting solutions from them, check them out if you’re looking for some streamlined deployment practices. She also mentioned I need to meet…

Jono Bacon (@jonobacon) – I managed to meet Jono by randomness. He’s, well, let’s say he does some absolutely great work in the tech industry for Canonical and in the open source universe. In addition Jono has some superb tastes in music.  \m/  \m/  Check out some of his work:  Blog, personal site, and you can probably google him too. Do it, he’s got a lot of great material out there.

As I was saying, these aren’t the only people that I met. To all those people I didn’t mention, it was awesome hanging out, catching up and hearing about what everyone is working on and creating.

PaaS, IaaS and The Driving Open Source Coders

On the topic of PaaS, it continues to expand into new realms of publicly (or privately) run services. PaaS is quickly expanding past mere framework services around .NET, PHP, Rails, Sinatra and such and moving into the realm of databases, services buses, and other capabilities as a service. As laid out with the SOA mindset. Even though enterprises failed to bring SOAP to an effective worldwide use, RESTful services are expanding rapidly. *aaS is pushing those even further, to do what the enterprise had wanted but failed to do. Creating a universal acceptance of scalable, powerful, expandable and extensible services through APIs.

As more services are extended we’ll start seeing a lot of offerings around truly scalable databases with various feature sets around those databases offered as a key service. Examples would include “atomic database as a service”, “transactional data store as a service”, or “document store as a service”. In the end it will include the amount of usefulness for the services while eliminating a need to know each in intimate detail. Knowing the core capabilities of an option and just using the service will grossly outpace the attempt to implement these services internally.

So keep watching PaaS to grow in many various ways. Consuming the service being the driver over attempting to build the service. Of course, if the service doesn’t exist, get on that it’s business opportunity!

Random OSCON Diversions

I had a great time visiting with family while at OSCON also. To whom they all send a hello and horns up, thrash on salute to the coders of the world!

Voodoo Donut Break with Florida Family Contingent
Voodoo Donut Break with Florida Family Contingent.
My brother Adam, the IT Department
My brother Adam, the IT Department

My Brother Runs an IT Shop of One…

…thanks to cloud computing capabilities.

This kind of blew my mind. I sort of of knew what he did, but it didn’t hit me how close our professional lives are until this trip. He’s just recently moved several hundred miles away from the main office, but still manages the entire company.

One of the unique happenstances is, my brother (the guy next to the bald guy that is me, he’s wearing a Tesla t-shirt) is the top IT guy for a little billion dollar a year company. Which, in this case, he’s proven the power of cloud computing. Why do I say this? Because traditionally this organization would have needed an army of PC techs, network knob fiddlers, and such. But with the advantages of cloud computing, both on premise and off premise, and have a DevOps Guy that knows what he’s doing they are able to efficiently run their entire company with one single guy.

Needless to say, with the synergy of OSCON we had more than a few conversations around tech. Some of those included the replacement of PCs with mobile devices, such as iPads or smart phones. Another was the mix of on-premise data that couldn’t easily be transferred or utilized form cloud services. These are just a few fo the things that have helped him to run the show, the entire show.

Summary

OSCON was awesome. Next time I will be taking off a day or two before and a day or two afterwards so that I can do an even more elaborate write up of the event. My aim is to have interviews, video and otherwise, and really step it up in relation to providing an eye into the event from a developer’s point of view.

#nodejs, why I’m basically porting EVERYTHING to it…

Here’s my list of why I’m moving everything to Node.js that I run (i.e. maybe even THIS wordpress blog eventually).

  • Between the enhancements Google gave to JavaScript and the ease of use in writing with the language, it provides the least resistance of any framework and language stack out there.
  • Node.js + Express.js or Bricks.js + Jade + Every DB Choice on Earth really is a convincing reason too.
  • The developer community, if it isn’t now, is ridiculously close to the biggest development community on Earth. The JavaScript community goes into every corner of development too and crosses over easily into Ruby on Rails, .NET, and Java. Nobody is left untouched by JavaScript. This provides more avenues of joining up for projects than any other platform in existence.
  • Hiring for startups, mid- or enterprise business to build node.js and Javascript apps is 10x easier than hiring for anyone else right now. Which still makes it almost impossible. But that means it is “almost impossible” vs. “impossible” as it is with the other stacks!
  • Node.js is fast enough, and easy enough to distribute and less resource intensive than almost anything on the market. All that and it requires almost nothing to configure and setup compared to Apache, IIS, and a bunch of those other solutions.
  • The PaaS Solutions out there, thanks in large part to Nodejitsu, Nodester, and even the Windows Azure Node.js team have made deploying Node.js apps the easiest stack to deploy around – hands down – no contest.
  • Node.js uses JavaScript (if you haven’t noticed) and most of the NoSQL solutions already speak the common language, JSON or BSON which makes layering more transparent in your architectures.
  • I could go on… but you get the idea.  Node.js + JavaScript makes life EASIER and gives me more time to do other things. Other stacks typically have me tweaking and tinkering (which I do find fun) for hours more at a time per project than a Node.js Project. Generally though, I like to get a beer at some point, and Node.js get me there earlier!

Sure, I’m sticking to being polyglot. I’m even headed to the Polyglot Conference in Vancouver BC this evening. But nothing is as approachable as Node.js + JavaScript. Looking forward to a lot of PaaS discussion around Node.js and getting interoperability against .NET, Java, Rails and other frameworks.

So expect to see a lot more Node.js and JavaScript bits on the blog!  🙂   Cheers!