Decreasing 64-bit Tweet ID in JavaScript

JavaScript is only able to handle integers up to 53-bit in size, here is a script to decrease tweet ID which is a 64-bit number in JavaScript without libraries or recursion, to use with max_id or since_id in Twitter API

As some of you might know, JavaScript is only able to handle integers up to 53-bit in size. This post, Working with large integers in JavaScript (which is a part of Numbers series) does a great job at explaining general concepts on dealing with large numbers in JS.

64-bit Tweet ID is "rounded" in JS
64-bit Tweet ID is “rounded” in JS

I had to do some research on the topic when I was re-writing some JavaScript code responsible for handling Twitter search in Storify editor: we had tweet duplicates in results! In this article, Working with Timelines, Twitter official documentation says:

Environments where a Tweet ID cannot be represented as an integer with 64 bits of precision (such as JavaScript) should skip this step.

So true, because id and id_str fields in a Twitter API response were different. Apparently, JavaScript engine just “rounds” inappropriately large numbers. :-( The task was complicated by the fact that I needed to subtract 1 from the last tweet’s ID to prevent its reappearance in a second search response. After the subtraction I could have easily passed the value to max_id parameter of Twitter API.

I’ve come across different solutions, but decided to write my own function which is simple to understand and not heavy on resources. Here is a script to decrease tweet ID which is a 64-bit number in JavaScript without libraries or recursion, to use with max_id or since_id in Twitter API:

function decStrNum (n) {
    n = n.toString();
    var result=n;
    var i=n.length-1;
    while (i>-1) {
      if (n[i]==="0") {
        result=result.substring(0,i)+"9"+result.substring(i+1);
        i --;
      }
      else {
        result=result.substring(0,i)+(parseInt(n[i],10)-1).toString()+result.substring(i+1);
        return result;
      }
    }
    return result;
}

To check if it works, you can run these logs:

console.log("290904187124985850");
console.log(decStrNum("290904187124985850"));
console.log("290904187124985851");
console.log(decStrNum("290904187124985851"));
console.log("290904187124985800");
console.log(decStrNum("290904187124985800"));
console.log("000000000000000001");
console.log(decStrNum("0000000000000000001"));

Alternative solution which I’ve found in a StackOverflow question was suggested by Bob Lauer, but it involves recursion and IMHO is more complicated:

function decrementHugeNumberBy1(n) {
    // make sure s is a string, as we can't do math on numbers over a certain size
    n = n.toString();
    var allButLast = n.substr(0, n.length - 1);
    var lastNumber = n.substr(n.length - 1);

    if (lastNumber === "0") {
        return decrementHugeNumberBy1(allButLast) + "9";
    }
    else {      
        var finalResult = allButLast + (parseInt(lastNumber, 10) - 1).toString();
        return trimLeft(finalResult, "0");
    }
}

function trimLeft(s, c) {
    var i = 0;
    while (i < s.length && s[i] === c) {
        i++;
    }

    return s.substring(i);
}

Now, if you’re the type of person who likes to shoot sparrows with a howitzer, there are full-blown libraries to handle operations on large numbers in JavaScript; just to name a few: BigInteger, js-numbers and javascript-bignum.

MongoDB migration with Node and Monk

Recently one of our top users complained that their Storify account is unaccessible. We’ve checked the production database and it appeared to be that the account might have been compromised and maliciously deleted by somebody using user’s account credentials. Thanks for a great MongoHQ service we had a backup database in less than 15 minutes.

Recently one of our top users complained that their Storify account was unaccessible. We’ve checked the production database and it appeares to be that the account might have been compromised and maliciously deleted by somebody using user’s account credentials. Thanks to a great MongoHQ service, we had a backup database in less than 15 minutes.
There were two options to proceed with the migration:

  1. Mongo shell script
  2. Node.js program

Because Storify user account deletion involves deletion of all related objects — identities, relationships (followers, subscriptions), likes, stories — we’ve decided to proceed with the latter option. It worked perfectly, and here is a simplified version which you can use as a boilerplate for MongoDB migration (also at gist.github.com/4516139).

Restoring MongoDB Records
Restoring MongoDB Records

Let’s load all the modules we need: Monk, Progress, Async, and MongoDB:

var async = require('async');
var ProgressBar = require('progress');
var monk = require('monk');
var ObjectId=require('mongodb').ObjectID;

By the way, made by LeanBoost, Monk is a tiny layer that provides simple yet substantial usability improvements for MongoDB usage within Node.JS.

Monk takes connection string in the following format:

username:password@dbhost:port/database

So we can create the following objects:

var dest = monk('localhost:27017/storify_localhost');
var backup = monk('localhost:27017/storify_backup');

We need to know the object ID which we want to restore:

var userId = ObjectId(YOUR-OBJECT-ID); 

This is a handy restore function which we can reuse to restore objects from related collections by specifying query (for more on MongoDB queries go to post Querying 20M-Record MongoDB Collection. To call it, just pass a name of the collection as a string, e.g., "stories" and a query which associates objects from this collection with your main object, e.g., {userId:user.id}. The progress bar is needed to show us nice visuals in the terminal.

var restore = function(collection, query, callback){
  console.info('restoring from ' + collection);
  var q = query;
  backup.get(collection).count(q, function(e, n) {
    console.log('found '+n+' '+collection);
    if (e) console.error(e);
    var bar = new ProgressBar('[:bar] :current/:total :percent :etas', { total: n-1, width: 40 })
    var tick = function(e) {
      if (e) {
        console.error(e);
        bar.tick();
      }
      else {
        bar.tick();
      }
      if (bar.complete) {
        console.log();
        console.log('restoring '+collection+' is completed');
        callback();                
      }
    };
    if (n>0){
      console.log('adding '+ n+ ' '+collection);
      backup.get(collection).find(q, { stream: true }).each(function(element) {
        dest.get(collection).insert(element, tick);
      });        
    } else {
      callback();
    }
  });
}

Now we can use async to call the restore function mentioned above:

async.series({
  restoreUser: function(callback){   // import user element
    backup.get('users').find({_id:userId}, { stream: true, limit: 1 }).each(function(user) {
      dest.get('users').insert(user, function(e){
        if (e) {
          console.log(e);
        }
        else {
          console.log('resored user: '+ user.username);
        }
        callback();
      });
    });
  },

  restoreIdentity: function(callback){  
    restore('identities',{
      userid:userId
    }, callback);
  },

  restoreStories: function(callback){
    restore('stories', {authorid:userId}, callback);
  }

  }, function(e) {
  console.log();
  console.log('restoring is completed!');
  process.exit(1);
});

The full code is available at gist.github.com/4516139 and here:

var async = require('async');
var ProgressBar = require('progress');
var monk = require('monk');
var ms = require('ms');
var ObjectId=require('mongodb').ObjectID;

var dest = monk('localhost:27017/storify_localhost');
var backup = monk('localhost:27017/storify_backup');

var userId = ObjectId(YOUR-OBJECT-ID); // monk should have auto casting but we need it for queries

var restore = function(collection, query, callback){
  console.info('restoring from ' + collection);
  var q = query;
  backup.get(collection).count(q, function(e, n) {
    console.log('found '+n+' '+collection);
    if (e) console.error(e);
    var bar = new ProgressBar('[:bar] :current/:total :percent :etas', { total: n-1, width: 40 })
    var tick = function(e) {
      if (e) {
        console.error(e);
        bar.tick();
      }
      else {
        bar.tick();
      }
      if (bar.complete) {
        console.log();
        console.log('restoring '+collection+' is completed');
        callback();                
      }
    };
    if (n>0){
      console.log('adding '+ n+ ' '+collection);
      backup.get(collection).find(q, { stream: true }).each(function(element) {
        dest.get(collection).insert(element, tick);
      });        
    } else {
      callback();
    }
  });
}

async.series({
  restoreUser: function(callback){   // import user element
    backup.get('users').find({_id:userId}, { stream: true, limit: 1 }).each(function(user) {
      dest.get('users').insert(user, function(e){
        if (e) {
          console.log(e);
        }
        else {
          console.log('resored user: '+ user.username);
        }
        callback();
      });
    });
  },

  restoreIdentity: function(callback){  
    restore('identities',{
      userid:userId
    }, callback);
  },

  restoreStories: function(callback){
    restore('stories', {authorid:userId}, callback);
  }

  }, function(e) {
  console.log();
  console.log('restoring is completed!');
  process.exit(1);
});
           

To launch it, run npm install/update and change hard-coded database values.

Wintersmith — Node.js static site generator

This past weekend was a very productive one for me, because I’ve started to work on and released my book’s one-page website —rapidprototypingwithjs.com. I’ve used Wintersmith to learn something new and to ship fast. Wintersmith is a Node.js static site generator. It greatly impressed me with flexibility and ease of development. In addition I could stick to my favorite tools such as Markdown, Jade and Underscore.

This past weekend was a very productive one for me, because I’ve started to work on and released my book’s one-page website —rapidprototypingwithjs.com. I’ve used Wintersmith to learn something new and to ship fast. Wintersmith is a Node.js static site generator. It greatly impressed me with flexibility and ease of development. In addition I could stick to my favorite tools such as Markdown, Jade and Underscore.

Wintersmith is a Node.js static site generator

Why Static Site Generators

Here is a good article on why using a static site generator is a good idea in general, An Introduction to Static Site Generators. It basically boils down to a few main things:

Templates

You can use template engine such as Jade. Jade uses whitespaces to structure nested elements and its syntax is similar to Ruby on Rail’s Haml markup.

Markdown

I’ve copied markdown text from my book’s Introduction chapter and used it without any modifications. Wintersmith comes with marked parser by default. More on why Markdown is great in my old post, Markdown Goodness.

Simple Deployment

Everything is HTML, CSS and JavaScript so you just upload the files with FTP client, e.g., Transmit by Panic or Cyberduck.

Basic Hosting

Due to the fact that any static web server will work well, there is no need for Heroku or Nodejitsu PaaS solutions, or even PHP/MySQL hosting.

Performance

There are no database calls, no server-side API calls, no CPU/RAM overhead.

Flexibility

Wintersmith allows for different plugins for contents and templates and you can even write you own plugin.

Getting Started with Wintersmith

There is a quick getting started guide on github.com/jnordberg/wintersmith.

To install Wintersmith globally, run NPM with -g and sudo:

$ sudo npm install wintersmith -g

Then run to use default blog template:

$ wintersmith new <path>

or for empty site:

$ wintersmith new <path> -template basic

or use a shortcut:

$ wintersmith new <path> -T basic

Similar to Ruby on Rails scaffolding Wintersmith will generate a basic skeleton with contents and templates folders. To preview a website, run these commands:

$ cd <path>
$ wintersmith preview
$ open http://localhost:8080

Most of the changes will be updates automatically in the preview mode except for the config.json file.

Images, CSS, JavaScript and other files go into contents folder.
Wintersmith generator has the following logic:

  1. looks for *.md files in contents folder,
  2. reads metadata such as template name,
  3. processes *.jade templates per metadate in *.md files.

When you’re done with your static site, just run:

$ wintersmith build

Other Static Site Generators

Here are some of the other Node.js static site generators:

More detailed overview of these static site generators is available in the post, Node Based Static Site Generators.

For other languages and frameworks like Rails and PHP take a look at Static Site Generators by GitHub Watcher Count and the “mother of all site generator lists”.

Call for Reviewers and a Free Copy of Rapid Prototyping with JS

Get a free copy of Rapid Prototyping with JS and provide us your competent feedback to help prepare for the new revision and publishing on Amazon.com. First 50 people to submit an application and qualify will receive a coupon for free download of Rapid Prototyping with JS.

Call for Reviewers and a Free Copy

Get a free copy of Rapid Prototyping with JS and provide us your competent feedback to help prepare for the new revision and publishing on Amazon.com. First 50 people to submit an application and qualify will receive a coupon for free download of Rapid Prototyping with JS.

  1. Fill a short form and wait for the coupon;
  2. Download the book for free on LeanPub;
  3. Send your feedback to (instructions will be provided later).

About Rapid Prototyping with JS

Rapid Prototyping with JS is a hands-on book which introduces you to rapid software prototyping using the latest cutting-edge web and mobile technologies including NodeJS, MongoDB, BackboneJS, Twitter Bootstrap, LESS, jQuery, Parse.com, Heroku and others.

50% Off During Holidays

By the way, you can get Rapid Prototyping with JS ebook in PDF, Kindle/Mobi, iPad/ePub formats and future updates for 50% off during holidays at https://leanpub.com/rapid-prototyping-with-js/.

Rapid Prototyping with JS is out!

Rapid Prototyping with JS is a hands-on book which introduces you to rapid software prototyping using the latest cutting-edge web and mobile technologies including NodeJS, MongoDB, BackboneJS, Twitter Bootstrap, LESS, jQuery, Parse.com, Heroku and others.

The Book is on LeanPub

Rapid Prototyping with JS is a hands-on book which introduces you to rapid software prototyping using the latest cutting-edge web and mobile technologies including NodeJS, MongoDB, BackboneJS, Twitter Bootstrap, LESS, jQuery, Parse.com, Heroku and others.

The book has 84 pages (in PDF format) or 13,616 words to be precise, step-by-step set-up, best practice advices, web development overview, 11 code examples (also available ready-to-go in GitHub repository azat-co/rpjs), flexible pricing ($9.99–19.99).

Order your copy of Rapid Prototyping with JS at LeanPub: leanpub.com/rapid-prototyping-with-js.

Rapid Prototyping with JS
Rapid Prototyping with JS: Learn how to build web and mobile apps using JavaScript and Node.js

LeanPub platform allows readers to receive infinite future updates (current version of the book is 0.3) and read the book in the most popular digital formats: PDF, ePub/iPad, MOBI/Kindle. The PDF version has footnote links which make it suitable for printing.

Download a free sample at samples.leanpub.com/rapid-prototyping-with-js-sample.pdf.

What Readers Say

Rapid Prototyping with JS is being successfully used at StartupMonthly as a training manual. Here are some of our trainees’ testimonials:

“Thanks a lot to all and special thanks to Azat and Yuri. I enjoyed it a lot and felt motivated to work hard to know these technologies.” — Shelly Arora

“Thanks for putting this workshop together this weekend… what we did with Bootstrap + Parse was really quick & awesome.” — Mariya Yao

“Thanks Yuri and all of you folks. It was a great session – very educative, and it certainly helped me brush up on my Javascript skills. Look forward to seeing/working with you in the future.” — Sam Sur

Who This Book is For

The book is designed for advanced-beginner and intermediate level web and mobile developers: somebody who has just started programming and somebody who is an expert in other languages like Ruby on Rails, PHP, and Java and wants to learn JavaScript and Node.js.

Rapid Prototyping with JS, as you can tell from the name, is about taking your idea to a functional prototype in the form of a web or a mobile application as fast as possible. This thinking adheres to the Lean Startup methodology. Therefore, this book would be more valuable to startup founders, but big companies’ employees might also find it useful, especially if they plan to add new skills to their resume.

Prerequisite

Mac OS X or UNIX/Linux systems are highly recommended for this book’s examples and for web development in general, although it’s still possible to hack your way on a Windows-based system.

Contents

Acknowledgment

Introduction

  1. Who This Book is For
  2. Prerequisite
  3. What to Expect
  4. Notation
  5. Web Basics: Hyper Text Markup Language, Cascading Style Sheets, JavaScript
  6. Agile Methodologies: Scrum, Test-Driven Development, Continuous Deployment, Paired Programming
  7. Node.js
  8. NoSQL and MongoDB
  9. Cloud Computing
  10. HTTP Requests and Responses
  11. RESTful API

Getting Started

  1. Development Folder
  2. Browsers
  3. IDEs and Text Editors
  4. Version Control Systems
  5. Local HTTP Servers
  6. Database: MongoDB
  7. Other Components: NodeJS, jQuery, LESS
  8. SSH Keys
  9. GitHub
  10. Windows Azure
  11. Heroku
  12. Cloud9

Building Front-End Application

  1. JSON
  2. AJAX
  3. Cross-Domain Calls
  4. jQuery
  5. Twitter Bootstrap
  6. LESS
  7. BackboneJS
  8. Example of using Twitter REST API and jQuery
  9. Parse.com
  10. Message Board with Parse.com
  11. Message Board with Parse.com: REST API and jQuery version
  12. Pushing to GitHub
  13. Deployment to Windows Azure
  14. Deployment to Heroku
  15. Message Board with Parse.com: JavaScript SDK and BackboneJS version
  16. Deploying Message Board to PaaS
  17. Enhancing Message Board
  18. Building Back-End Application

Building “Hello World” in NodeJS

  1. NodeJS Core Modules
  2. Node Package Manager
  3. Deploying “Hello World” to PaaS
  4. Deploying to Windows Azure
  5. Deploying to Heroku
  6. Message Board: Run-Time Memory version
  7. Test Case for Message Board
  8. MongoDB Shell
  9. MongoDB Native Driver
  10. MongoDB on Heroku: MongoHQ MongoHQ URL
  11. BSON
  12. Message Board: MongoDB version

Putting it All Together

  1. Different Domain Deployment
  2. Changing Endpoints
  3. Message Board Application
  4. Deployment
  5. Same Domain Deployment

Further Reading

About the Author

Order your copy of Rapid Prototyping with JS at LeanPub: leanpub.com/rapid-prototyping-with-js.

What We’ve Learned From Teaching the Trainings

A couple months ago, the team of StartupMonthly: Yuri Rabinovich and Vadim Slavin as instructors and facilitators, Micah McGraw as an assistant (thanks Micah!), and I as an instructor and author, ran another class of my Rapid Prototyping with JavaScript and NodeJS training.

From an idea to a prototype
Yuri Rabinovich – From an idea to a prototype

The training is a two and a quarter day intensive hands-on workshop designed for advanced beginner and intermediate programmers. The main goal is to take an idea to a functional prototype, known as Minimal Viable Product or just MVP in Lean Startup circles.

We cover agile software and business methodologies (Lean Startup), front-end development with modern tools (LESS, Parse.com, Git) and frameworks (BackboneJS, jQuery, Twitter Bootstrap), deployment to production with Platform as a Service (PaaS) solutions (Heroku, Windows Azure) and back-end development with highly efficient and scalable technologies (Node.js, MongoDB). You can find the detailed curriculum of Rapid Prototyping with JavaScript training: on WebAppLog blog, and on StartupMonthly website.

Rapid Prototyping with JavaScript training
Rapid Prototyping with JavaScript training

We’ve learned a great deal from our students. Here are some of the most important, in my opinion, things:

  • Trainees with different levels of programming skills have different interests and different questions. We had trainees who were asking questions about running NodeJS stack in production and on the other hand there were people who were struggling with basic examples, e.g., making AJAX JavaScript call.
  • We still stayed competitive as a business venture even after reducing the discounts by $100 to $200, e.g., classes at Marakana are 1.5–2x more expensive; therefore rising prices don’t often affect the sales.
  • Having more time to market and sell is more important than having a lower price per seat. We came to this conclusion when higher prices and two months marketing yielded better results than lower price and one month of marketing. The brand awareness of the training is still insignificant to account for it. We mostly used [StartupMonthly] network and social events, a couple hundreds of dollars on Facebook ads, posting on Hacker News, and emailing to JavaScript dev groups.
  • Full refund policy didn’t turn out to be a disaster; in fact, it might have helped us to sell out the tickets. There was only one student who requested the refund simply because he didn’t expect that the training would be so intense and not suited for total beginners in web development.
  • Setting up dev environment is not an issue with a good step-by-step manual. Thanks to the lessons we’ve learned from out previous training, more about it in this blog post — Pilot Rapid Prototyping with JavaScript and NodeJS Class, I had beefed-up the manual with more robust tutorials; and only 2 trainees showed up for our optional Friday night pre-course session to get help with setting up a development environment on their machines. This is a true Reverse teaching approach.
  • Examples usually are not interesting to some of the students. We had a more engaging class when the students worked on their own ideas rather than code examples from the manual. Because examples are boring, people copy/paste code instead of writing it. Which leads to…
  • Copy/paste students complete assignments faster, but some of them have no idea how basic stuff works :-( It came to no-surprise that those trainees experienced barrage of difficulties when they tried to work on their own ideas or to implement additional functionality on top of the examples provided in the manual.
  • Advanced students skipped the second day, on which we had fun with NodeJS and MongoDB. Bummer! They were only interested in front-end JavaScript prototyping to complement their Ruby on Rails or Java back-end skills, hence the demand for separate front-end training exists.
Rapid Prototyping with JavaScript training
Rapid Prototyping with JavaScript training

Recently, I had a conversations with a new technical education company, Catalyst, which takes people from zero to employment; something similar to Dev Bootcamp but for JavaScript, including technologies like jQuery, CoffeeScript, NodeJS, etc.
We concluded that with materials widely available in a form of books, screencasts, GitHub repositories, and other mediums, learning technical skills come down to motivation. And motivation comes mostly from self-identity. For example, if I self-identify myself as a developer (or engineer, programmer, hacker), I could stay up all night fixing bugs, hacking around an obscure platform limitation, or trying to meet a deadline; however, if I wear an entrepreneurial hat, I’m more inclined to look at the bigger picture and either to defer the issue or to delegate it to a more experienced person. Therefore, entrepreneurial types usually less motivated to solve pure technical problems.

In our next iteration of the Rapid Prototyping with JavaScript and NodeJS trainings we plan to change our approach from education to coaching by:

  • Extending the format from two days to three to four days;
  • Accepting only those teams of two to three people or one-man-band-type individuals who already have an idea;
  • Packaging training materials in a self-study kit starting with a Rapid Prototyping with JavaScript book.

Students will work on their ideas while tapping into mentorship and experience of industry leading practices in both technical and Lean Startup methodologies. Exact dates and location of the next trainings will be announced on StartupMonthly website and on my blog — WebAppLog.com.

What is Accelerator.IO?

It’s a new social network for entrepreneurs with productivity tools based on Lean Startup methodology. Accelerator.IO is a niche social network similar to dribbble, which is for designers, and Forrst, which is for developers. Main focus for us, team of Accelerator.IO, is to provide valuable tools and content for startupers, founders, hackers and hustlers by connecting them with mentors, investors and most importantly fellow entrepreneurs across the globe. It is important to state that Accelerator.IO is not a competitor to AngelList but rather a complimentary tool. In fact, we leverage AngelList API to gather entrepreneurial information about users such as company name and website URL. In a sense Accelerator.IO is a global online co-working space where smart and bright minds collaborate and learn from each others failures and successes.

Accelerator.IO
Accelerator.IO

The key features of Accelerator.IO:

  • curated access and content moderation to keep discussions interesting and engaging;
  • access to global network of like-minded people;
  • leveraging AngelList API for easier adoption;
  • reliance on the over 6,000 people network of StartupMonthly fund and startup accelerator, across Silicon Valley/San Francisco, Middle East and Europe;
  • productivity tools for entrepreneurs and startups founders based on Lean Startup methodology.

Right now Accelerator.IO is in beta testing. We accept early access sign ups and beta testers at http://signup.accelerator.io.

Last but not least, if you are looking for a side-project to pick-up a new skills in web and mobile development, or get a free access to startup social events and get exposure on web — Accelerator.IO is accepting volunteers: JavaScript developers, front-end or back-end (we’ll teach you Node.js if you’re only front-end dev right now).

This website is not intended for use with JavaScript disabled

I’m working on materials for technical workshop. The topic is “Rapid Prototyping with JavaScript”. It is mostly about jQuery, Backbone, AJAX, RESTful APIs, NodeJS and MongoDB. So a lot of JavaScript on a client side and today I was asked a question by curious friend who saw my frequent updates about the event on Facebook:

“What about users who has JavaScript disabled?”

The questions made my smile and I intuitively answered:

“It’s 2012, right? The number of such users must be insignificant”.

And later I proved to be right — only 2% of Yahoo.com users have JavaScript disabled.

Another article shows why Yahoo.com data is a good source. It has almost all of the countries covered so we can get average numbers and numbers per each country.

But I wanted to analyze the change. Just about 5 years ago companies seriously considered not to innovate AJAX-y way so they can please non-JavaScript users. Now, I barely hear about such non-sense. Even the opposite is true – startups limit their environments to only WebKit browsers. What happened to that attitude? How did that happened? One theory is that Chrome and Firefox became more popular and an update to the newer and faster versions became just a click away or even automatic in most (default) cases. JavaScript de-facto became a web standard. Not using JS is a misfit.

I can’t imagine my life without Google Docs, GMail, Facebook chat and other wonderful things which are brought to us but small scripting language which started in 1995 at Netscape as a way to make text blink if not for the XMLHTTPRequest object. Brilliant minds even overcame cross-origin limitation with dynamically injecting script tags into to DOM. This technique is known as JSONP. But that is me — sort of advanced user.

Just a few days ago Adobe announced on 5th anniversary of iPhone release, which never supported Adobe Flash, that they will discontinue support of Flash plug-in in new Android 4.1, Jelly Bean. This event completes triumph of JavaScript as cross platform tool for web and mobile development.

For those unfortunate people (2% of Yahoo.com users) and search engine bots I must remember to put noscript into my HTML:

<noscript>
    This website is not intended for use with JavaScript disabled.
    Unless you are a googlebot, telnet or i486-PC user, please go get the latest version of Chrome.
</noscript>

One side note: mission critical applications without control over clients’ environment, corporate and government organizations which must try to server all users still have to take into account a lot of things which consumer facing and startup companies could get away with. Being section 508 complaint also falls into this category.

Super Simple Backbone Starter Kit / Boilerplate

During AngelHack, more details in my previous blog post, I struggled to find simple BackboneJS Boilerplate to start building our fashion prototype quickly.
If you are not familiar with BackboneJS it is a very powerful MVC framework for building thick client applications. It has fully RESTful API support via it’s model methods. So after half an hour of going through Backbone Boilerplate and other samples and tutorials I ended up using Sample App with Backbone.js and Twitter Bootstrap as a foundation.

So after this experience I decided to come up with my own super simple BackboneJS boilerplate or starter kit. It has bare minimum but all the necessary components:

To make it work just download zip or fork and clone it from GitHub.com: https://github.com/azat-co/super-simple-backbone-starter-kit. Then launch index.html in your favorite HTTP web server.

It’s a single-file application. Everything Backbone related is in app.js. Templates are in separate files and loaded via RequireJS, and Text plug-in for RequireJS.