CoffeeScript: The Good Parts

It’s not a secret that the topic of CoffeeScript is controversial to say the least. Many reputable JavaScript and Node.js developers just hate CoffeeScript, but there are lessons we can all learn from its good parts! However, many developers just won’t go back to plain JavaScript after building something relatively serious with CoffeeScript.

Continue reading “CoffeeScript: The Good Parts”

Intro to OAuth with Node.js: OAuth 1.0 (One-Legged)

This text is part of Introduction to OAuth with Node.js mini-book which is available at gum.co/hRyc.

Introduction to OAuth with Node.js
Introduction to OAuth with Node.js: Twitter API OAuth 1.0, OAuth 2.0, OAuth Echo, Everyauth and OAuth 2.0 Server Examples

Let’s start with good old OAuth 1.0. The way it usually works is as follows:

  1. For the first time, when we authorize a user to use our app, we need to perform extra work and obtain access token and secret (three-legged).
  2. You store these values for each user in your application.
  3. Then, on subsequent requests, things become much simpler. We construct auth headers and make HTTP requests (one-legged).

Continue reading “Intro to OAuth with Node.js: OAuth 1.0 (One-Legged)”

Practical Node.js is Ready!

My latest book about Node.js is ready (Jul, 2014)!

Practical Node.js was designed to be a one-stop source for going from hello-world examples to building apps in a professional manner. The libraries covered in Practical Node.js greatly enhance the quality of code and make developers more productive.

You can get it on Amazon, B&N and Apress directly. Also, Apress has the ebooks in all formats.

The book’s website is at practicalnodebook.com. And the examples’ code is freely available at github.com/azat-co/practicalnode.

Why Node Program is Different

Node Program is the  fastest and most engaging way  to get started with Node.js, MongoDB and Express.js. It’s an  intensive  weekend-long  live course  taught in the Bay Area by skilled experts who have run Node.js in production  for years!

Node Program is the ultimate way to get up and running with the foundations of Node.js, by learning the required foundational skills to use Node.js! Learn more about our approach and curriculum.

Continue reading “Why Node Program is Different”

The Nastiest Little Secret

The nastiest little secret about software engineering job search, in any time and geolocation that I’ve seen: virtually everybody wants senior developers. So there’s very little chase to get into the industry. One theory this catch 22 happens is because senior software engineers are 10-20x more productive with only 10-30% more pay. Or at least that’s what most of the companies think. I’m not sure this is true 100% of the time. Therefore, if you are a junior developer—fake it till you make it. Most of us have been there. Become an expert in one field, and make a name for yourself. Then the companies will fight for you. Networking also helps. You need to be considered for the job before the job opening has been posted to the company’s website.

Seven Things You Should Stop Doing with Node.js

Inspired by 5 Things You Should Stop Doing With jQuery by Burke Holland, I decided to open a discussion and highlight seven things you should immediately stop doing with Node.js:

  1. Stop using callbacks
  2. Stop using * for versions
  3. Stop using console.log for debugging
  4. Stop using GET and POST for everything
  5. Stop using semicolons
  6. Stop using comma-first style
  7. Stop limiting your connections with default maxSockets value

Continue reading “Seven Things You Should Stop Doing with Node.js”

Intellect as an Impediment to Successful Marketing and Selling

After watching The Foundation video it struck me that an intellect can be an impediment to successful marketing and selling. I’ve heard some variation of this before but the aforementioned video was an aha moment when it all came together.

Have you ever heard about the curse of knowledge? Or cognitive bias? Basically, if a person knows something he/she assumes that everybody else also know that. This leads to omissions, assumptions and messages that don’t reach target audience. And it’s not because the average audience is stupider in general, they’re just not so fluent in this particular narrow topic and your language (The Secret Language Of Millionaires in the video). I have to fight myself tooth and nail with this bias when I’m writing my programming books!

Sharing my musings on Twitter led me to Steve Jobs who no doubt was intelligent and very good at marketing:

I think smart people have to work extremely hard to “dumb” down their marketing messages. A good example is the original Apple iPod ad that used X number of songs instead of Y number of Megabytes.

Original Apple iPod
Original Apple iPod

Another revelation was that all this time many people that I know (startupers) and I were doing it all wrong. Almost always we start with products instead of starting with problems. In the best case, we pick out our own problems to solve (some do it successfully, like Evernote founders). But where are the guarantees that our problems are not just emotionally exaggerated and the market for them is big enough? Instead we should identify the pain points first and try to pre-sell. Yes, pre-selling (before building) can solve this dilemma. Let consumers vote with their wallets (actually debit/credit cards). What if we can’t sell our service or product without it being ready, or without all the fluff like a catchy domain name, fabulous design, beautiful logo and half-a-dozen social media profiles? Then, the problem is not too big for us to work on it anyway. Not all ideas should be executed and not all problems are worth solving. :-)

Last night, I did exactly that. I created a Gumroad page for Introduction to Express.js video course. It took me half an hour, and it already has sales! The conclusion is to go lean early or suffer later.

CoffeeScript FUNdamentals: The Better JavaScript

Disclaimer: This text is a part of the JavaScript and Node FUNdamentals: A Collection of Essential Basics ebook which is available now for free. However, upon the book’s completion it’ll be priced at $2.99. The book is 80% done as of this writing. The formats available: PDF, EPUB and Kindle. If you would like to participate in the writing process by providing your feedback and future topics, fill this short Future Topics and Feedback form.

Continue reading “CoffeeScript FUNdamentals: The Better JavaScript”

Migrating Express.js 3.x to 4.x: Middleware, Route and Other Changes

Express.js 4 is the latest (as of May 2014) version of the most popular mature and robust Node.js framework for web apps, services and APIs. There are some breaking changes going from 3.x to 4.x, so here’s a brief migration guide:

Continue reading “Migrating Express.js 3.x to 4.x: Middleware, Route and Other Changes”

Express.js 4, Node.js and MongoDB REST API Tutorial

Usually good things don’t stay the same, so our tutorial on building a JSON REST API server with Node.js and MongoDB using Mongoskin and Express.js, and testing it with Mocha and Superagent, has became a bit outdated with the new Express.js 4 version release. Here’s a brand new, revisited tutorial for Express.js 4, Node.js and MongoDB (Mongoskin) free-JSON RESTful API server.

The code for this new tutorial is available at github.com/azat-co/rest-api-express (master branch). The old tutorial’s code for Express 3.x, is still working and in the express3 branch.

Express.js 4 and MongoDB REST API Tutorial consists of these parts:

  1. Node.js and MongoDB REST API Overview
  2. REST API Tests with Mocha and Superagent
  3. NPM-ing Node.js Server Dependencies
  4. Express.js 4.x Middleware Caveat
  5. Express.js and MongoDB (Mongoskin) Implementation
  6. Running The Express.js 4 App and Testing MongoDB Data with Mocha
  7. Conclusion and Further Express.js and Node.js Reading

Instead of TL;DR:

If you’re only interested in a working code from the repository and know what to do, here are brief instructions on how to download and run the REST API server:

$ git clone git@github.com:azat-co/rest-api-express.git
$ npm install
$ node express.js

Start MongoDB with $ mongod. Then, in a new terminal window run the Mocha tests:

$ mocha express.test.js

Or, if you don’t have mocha installed globally:

$ ./node_modules/mocha/bin/mocha express.test.js

Node.js and MongoDB REST API Overview

This Node.js, Express.js and MongoDB (Mongoskin) tutorial will walk you through writing the test using the Mocha and Super Agent libraries. This is needed for a test-driven development building of a Node.js free JSON REST API server.

The server application itself will utilize Express.js 4.x framework and Mongoskin library for MongoDB. In this REST API server, we’ll perform create, read, update and delete (CRUD) operations and harness Express.js middleware concept with app.param() and app.use() methods.

First of all, make sure you have MongoDB installed. You can follow the steps on the official website.

We’ll be using the following versions of libraries:

  • express: ~4.1.1
  • body-parser: ~1.0.2
  • mongoskin: ~1.4.1
  • expect.js: ~0.3.1
  • mocha: ~1.18.2
  • superagent: ~0.17.0

If you try to attempt to use later or older versions the code might not work. :-(

Continue reading “Express.js 4, Node.js and MongoDB REST API Tutorial”

CoffeeScript Quirks

CoffeeScript is a solution without the problem.

— Unknown ironic source.

CoffeeScript is awesome, until it’s totally confusing, and it’s illogical, which can lead to unexpected and subtle bugs. If you’re one of the CoffeeScript haters please skip this post; for others, I’ll share a few notes on the CS quirks that I’ve observed.

For example, let’s say we have a counter and need to assign a value of index subtracted by one to it:

numberOfRadios = index -1

But the line above is not the same as:

numberOfRadios = index - 1

Did you notice that there’s a space after the minus sign in the second example? It took me awhile to track down this type of bug. The reason for this behavior is that the first line will be converted by the compiler to the function invocation and that is probably not what you wanted.

Try the minus one snippet on CoffeeScript.org. It outputs the following JavaScript code:

var numberOfRadios;

numberOfRadios = index(-1);

numberOfRadios = index - 1;

Another pitfall, that leads to writing despondently inconsistent code (by us developers), is caused by the fact that parentheses are optional for function calls.

This example involves if conditions in which we want to compare the value of the expression model.get() or the operand typeof to some strings:

a() if @model.get 'groupType' is 'radioGroupTabs'
a() if typeof @model.get 'condition' is 'function'

CoffeeScript is treating the entire thing as an argument and the results are pathetic. Duh. ;-( Here is the native JavaScript code:

if (this.model.get('groupType' === 'radioGroupTabs')) {
  a();
}

if (typeof this.model.get('condition' === 'function')) {
  a();
}

Placing parens over the function still does us no good. Look at this CoffeeScript code:

a() if @model.get ('groupType') is 'radioGroupTabs'

And its JavaScript output:

if (this.model.get('groupType' === 'radioGroupTabs')) {
  a();
}

The workaround involves using () around function calls, or flipping the order in the if statement so that the function invocation is the last bit of code in the if statement:

a() if (typeof @model.get 'condition') is 'function'
a() if 'function' is typeof @model.get 'condition'
a() if (@model.get 'groupType') is 'radioGroupTabs'
a() if 'radioGroupTabs' is  @model.get ('groupType')

The code above compiles to what we wanted originally:

if ((typeof this.model.get('condition')) === 'function') {
  a();
}

if ('function' === typeof this.model.get('condition')) {
  a();
}

if ((this.model.get('groupType')) === 'radioGroupTabs') {
  a();
}

if ('radioGroupTabs' === this.model.get('groupType')) {
  a();

Is it all good now? Not really, because I personally think this approach leads to inconsistencies: parts of CoffeeScript code that must have parentheses, while in other places they are optional.

Try these if conditon snippets yourself on CoffeeScript.org.

The next note explains the most common beginner’s mistake in CoffeeScript; that is to use an a instead of an a() for function calls. However, super inside of a class, must be called without parentheses in order to pass the arguments to it.

Moving on to the single hash (#) comments which are just skipped over by CoffeeScript. Again, this can lead to unexpected consequences.

For example, a straightforward if statement has a few lines of code:

unless A 
  b()
  blah blah

But if we comment out all of the lines inside of if, the whole thing will fail miserably at the compilation step (at least thank you for that, CoffeeScript!):

unless A 
  # b()
  # blah blah

Just by adding an empty else we can mitigate the failure:

unless A 
  # b()
  # blah blah
else


c() # the code continues here

Try this snippet yourself on CoffeeScript.org

Last but not least, there is another CoffeeScript pitfall related to jQuery events that don’t propagate when the event handler returns false. Of course, CoffeeScript philosophy makes every function an expression (the last statement is evaluated if there is no return statement present).

b = ()->
  false # usually this result is less obvious and buried deep down in code
$a = $ 'input'
$a.click ()->
  console.log 'this happens all right'
  b()

$a.parent().click ()->
  console.log('this never happened')

Of course, in real life the b() function is not so obvious and it’s buried somewhere deep within Backbone and Angular model methods. And the event isn’t propagating up the DOM tree (return false). Therefore, we’ve lost the second event handler without even realizing t. Buyers beware of this elusiveness! :-)

Try the event propagation bug yourself on CoffeeScript.org

This is the end of my list. If you know of any additional CoffeeScript idiosyncrasies, please send them my way. :-)

Further CoffeeScript reading:

DocuSign for BlackBerry 10 in a Few Hours

Last week DocuSign engineering had a second internal hackathon (a nice collage resulting from the first one) and I built DocuSign for BlackBerry 10 in just a few hours (well, sort of).

Some of you might be wondering what BlackBerry is. It’s a mobile operating system that is actually in the process of surpassing Windows and Kindle, based on market share, according to this reputable study. Oh, and by the way, BB also has many loyal aficionados thanks to their years of being a mobile solo-provider to enterprises.

Luckily, DocuSign already had an app for Android and, based on my research, which consisted of looking at this page for a minute, and talking with our mobile dev manager, I figured out that I could just port the DocuSign for Android app to the BlackBerry OS. Porting is just a fancy word for re-writing something in a new language, or for a new platform, without changing functionality very much. It typically involves re-compiling, changing APIs, updating code and re-packaging.

It’s worth noting that RIM (the company behind BlackBerry) provides many other options for building BlackBerry 10 apps including:

  • Adobe AIR
  • Native
  • HTML5

This is probably done to boost the number of available offerings within their marketplace (BlackBerry World) and jump-start their development ecosystem, which is lagging far behind those of iOS and Android.

I have worked with Java and J2EE before. In addition, I was an Adroid guy for a long time prior to getting my first Apple product (MacBook Air): I remember that my very first smartphone (running buggy Android 1.6) had constant “Force Close” errors. However, up until this hackathon, all of my forays into mobile dev land consisted only of using HTML5 with the Jo and Sencha Touch frameworks. Awesome challenge! Or so I thought.

The goal was to use Android code, re-package it, and install it in the simulator (with or without changes). I decided to go with Android Studio vs. Eclipse, and downloaded these tools (download page):

The complete tutorials are available at Runtime for Android apps.

After downloading, literally, a few gigabytes of SDKs and packages, I was stuck with our code-base in Android Studio due to some Java exceptions regarding Gradle, so I resorted to using command-line tools.

These are the commands from the BlackBerry toolchain that I ended up using:

  • apk2barVerifier: to verify apk (Android) files for compatibility for bar (BlackBerry)
  • apk2bar: to re-package apk to bar
  • blackberry-deploy: to upload and install the app on a BlackBerry

It’s worth noting that for distributing BlackBerry 10 apps to the BlackBerry world, apps must be signed with a special token (tutorial). Obviously, I skipped this step for the hackathon.

Lo and behold, everything worked on the BlackBerry with 0 code changes (except where DocuSign tries to charge via Google Play). The end results were quite pleasing. Thank you BlackBerry for making it easier for us developers. I guess, I can now say that I develop native apps (yeah, right). :-)

DocuSign for BlackBerry 10: Homescreen
DocuSign for BlackBerry 10: Homescreen
DocuSign for BlackBerry 10: Sign a Document
DocuSign for BlackBerry 10: Sign a Document
DocuSign for BlackBerry 10: Main Menu
DocuSign for BlackBerry 10: Main Menu
DocuSign for BlackBerry 10: Document View
DocuSign for BlackBerry 10: Document View

In addition, I also found this neat but scammy-looking service called APK Downloader that allows us to install Android apps from the Google Play market directly onto the latest BlackBerry 10 systems. Simply enter the name of the app as a Java package, e.g., com.docusign.ink, (link). The real hack! I could have used it from the beginning and saved myself a few hours. Therefore, it’s vital to conduct proper up-front research prior to embarking on a project! ☺

Growth Hacking The New DocuSign Experience

The DocuSign Momentum 2014 conference was a huge success, attended by over 1,200 people and filled with many announcements of new developments. One was a culmination of many years of hard work for DocuSign product engineering — the re-imagined web application dubbed the New DocuSign Experience.

The web app is fast, beautiful and well thought-through. It was a pleasure to watch its live demo on a large screens and hear tons of positive comments from glad DocuSign customers.

Being a part of the growth hacking team and its team lead / ScrumMaster, I had the chance to work on a few important features:

  • Responsive and dynamic homepage: certain sections on the homepage change based on account types and states, e.g., show “Your plan is expiring in X days” for trial users, but “You have Y documents left before reaching your limit” for freemium ones.
  • Visual notifications: special messages conveniently spread across the app, which are triggered dynamically based on user account states (similar to the dynamic homepage).
  • Analytics: removing old page-view-based tools in favor of event-based ones (go Mixpanel!).
  • In-app upgrade: before, it was not a smooth experience and required multiple logins, redirects and was a plain PITA.
  • Landing page for Sign a Document: when users self-sign docs, the recipients (CCs) see a nice page that prompts them to sign up.

Continue reading “Growth Hacking The New DocuSign Experience”

Getting Published as a Programmer: The Practical Node.js Story

This is the story about how I got my first publishing deal, what this book is about, and what problems I encountered along the way.

TL;DR: This is the story about how I got my first publishing deal, what this book is about, and what problems I encountered along the way.

I spent last weekend sitting in an awesome new coffee shop in Oakland, typing up the last two chapters of my Practical Node.js manuscript. The book is scheduled for release by the UK-based technical publisher Apress in the late spring.

I started writing the manuscript in October 2013. I devoted my weekends and holidays to it (as so many entrepreneurs and writers do). The fact that I smartly had a few example apps and some drafts written — some of them for my blog, others for proposals to Pragmatic (declined!) — helped to speed things up. (Needless to say, in publishing rejection is a common thing and often an opportunity to get better.) However, the writing itself wasn’t the hardest part. Here’s the short story why.

Continue reading “Getting Published as a Programmer: The Practical Node.js Story”

What is Growth Hacking

Growth hacking is such an interesting term. When I first heard of it, either at one of the meetings organized by 500 Startups or on the Jason Calacanis’s show, it made a lot of sense to me. Growth is vital for startups, and hacking is all about finding clever solutions (which are usually temporary but efficient).

When I became a growth hacking team lead at DocuSign, I started reading more about growth hacking. Soon I found out that there’s a ton of confusion on the Internet around the meaning of this phrase.

Some folks, especially ones who’s been doing new media and online marketing for a long time, think that it’s just a fancy trend for good old tools and techniques like:

  • A/B testing
  • Email marketing
  • Referral marketing
  • Social media marketing
  • Viral marketing
  • Content and SEO
  • Analytics

It’s true that these kinds of online marketing have been around for the last 5—15 years! What these adepts usually miss is the difference in how growth hacking approaches product by directly influencing and oftentimes even developing it!

Note: Being a programmer hacker is not required to be a growth hacker.

On the contrary, there is little to no input from marketers on product decisions in traditional marketing. For example, imagine, there are a car manufacturer and its marketing department. Most likely, the marketers will have little to no input into the car’s engineering and design.

Another example, a pure marketer might organize an email campaign, but because the funnel hasn’t been optimized, the conversion rate turns out to be dismal. On the other hand, a typical growth hacker will first test the funnel, and only after optimizing it, they launch full-blown campaigns reaping better conversion rates!

In software, and info products (and maybe in services?), the relative low cost of prototyping — vs. increasing cost of advertising and other traditional strategies — lead to the emergence of a hybrid: growth hacking. The distinct boundaries between marketing and product departments become blurred.

The best growth hacking will involve some sort of product engineering, user experience and design work, gathering and analyzing of metrics and events.

Usually there are only two tactics for growth hacking:

  • Push
  • Pull

Push tactics often involve finding temporary “loopholes” and getting a competitive advantage by using them. These are examples we often hear/read about: AirBnB posting on Craigslist, Dropbox using free space for referrals, etc.

That’s all good, but as in our example with an email campaign, if the product is not selling itself — that’s where the most ROI is for a growth hacker: pull tactics. They involve working on a funnel, and making product better to use / easier to know about expired CCs, etc. In the next post, I’ll show how my team and I growth hacked The New DocuSign Experience.

To sum it all up, there is a good quote from TNW post by GAGAN BIYANI:

Growth hackers focus on low-cost and innovative alternatives to traditional marketing, i.e., utilizing social media and viral marketing instead of buying advertising through more traditional media such as radio, newspaper, and television.

PS: I absolutely positively recommend this amazing free ebook The Definitive Guide to Growth Hacking by Neil Patel and Bronson Taylor.

How to Stay Healthy and Sane Working 12-hour Days As a Programmer

The DocuSign Momentum conference is just a few days away, and my team and I has been pulling long shift in order to deliver something absolutely amazing and to make sure that it’s in a great shape. So I wanted to share what exactly helps me stay healthy, sane, productive and happy working as a programmer 10–12 hours per day sustainably:

  • Get at least seven to eight hours of sleep
  • Skip breakfast: clears mind, reduces calories intake, and saves time
  • Check work email only a few time per day and check personal email/Facebook/LinkedIn/etc only once (in the evening) preferably inboxing zero both categories
  • Meditate and workout (12 minutes is enough)
  • Cancel all activities and avoid any additional obligations and projects
  • Wear uniform-like clothing
  • Drink lots of good coffee (e.g., bulletproof coffee)
  • Avoid fruits, sugars, sodas (even diet ones), grains, legumes and potatoes, i.e., paleo lifestyle/diet
  • Change workstations: resistance ball chair, stand-up desk, sofa, etc.
  • Consume vitamins: C, Omega–3, Multivitamins and D3
  • Take walks and stay positive!

PS: The Healthy Programmer book has been on my to-do list for a long time. Please let me know whether you read/liked it.

Succeeding with Agile, Brief Overview I

Couple months ago, I was promoted to a ScrumMaster role at DocuSign. In light of it, I decided to brush up on my agile development skills and theory by reading. My choice fell on the highly acclaimed Succeeding with Agile: Software Development Using Scrum by the guru of Agile Development and Scrum — Mike Cohn.

Succeeding with Agile
Succeeding with Agile

Here is a short overview of the first half of the book, or gist as programmers call it:

  • A ScrumMaster has more responsibility and authority over processes, but a limited authority over people; the role is akin to a fitness trainer (a yoga teacher analogy fits me better): enforcing the agile process.
  • Every sprint team needs to deliver shippable (and tested) code: features, bugs, etc.; if the task is too large — split it.
  • Developers should work with product managers/owners directly on requirements.
  • Different developers should work on all parts of the application / code base.
  • Agile is not for the developers who likes to work in privacy putting their headphone and not talking to people (Bummer). :-)
  • Team functions better with a mix of generalists and specialists; avoid all-specialists teams at all cost.
  • When possible use feature teams rather than component teams.
  • Keep teams small. Four to nine people is an optimal size due to the social loafing (having more people reduces average productivity) — this was one of the reason our DocuSign team was split into three smaller teams!
  • A non-coding architect and project manager are obsolete roles on a Scum team.
  • Don’t let team members multitask. Each additional task reduces productivity; however, after three and more tasks the reduction becomes smaller and smaller. Direct quote: “Individuals assigned to work on multiple projects inevitably get less done”

To be continued…

What I really liked about the book so far is that it’s not just boring theory. Each point is supported by data, references to sources and personal three-decade-long (anecdotal) experience of the author (Mike Cohn). If you liked the bullet point above, get Kindle Succeeding with Agile on Amazon.