Categories
Uncategorized

Nodejs in Heroku: the super duper installation guide

1) Install node.js https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

2) Install express framework:

$ sudo npm install -g express@2.5.8

Note: if you get an error message at this point, complaining about some “Karma” package. Run the following

$ npm uninstall -g generator-karma && npm install -g generator-angular

3) Create your application:

$ express my_app

$ cd my_app && npm install

4) Login your heroku (if you haven’t), and start git

$ heroku login

$ git init; git add .; git commit -am “whatever you want to say”

5)

 

 

Categories
Responsive Web Design (RWD)

RWD: Responsive web design recipes

1) Make an image size responsive to the page size.

– Set the parent container to an adjustable width, either via media queries, or percentages.

– Set the image itself to width: 100%, height: auto. So it will grow as the parent container does.

 

Categories
JavaScript

JavaScript: code organization template

If not working with a framework, try the following:

$(function() {
  function MyFunction() {
  }

  MyFunction.prototype = {
    myMethod: function() {
    }
  };

  var myInstance = new MyFunction();
});

If you are looking for something simpler, kind of a one quick page deal:


var GLOBAL_NAMESPACE_HERE = (function () {
    var _private_obj_name_here = {
        // settings and defaults here
        key_here: value_here
    };

    /********************************************************************
     * Initialization:
     * Starts the listeners and get things rolling
    */
    _private_obj_name_here.init = function () {
    };

    /********************************************************************
     * Getters, other stuff
    */
    _private_obj_name_here.getSomething = function () {
        return _private_obj_name_here.key_here;
    };

    /********************************************************************
     * Expose public methods (the ones that can be called from outside)
    */
    return {
        init : _private_obj_name_here.init,
        getSomething: _private_obj_name_here.getSomething
    };

}());

This is called the module pattern.

GLOBAL_NAMESPACE_HERE.init();