Saturday, April 21, 2012

Continuous Integration for Javascript

I have been on a journey to introduce Javascript into our Continuous Integration and Test Driven Development eco-system.

For so long, Javascript has been treated like the ugly duckling, but with budding technologies like Knockout.js and Node.js, javascript is becoming a critical component of most systems.

The team at work decided to move forward with QUnit for the testing framework. I found a great link that showed how to get up and running with QUnit and PhantomJs here.

I ended up with the following files (from jQuery and the above blog post). Note I did not use the same name for my phantom-qunit-testrunner.js as the author of the blog post. 

Update – I am now using the run-qunit.js from phantomJS instead of phantom-qunit-testrunner.js from the above blog post.

image

I was then able to run phantomJs

image

Sweet!!

The blog post author was going after Continuous testing, which is very cool – but not what I need.

There is a lot to consider in the context of automation for Continious Integration. Generally, I don’t need my own html file. I just need the tests. So here goes the first feature.

When a js file (ie. coolplugin.js) is discovered during continuous integration, we should look for an associated test file (ie. coolplugin.test.js), if one is found, then we should generate the required qunit html, run the html though PhantomJS. The file should be unique (ie. coolplugin.test.html), and should not be deleted so that it can inspected for a failing test.

There will be times where I do need to provide my own dom elements, and therefore provide my own html. so here goes another feature.

When a js file (ie. coolplugin.js) is discovered during continuous integration, we should first look for an associated html file (ie. coolplugin.test.html), if one is found, then we should run the html though PhantomJS.

For this I created a simple executable which will perform the above tasks. (it is currently available on our internal svn – if you want it just leave a comment and I can put it in git hub).

Then I tied it all together with NAnt.

image

I am new to NAnt so I am sure I did several things wrong but its working….

Tests Passed

image

Tests Failed

image

Whats next? Prototype to production – and continuous testing for local development.

jQuery plugins and html data driven options

Wouldn’t it be nice if you could write a jquery plugin that takes options from the plugin, from the dom, or from defaults….?

But who wants to own that code?

This used to be a pain a few years ago, but html5 and jquery.data have made this quite easy.

Monday, April 16, 2012

JSHint or JSLint

Heard the buzz about JSHint?

I too am not a big fan of an opinionated code quality tool, but one of the main reasons I am hearing of people using JSHint is that doesn’t force you to declare your variables at the top of a function.

While it is really annoying to have to do this, I remembered in reading Javascript the Good Parts that it is best practice – I just couldn’t remember why.

Then I ran across this post which provides a snippet of why.

var name = "Dan";

function getName(){
    console.log(name);
    var name = "Paul";
    return name;
}
var newName = getName();

You would expect that console.log(name) would print “Dan” but instead it will print ‘undefined.’ This is because the variable name is scoped to the function and though the value gets set later, it is declared and scoped to the entire function.

If your going to allow this – you need to understand the ramifications.

The counter argument is that declaring variables at the top is noisy and unintuitive, especially in loops.

Saturday, March 31, 2012

RabbitMQ

Alright, its time to dive into RabbitMQ and see if it can pull its weight. 

  1. Created a Server2008 VM
  2. Installed Erlang and RabbitMQ
  3. Install Management Plugin (comes with RabbitMQ just not enabled)
    1. Enabled Management Plugin
      1. image
    2. Restarted the Service
      1. Supposed to do this
        1. image
      2. be sure to call rabbitmq-service.bat and not rabbitmq-server.bat
    3. Get an answer at http://localhost:55672/mgmt/ but what user… standard installation includes a user: guest with password: guest

Tuesday, March 13, 2012

Knockout Presentation

I had a great time presenting Knockoutjs at VtDotNet last night. It was a privilege to get to share such a cool technology with other enthusiasts.

The slides can be found here.

The prototype can be found here. (note that it requires MVC4 – yes its time!!)

Here are the link of resources for easy access

Thanks to all those that came and I welcome any feedback jhoguet@gmail.com.

Sunday, January 29, 2012

Getting out from beneath the cell phone giants

My wife and I are currently paying $135.45 (before taxes) for our cell phones which gives us 700 shared minutes and two unlimited data plans. In an effort to save money we are biting the bullet and considering alternatives to bring this perpetual cost down.

Spoiler: We are going to switch to a $2/day prepaid plan with no contract. We are going to use google voice for most of our phone calls for free and will buy an adapter ($50) so that we can use a regular phone to make Google Voice phone calls from our house. We can then adjust our usage to effectively pay $0 / month for our cell phones instead of being locked into $135 month after month. 

Our requirements are:

  • one data plan for GPS navigation and web browsing – we decided we could share the phone with the data plan when needed
  • great cell coverage for emergency phone calls
  • ~500 text messages / month
  • ~700 minutes / month

Coverage for emergencies is a high priority, so this limited us to Verizon and ATT. This was based on looking at coverage maps and asking around.

Now that we are down to two companies – it is time to think about the plan.

My first thought was that if we joined forces with another family then a family plan might be worth it… I built an excel spreadsheet and found two things

1) Unlimited plans would be more expensive than we are paying now

2) 2000 minute plans would only be slightly cheaper than we are paying now

(note that this is based on 2 lines with 2 data plans per family)

image

This was unacceptable when factoring in the drama that comes from working with another family (fighting over minutes, handling money, etc.) so we moved on to prepaid…

We learned that prepaid with Verizon was not an option. They charge you $10-20 for texting, plus the voice part, plus the data part. ATT prices were close to the same as Verizon but included text messages making Verizon about $10-20 more expensive.

So onto ATT prepaid. Lets first talk about data. Data options are

image

Which means nothing if you don’t know how much you use – so off to Verizon to see how much we use…

image

Ouch – line 5961 (me) is using a lot – this pre-paid thing (as far as data goes) might not work out. Line 6447 could get by with the $25 plan which is $5 cheaper than currently paying Verizon. I called ATT and asked what would happen if I went over the 500MB.

“If you have money in your account, and your account configured to allow you to go over – then you will buy another 500MB.”

This is good news in the sense that I can use more than 500MB but means I would need 3 subscriptions per month totaling $75. Not so good.

But – this is all a mute point because I am not using that much anymore. At my last job we were not allowed to stream radio – so I was using Pandora through my phone. At my new job I can stream through my computer – so what is my usage like now…

image

So this usage extended out to a 30 day month, is ~260MB. Much better!

So data is $25. And the best part is… because I am not under contract (by going prepaid) I can turn the data on and off at will. I confirmed this by calling ATT and they do not require data with a droid on a pre-paid plan. Worth noting that iPhone has some special data requirements and isn’t eligible – but this didn’t effect me so I didn’t spend any time to figure out what that meant. 

Now to the voice and messaging of pre-paid.

The basic plan is

image

this provides a benchmark for comparing to the other plans. The pay by minute plan looks like this

image

With text messaging unlimited, but only 250 voice minutes included – the question becomes how many minutes would I have to use – to be better off with the unlimited plan – in other words - what is my breakeven point. A few calculations later and we arrive at 500 minutes. This is not looking like a good fit for us.

So how about the pay by day plan.

image

This plan also has unlimited texting  so the question is how many days would I have to use my phone to be better off with the unlimited plan. At $2 / day – it is simply 25 days.

It is worth taking a pause here to explain the pay by day. If you use your phone to send or receive a call, or send a text message, that is a $2/day charge. Yes, receiving texts are free. Once you you pay for  a day, you have unlimited calls and texts.

Back to the analysis – if we can keep it under 25 days – than we would be better off with the pay per day.

So for the final analysis we need to compare the prepaid to our contract plan. Our current Verizon bill $135 – we have already decided to remove one data plan at $30 so we arrive at $105. Prepaid monthly would be $50 per phone + $25 for one data plan. Totaling $125… but what about pay per day.

The breakeven point for pay per day with one data plan at $25 and 2 phones paying $2 / day is 20 days per phone.

Our conclusion:

We are committed to bringing down our cell bill and the prepaid gives us the greatest flexibility to do that. We like that if we are trying to save money we can easily cancel data temporarily and limit our phone usage to potentially emergency only. We would gain the option to not use our phone for a single call or text and effectively pay $0 on any given month. And during that entire month we would still have coverage and the capability to make an emergency call.

Heavy usage months would cost us $125 which is more than contract $105. But we plan on having enough savings throughout the year to offset these heavy months.

To help facilitate limited cell phone usage we are setting up google voice accounts for each of us. We will be able to make calls from a house phone using google voice (going through the internet) mitigating some of our cellular needs.  Note that Google Voice is currently free. We will not give out our cell numbers and instead give out our google voice number. We will configure Google Voice to forward to the house phone, our computers, and our cell phones. If we are unable to answer on the computer or the house phone then we can choose to answer with the cell phone.

Angela won’t have a data plan but will be able to connect her Droid over our wireless network. She will still be able to use all of her apps (like facebook) but just not while out on the road.

We will limit calls while driving and instead make those calls from home.

We ordered an Obi phone adapter so that we can connect a regular phone to our google voice account.

http://www.amazon.com/OBi110-Service-Bridge-Telephone-Adapter/dp/B0045RMEPI/ref=sr_1_1?ie=UTF8&qid=1327870783&sr=8-1

Saturday, January 7, 2012

[Book Review] Crucial Conversations: Tools for talking when stakes are high

Title: Crucial Conversations: Tools for talking when stakes are high

Author: Kerry Patterson, Joseph Grenny, Ron McMillan, Al Switzler

Link: http://www.amazon.com/Crucial-Conversations-Patterson-McMillan-Switzler/dp/B004H7422O/ref=sr_1_2?ie=UTF8&qid=1325958089&sr=8-2

Crucial Conversations: Tools for Talking When Stakes are High by Kerry Patterson, Joseph Grenny, Ron McMillan, Al Switzler

Overall I found this book to be helpful in putting a finger on such an impossible skill as managing a Crucial Conversation. Over the years I have found myself engaged in crucial conversations where the skills described in the book are necessary but undefined. I am confident that my marriage and relationship with my children will be improved now that we can use a consistent language to manage the Crucial Conversation much more efficiently. For other crucial conversations where I cannot expect stakeholders to be aware of this language (like co-workers) - I can now review a concise cheat sheet and help steer the conversation towards a healthy output.

The authors have a diagram they intend to be a tool but I find it to be unhelpful.

image

It is clearly too abstract – probably b/c they don’t want people to skip reading their 200+ page book. Well I can’t read the book before every Crucial Conversation, so I decided to create my own.

image

In creating this, I found that I simplified some of the skills. I effectively combined the Master My Stories (not shown above) with STATE my path and explore others’ path because I feel that this should be a collaborative process where everyone is playing by the same rules. I think the authors separated it so much because some things are outside your control while exploring others’ path, but I feel like I want to be thinking about those things for both.

I also did not include Move To Action as I feel that is a separate problem. It is surely related but there are great resources that focus on just that problem and in the context of a crucial conversation, if we can get through high stakes, varied opinions, and strong emotions to come up with a solution. We can take a break, maybe even go to another cheat sheet to find a way to Move to Action.

I simplified a concept called CRIB which is meant to Make it Safe. CRIB stands for Commit to seek mutual purpose, Recognize the purpose behind the strategy,  Invent a mutual purpose, and Brainstorm new strategies. I found this to be highly repetitive and therefore overly complex. I replaced it with find common ground. This simple statement provides a great reminder if the conversation has gone to silence of violence to make it safe again by finding common ground.

I ignored one of the clever stories. I found that victim and helpless are two similar to clutter my cheat sheet. I found that when I tried to find a difference – a victim had a villain at which point its more of a villain story.

Though I know I am an improved human being after reading this book, I was disappointed during reading at how long the book is. The book is under 250 pages but could easily be under 100 pages. Much of the simplification I did in my cheat sheet was being performed by my mind while I was reading. It is disappointing to finish reading a paragraph or page and then say – wow – that didn’t really add anything new.

I do recommend this book.