Well i missed this announcement from Cloudant

Well i noticed this on my account page with Cloudant:

Cloudant DBaaS price change—the free tier just got free-er!

Big news! We’ve raised the limit of the Cloudant DBaaS multi-tenant free tier from $5 per month to $50 per month. This permanent change begins on January 1, 2015, and will automatically be applied to the accounts of all multi-tenant users.

There will still be no extra charges for secondary index reads and updates, and bulk reads and writes will continue to count as one request.

You can see the details in their changed pricing page.

This is an awesome way to start the 2015. $50 is a lot of http and json flying back and forth. For me it means more room to play.

i <3 Cloudant…

Cloud 9 IDE and hiding secrets

I’ve using Cloud 9 IDE and one thing that has cropped up is the need to hide sensitive information in public work spaces.

If you are unsure of what Cloud 9 IDE is, it’s a browser based Integrated Development Environment. It’s great for things like node apps and it has a few templates for things like Ruby on Rails, Node C/C++, etc… Head over to http://c9.io for more details.

The other great thing is that all projects have a terminal that adds a great deal of flexibility when coding.

I was trying to hide the API key and secret to the data store in one of my Node projects and because the projects on C9 are public workspaces other people can potentially see what you have written in your code.node

The first thing I tried was to add an environment variable from the shell. This did add the variable but for some reason it wasn’t exposed in node through ‘process.env’ and the more i searched the less i found.

Not to be disappointed I looked through my C9 project and I found an area called Run & Debug and in there I was able to create different run profiles. Each of these profiles had an option to add command line arguments. After a bit of reading i found that these arguments are exposed in Node through the ‘process.argv’ array. Not ideal but it works.

C9 Cmd Line Arg

demo image

In this example environment the argument was at index 2 in the array but this may vary in other environments. I did get a friend to log into their Cloud 9 account and see if they could see the run profiles and she couldn’t see it.

I’m not sure if this is the best way to do this and I would love to know if anyone else has found a better way to hide sensitive information in Cloud 9 IDE public work spaces.


Edit – Try to be an optimist

After a bit more reading I found a popular node module called optimist. It hashes the options you pass in the command line. So now you can just pass in whatever key & value into the Cmd Line Args.

Have a look at the examples

Scope in JavaScript (Learning is fun)

What would you expect when you ran the following code JS snippet ?

if (true) {
var x = 69;

Today I found out some interesting things about scope in JavaScript. At the moment I’m reading the book Secrets of the JavaScript Ninja and in the chapter I’m reading they are going back through the fundamentals of functions.

Here is one of the points made is around variables, functions and their scope:

  • Variable declarations are in scope from their point of declaration to the end of the function within which they’re declared, regardless of block nesting.
  • Named functions are in scope within the entire function within which they’re declared, regardless of block nesting. (Some call this mechanism hoisting.)
  • For the purposes of declaration scopes, the global context acts like one big function encompassing the code on the page.

The code at the top will actually alert 69 when run. This came as a bit of a shock for me because from my background of C# / Java I have always assumed x would have been out of scope due to the block level context of how those languages work. When executed i expected to see a healthy null alerted.

This whole time I have made the assumption that these same rules from my experience with C# applied with JavaScript. This realisation that part of the fundamentals of what I have learnt is a little flawed is a little humbling but it really opens your eyes to what you are re-learning and quite honestly it’s awesome.

I can’t believe I have been using JavaScript for so long and have never picked this up. I guess the situation never came up in anything I’ve written (or it has and no one has found it yet). Sure the situation would rarely come up and it’s not like what you are doing is wrong, you just don’t feel like an expert anymore and that’s the humbling part so it’s bitter-sweet.


The great thing is at the moment i feel like Neo (Matrix Movie) when he’s in the chair and Link just ran the procedure to push Kung Fu 1.0 into his head, this will definitely change the way i write JavaScript.

I guess its another notch on the sword on the way to ninja status….

Or maybe I’m just holding the sword the right way round now :)

JavaScript is evolving

I’ve been playing with JavaScript since I first discovered it in grade 9 of high school. At the time I thought it was awesome, I could change images on a HTML page and make stuff disappear. I was hooked.

I started making little web pages that did nothing. I probably contributed to the large amount of webpages on the Internet that had scrolling marques or flaming gifs and had images that switched to different sized images when you rolled over them. For this I am sorry.

js logo

At university JavaScript was not a commonly talked about language, we learned C / C++ and then moved on to Java. These where heavy lifting languages, they could do anything. I couldn’t do it as easy as I could with JavaScript and HTML, but there was more here.

At the time Java and .NET were on the rise and web applications were still a little young. As I matured I saw JavaScript as more of a scripting language and only used when it was need.

Over time I have became familiar with .NET and saw it as a professional language (don’t hate) and JavaScript remained in the background and only took stage when needed.

Now I have noticed something. More and more technologies are pushing the boundaries of where Javascript can be used. Things like node.js have turned Javascript on it’s head and made me think differently about the language, it can be a server now.

Things like require.js, backbone.js, mustache.js, etc.. all push JavaScript to the realm of being a modularised, testable language that follows an MVC architecture. JQuery UI and ExtJS give you rich UI/UX tools that make your apps pop. No more flaming gifs for me.

At the moment I’m hacking together an app that utilises JQuery, mustache and backbone and require. Built with node and CouchApp and pushed to CouchDB, furthermore I am developing it on Cloud 9 IDE. All bar CouchDB are based on JavaScript (As far as I know from what I have read), that’s end to end development in the cloud. To me JavaScript is becoming the language of the Internet.

mustache jsIts like JavaScript is that girl in high school that you hung out with and did stuff with but never got serious with her, she had potential but you were young and naive and never saw it. You grew apart over the years and then suddenly at a conference in Capital City you see her again and POW you are stunned at her change. She is so much cooler than you ever knew…. I think I’m getting carried away.

The point is JavaScript with all it’s fancy prototyping is evolving and I feel like there is a new wave of frameworks that are going to become the norm. Its not going to replace things like Java, PHP, .NET, etc. but I think the convenience and ease that these toolkits create will be big attraction for developers.

Granted it isn’t there yet, things like Unit Testing need a bit of work but in any case I think its an exciting time.

Playing with mustache.js

I’ve been playing with CouchApp lately and I like the idea of making single page apps the rely a lot on Ajax and a chatty rather than chunky. I saw mustache.js the other day and decided to use it in my CouchApp.

Mustache.js is the JavaScript implementation of the templating engine Mustache. Its basically logic-less templates, you define a template and as long as the object parsed through the template contains a field in the template then it’s value will get pushed into the result. It’s a little more than that but I try to keep things succinct.

I was rather surprised with it and I really like it. There is this simplicity to it that I really like. You have a model, you define a template, parse both into a function and bam you have yourself an output for data (almost).

I come from an asp.net background and data binding was a staple for me. I would define these data sources and then i would define a grid and then bind the data to the grid columns. Most of the time the standard controls would get you out of trouble but occasionally you would define a custom template the would automagically display what you wanted.

It wasn’t bad but it doesn’t feel as natural as mustache does. I picked this up very quickly and enjoy playing with it. Defining how a list was displayed was just as easy as displaying a single object. In .net land this was 2 separate data bound controls and some server side logic, in mustache it’s much more lean.

What I really like is how you just parse a template and a model through the mustache object. For me this is where you can separate logic, your views are objects that are platform agnostic and your mustache templates are browser specific (Mikito Takada’s single page app put this idea in my head).

I work in an environment where IE6 (don’t hate) is still the standard browser and we often run into the issues towards the end where a simple layout in standards land just looks crap on IE6. I intend to play with this some more and I believe this is going to save us time in the long haul.

If we just push things to the client as models and then have templates that are specific to a client then we should be a lot sweeter… In theory, all things work well in my head. I will test this out and post more on how things go later.

I would say that my organisation is responsible for Australia still being 0.8% on ie6countdown :)

Playing with CouchApp

I’ve been playing with CouchApp lately and have found it quite enjoyable. The version I’m playing with is the node.couchapp.js version. I installed it on my windows pc originally with a few hiccups due to paths for node modules.

After this I managed to do the same thing on Cloud 9 ide but more on this later.

One thing that annoyed me was the boiler command doesn’t feel complete. It gets you 80% there and then leaves you wanting.

The main thing was sammy doesn’t seem to work. I’m am publishing to a cloud based CouchDB server but I don’t think this should matter. I looked around at the repo history on git and comments were made to ignore sammy altogether.

It isn’t a big deal because you still have the crux of what boiler is supposed to do but having sammy there would be awesome in my opinion because it would just make the design doc feel a lot more app like.

A missing feature I would like to see is a ‘couchapp pull’ meaning i could go to a couchdb and download their design doc and it would get converted into a couchapp with the relevant JS file and attachments in my local directory.

Apart from this I still love the node CouchApp. It really fits what I’m trying to achieve with CouchDB, a lean environment for me to publish apps to and store data. The one huge plus with node CouchApp is that everything remains in JSON and JavaScript. It makes reading your docs and developing your apps a lot leaner because it all looks the same.

One last thing is you should try cloud 9 IDE, it integrates with git and I’ve managed to install node and CouchApp on there. In the end I have a full end to end development environment that runs from a browser. Data is pushed to iriscouch, source is stored on git and cloud 9 is my ide.

I’ve been using this for a week now and haven’t had an issue with it. I’ll blog more details on this later.