Ruby 1.9.3, Iron Foundry + Cloud Foundry and++

Installing the Latest Ruby, A Gotcha

Generally, you’d just install rvm (Ruby Version Manager) and execute this command.

[sourcecode language=”bash”]
rvm install 1.9.3
[/sourcecode]

But alas, as happens sometimes, I ran into an issue related to the C compiler being found. Checking the log file for errors I found the message and went searching, finding an immediate solution thanks to good ole’ Stack Overflow. Simply executing the install with a specific C compiler will get things running smoothly.

[sourcecode language=”bash”]
rvm install 1.9.3 –with-gcc=clang
[/sourcecode]

Installing the Latest Ruby on Windows

This part is pretty stupidly simple. Just download the installer and execute it. Once you’ve done this you’ve got all the gem bits and ruby bits you need to get the CLI for Cloud Foundry w/ the Iron Foundry .NET Additions!

Installing the vmc-ironfoundry CLI App

Why am I installing Ruby 1.9.3 besides the obvious fact that it is Ruby, and awesome, and inherently great for getting shit done? I need the latest bits in order to install the latest Iron Foundry vmc client! You may ask, what’s wrong with the vmc client that Cloud Foundry has made? Well, the .NET bits aren’t included to appropriately identify when you have a .NET application. Basically, the vmc client is the exact same one that the core Cloud Foundry team puts together, but with the additions to know that there are Iron Foundry DEAs that can launch and run .NET Web Applications. To install this, execute the following command on OS-X.

[sourcecode language=”bash”]
gem install vmc-IronFoundry
[/sourcecode]

If you ever run into the

“Could not find a valid gem ‘vmc-ironfoundry’ (>= 0) in any repository”

a quick call to update will usually resolve the issue. You may need to run this command with sudo, to insure you have access to the gems directory.

[sourcecode language=”bash”]
sudo gem update –system
[/sourcecode]

Summary

At this point you can deploy a ton of languages and frameworks in addition to having .NET & SQL Server Support. I’ll be following up this with a how-to on deploying an ASP.NET 4.0 MVC Application, Node.js, and Ruby on Rails Application, scaling them to multiple instances, and best practices around that in the next month or three. In addition to that, I’ll have some great material coming up regarding some practices around getting these frameworks to work well together against data sources, across end points, via services and more.

Raven DB, A Kick Starter using Tier 3 IaaS

I’m putting together a pretty sweet little application. It does some basic things that are slowly but surely expanding to cover some interesting distributed cloud computing business cases. But today I’m going to dive into my Raven DB experience. The idea is that Raven DB will act as the data repository for a set of API web services (that seems kind of obvious, I state the obvious sometimes).

The first thing we need is a server instance to get our initial node up and running. You can use whatever service, virtualization tools, or a physical server if you want. I’m going to use Tier 3’s Services in my example, so just extrapolate for your own situation.

First I’ve logged in to the Tier 3 Control Site and am going to create a server instance.

Building the Tier 3 Node for Raven DB

Creating the Server Instance (Click for full size image)
Creating the Server Instance (Click for full size image)

Next step is to assign resources. Since this is just a single Raven DB node, and I won’t have it under heavy load, I’ve minimized the resources. This is more of a developers install, but it could easily be a production deploy, just allocate more resources as needed. Also note, I’ve added 50 GB of storage to this particular instance.

Setting Resources (Click for full size image)
Setting Resources (Click for full size image)

Now that we’ve set these, click next and on the next screen click on server task. Here add the public IP option and select the following services to open their ports.

Setting up a Public IP and the respective ports/services (Click for full size image)
Setting up a Public IP and the respective ports/services (Click for full size image)

The task will display once added as an item on the create server view. Once that is done, click create server so the server build out will start.

Creating the Server (Click for full size image)
Creating the Server (Click for full size image)

Now log in with RDP to start setting up the server in preparation of loading Raven DB. The first thing you’ll want to do is go ahead and get Windows Update turned on. My preference is to just turn it on and get every update that is available. Once that is done, make sure to get the latest .NET 4 download from Windows Update too.

Getting Windows Update Turned On (Click for full size image)
Getting Windows Update Turned On (Click for full size image)

Once all of the updates are finished and .NET 4 is installed we’ll get down to the business of getting Raven DB Installed. In this specific example I’ll be installing the Raven DB as a windows service, it however can be installed under IIS so there are many other options depending on how you need it installed.

Installing Raven DB

To get the software to install, navigate over to the Raven DB site at http://ravendb.net/ from the new instance we’ve just spun up. Click on the Download button and you’ll find the latest build over on the right hand side. Click to download the latest software package to a preferred location on the system.

Raven DB - Open Source 2nd Generation Document DB (Click to navigate to the site)
Raven DB – Open Source 2nd Generation Document DB (Click to navigate to the site)

Once you’ve downloaded it (I’ve put my download in the root R:\ partition I created) unzip it into a directory (I’ve just unzipped it here into R:\ to make the paths easy to find, feel free to put it anywhere you would prefer. In our Tier 3 environment the R drive is on a higher speed, thus higher IOP drive system, thus the abilities exceed your standard EBS/AMI or S3 style storage mechanisms.).

Saving the Raven DB Download (Click for full size image)
Saving the Raven DB Download (Click for full size image)
Saving to R:/ (Click for full size image)
Saving to R:/ (Click for full size image)

At this point, open a command prompt to install Raven DB as a service. Navigate to the drive and folder location you’ve saved the file to. Below I displayed a list of the folder and files in the structure.

CLI actions (click for full size image)
CLI actions (click for full size image)

Once you’re in the path of the Raven.Server.exe file then run a slash install on it to get a Windows Service of the Raven DB running.

Raven DB Installation results (click for full size image)
Raven DB Installation results (click for full size image)

To verify that it is up and running (which if you’ve gotten these results, you can rest assured it is, but I always like to just see the services icon) check out the services MMC.

Launching services (Click for full size image)
Launching services (Click for full size image)

There it is running…

Now, you’re not complete yet. There are a few other things you may want to take note of to be sure you’re up and running in every way you need to be.

The management and http transport for Raven DB is done on port 8080. So you’ll have to open that port if you want to connect to the services of the database externally. On windows, open up the Windows Firewall. Right click on the Inbound Rules and click Add Rule.

Select Port (Click for full size image)
Select Port (Click for full size image)
Select the Raven.Server.exe (click to see full size)
Select the Raven.Server.exe (click to see full size)
Inbound Rule (Click for full size image)
Inbound Rule (Click for full size image)
Open up however needed. (Click for full size image)
Open up however needed. (Click for full size image)
Public Private etc. (Click for full size image)
Public Private etc. (Click for full size image)

Enter a name and description on the next wizard dialog screen and click on Finish.

Displayed active firewall rule (Click for full size image)
Displayed active firewall rule (Click for full size image)

Now if you navigate to the IP of the instance with port 8080 you’ll be able to load the management portal for Raven DB and verify it is running and you have remote access.

Raven DB Management Screen
Raven DB Management Screen (Click for full size image)

At this point, if you’d like more evidence of success, click on the “Create Sample Data” button and the management screen will generate some data.

Raven DB Management console with data (Click for full size image)
Raven DB Management console with data (Click for full size image)

At this point you have a live Raven DB instance up and running in Tier 3. Next step is to break out and add nodes for better data integrity, etc.

Summary

In this write up I’ve shown a short how-to on installing and getting Raven DB ready for use on Windows Server 2008 in Tier 3’s Enterprise Cloud environment. In the very near future I’ll broach the topics of big data with Raven DB, and other databases like Riak and their usage in a cloud environment like Tier 3. Thanks for reading, cheers!

Building a Node.js + Express.js + Jade CoderWall + Geekl.st Portfolio (cont…)

In the previous blog entry I went thru the steps needed to get a Node.js site up and running with Express.js. Next I’m going to leap right into getting some mash ups going with Coder Wall. I’m currently waiting on Geekli.st to get me some beta API access, when that happens I’ll be adding some of the geeky list to the portfolio. For now… on with the mash up.

Folder Structure
Folder Structure

First things first, get the pertinent pieces you need from proudify.js (check it out here: https://github.com/icebreaker/proudify and on Mihail’s site here: http://proudify.me). My folder structure looked like this once I had pulled in the js & css files I needed. You may notice I have three image files too, I picked them up via http://iconfinder.com, but you can snag my github and they’re included in that.

If you just want to clone the code, I do have it available on githubhttps://github.com/Adron/codingwall.

.
.
.
.
Next I setup the index.jade like this:

[sourcecode language=”vb”]
h1= title

div.splitter
div.left
div.navAlpha
p Welcome to #{title}’s Portfolio Site

a(href=’http://www.linkedin/in/adron’)
| <img alt="Linkedin" src="images/linkedin.png" style="border: 0px" />
br
a(href=’http://twitter.com/adron&#8217;)
| <img alt="Twitter @adron" src="images/twitter.png" style="border: 0px" />
br
a(href=’http://www.facebook.com/adron&#8217;)
| <img alt="Facebook" src="images/facebook.png" style="border: 0px" />

div.navBeta
p #{title}’s Other Web Presence

ul
li
a(href=’http://compositecode.com&#8217;)
| Composite Code
li
a(href=’https://github.com/Adron&#8217;)
| Github
li
a(href=’http://www.linkedin.com/in/adron&#8217;)
| LinkedIn
li
a(href=’http://www.facebook.com/adron&#8217;)
| Facebook
li
a(href=’http://twitter.com/adron&#8217;)
| Twitter

div.right
div.crazy
p the content
[/sourcecode]

After I setup the index.jade I changed the layout.jade to have the following code.

[sourcecode language=”vb”]
doctype 5
html(lang="en")
head
title= title
link(rel=’stylesheet’, href=’/stylesheets/style.css’)
link(rel=’stylesheet’, href=’/stylesheets/site.css’)
link(rel=’stylesheet’, href=’/stylesheets/splitter.css’)
link(rel=’stylesheet’, href=’/stylesheets/proudify.min.css’)
script(src=’/javascripts/jquery-1.4.4.min.js’)
script(src=’/javascripts/jquery-ui-1.8.7.custom.min.js’)
script(src=’/javascripts/jquery-proudify.min.js’)
body!= body
[/sourcecode]

Those are basically all the changes I made for the first push to github. Run the standard app:

[sourcecode language=”bash”]
node app.js
[/sourcecode]

Once it runs you should see the basic display of information. The proudify.js pulls the CoderWall badges from the their site.

Coding Wall
Coding Wall

At this time I still haven’t had time to weave in the Geekli.st yet, but will work toward doing that in the future and making a post.

I’ll be adding other features to this, as an example, around database support, connecting to services and a host of other functionalities. So stay tuned to this blog and be sure to follow the github repository for the latest bits.

Until then, enjoy.

Building a Node.js + Express.js + Jade CoderWall + Geekl.st Portfolio

If you’re looking for Part 2…

Alright, diving right in. First, get an express.js application setup and install all the dependencies.

Creating the Express.js Web Application

[sourcecode language=”bash”]
$ express codingWall

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

dont forget to install dependencies:
$ cd codingWall && npm install

$ cd codingWall/
$ npm install
npm http GET https://registry.npmjs.org/express/2.5.8
npm http GET https://registry.npmjs.org/jade
npm http 200 https://registry.npmjs.org/express/2.5.8
npm http GET https://registry.npmjs.org/express/-/express-2.5.8.tgz
npm http 200 https://registry.npmjs.org/jade
npm http 200 https://registry.npmjs.org/express/-/express-2.5.8.tgz
npm http GET https://registry.npmjs.org/mime/1.2.4
npm http GET https://registry.npmjs.org/mkdirp/0.3.0
npm http GET https://registry.npmjs.org/qs
npm http GET https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/commander/0.5.2
npm http 200 https://registry.npmjs.org/qs
npm http 200 https://registry.npmjs.org/mkdirp/0.3.0
npm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz
npm http 200 https://registry.npmjs.org/mime/1.2.4
npm http GET https://registry.npmjs.org/mime/-/mime-1.2.4.tgz
npm http 200 https://registry.npmjs.org/commander/0.5.2
npm http GET https://registry.npmjs.org/commander/-/commander-0.5.2.tgz
npm http 200 https://registry.npmjs.org/connect
npm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz
npm http 200 https://registry.npmjs.org/mime/-/mime-1.2.4.tgz
npm http 200 https://registry.npmjs.org/commander/-/commander-0.5.2.tgz
npm http GET https://registry.npmjs.org/formidable
npm http 200 https://registry.npmjs.org/formidable
jade@0.26.0 ./node_modules/jade
├── commander@0.5.2
└── mkdirp@0.3.0
express@2.5.8 ./node_modules/express
├── qs@0.4.2
├── mime@1.2.4
├── mkdirp@0.3.0
└── connect@1.8.7
$
[/sourcecode]

Next get a basic app with a message built. This will make sure all the Jade, Express.js and of course Node.js bits are all installed and running.

[sourcecode language=”bash”]
$ node app.js
[/sourcecode]

Build The UI With Jade Templates

At this point you should be able to navigate to http://localhost:3000 in a browser and view the default express.js web app. So now let’s add something relevant to the page. First, I’m just going to stick my name on the page in the index.jade file. My method for editing the file is usually to just use a text editor such as TextMate.

[sourcecode language=”bash”]
$ mate views/index.jade
[/sourcecode]

There isn’t really a whole lot to the file yet. One thing you’ll notice though, is the Jade Templating.

[sourcecode language=”vb”]
h1= title
p Welcome to #{title}
[/sourcecode]

This might seem strange at first, but here’s an example of the HTML mess we normally see and then the same thing cleaned up. So here’s the some HTML goo…

[sourcecode language=”html”]
<header id="header" class="container">
<div id="socialLinks" class="span-24">
<ul class="right">
<li>Follow us:</li>
<li><a title="Twitter" href="http://www.twitter.com&quot; target="_blank"><img src="images/Twitter_32x32.png" alt="" /></a></li>
<li><a title="Facebook" href="http://www.facebook.com&quot; target="_blank"><img src="images/Facebook_32x32.png" alt="" /></a></li>
</ul>
</div>
<div id="titleContent" class="span-24">
<div id="textLogo">
<a title="GoldMind" href="/">
<span id="companyName">GoldMind</span>
</a>
</div>
<span id="textLogoSubtitle">What do you have to learn?</span></div>
</header>
[/sourcecode]

…and the Jade Template of the same.

[sourcecode language=”vb”]
header.container#header
div.span-24#socialLinks
ul.right
li Follow us:
li
a(href=’http://www.twitter.com&#8217;)
| <img src="images/Twitter_32x32.png" alt="" />
li
a(href=’http://www.facebook.com&#8217;)
| <img src="images/Facebook_32x32.png" alt="" />
div.span-24#titleContent
div#textLogo
a(href=’/’, title=’GoldMind’)
span#companyName GoldMind
span#textLogoSubtitle What do you have to learn?
[/sourcecode]

Much shorter, much cleaner, and lots less noise when one yanks away all the repetitive chevrons. Now that we’ve looked at an example of nasty HTML and clean Jade, let’s step through how to get certain markup with Jade.

The first thing to note is that each tag is indented below the tag it is included within. That’s how things are nested in Jade, and intelligently, no closing tag is needed. But what if you need the id or class added to the tag. That’s also extremely easy. To add the id just add a hash between the tag and the id parameter like this.

[sourcecode language=”vb”]
div#theIdName
[/sourcecode]

For a class added to the tag.

[sourcecode language=”vb”]
div.className
[/sourcecode]

To add both an id and a class.

[sourcecode language=”vb”]
div.className#theIdName
[/sourcecode]

If you open up the layout.jade file you’ll fine some other parts of the Jade Templating I haven’t covered, variables. In the layout.jade file you’ll find the following code.

[sourcecode language=”vb”]
!!!
html
head
title= title
link(rel=’stylesheet’, href=’/stylesheets/style.css’)
body!= body
[/sourcecode]

The title is set to title. Which is actually set in the index.js file. The index.js file has the routing functions that are called from the app.js file that launches the web application. Looking in the index.js file you’ll find the value that is passed in as the title. Change that to something custom for our app example. I changed mine as follows.

[sourcecode language=”javascript”]
exports.index = function(req, res){
res.render(‘index’, { title: "Adron’s Coder Portfolio Site" })
};
[/sourcecode]

Also, to get a little closer to the HTML5 Spec, I changed the layout.jade page as follows.

[sourcecode language=”html”]
doctype 5
html(lang="en")
head
title= title
link(rel=’stylesheet’, href=’/stylesheets/style.css’)
body!= body
[/sourcecode]

With those two changes we should have a custom message that is processed and also HTML5 compliance. Be sure to kill node.js if it is still running and restart it so all the changes are taken into account.

Mashing it Up!

Now it is time to mash this CoderWall & Geekli.st stuff up, but alas, that’s coming in the NEXT blog entry. Stay tuned, I’ll have it up in the morning!

Added: Part 2

OS-X Cocoa Quickie #2 => Know Objective-C

When working with Objective-C one key thing to keep in mind is the differences between the other “C”s like C, C++, etc. One thing that crops up sometimes is the C char type. Normally, this isn’t the most ideal thing to use. The better type to use is NSString.

[sourcecode language=”objc”]
// c string
char *foo;
foo = "This is a c string.";

// NSString
NSString *bar;
bar = @"This is an NSString.";
[/sourcecode]

The way to straighten this out is to give a little conversion if you do run into some C char types.

[sourcecode language=”objc”]
const char *footoo = "blah blah";
// Convert the NSString from a c string.
NSString *foobar;
foobar = [NSString stringWithUTF8String:footoo];

// Convert the c string to an NSString.
footoo = [foobar UTF8String];
[/sourcecode]

One of the other things that is a little catchy is the isEqual method.

The result of this test is yes if the receiver and anObject are equal and no otherwise. Basically, both pointers must be to the same memory locations. This however is not always equal, which can cause a bit of confusion.

There are a host of other things to keep an eye out for. So be sure to check out the specifics of how Objective-C works versus the other “C”s.