Tag: ruby on rails

Getting started with Node.js

Easy as pie install of node.js.

Although Node.js is frequently mentioned as a backend alternative to Ruby on Rails it is neither a language nor a framework. Node is an asynchronous I/O library build on V8 (Google’s open source JavaScript engine). Express.js is a framework built on top of node.js and it’s a better comparison to RoR than node itself.

From Node’s site:

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

Installing node (& npm)

Donwload (on Mac get PKM) from http://nodejs.org/#download & double click easy installer 🙂

Testing node

Write a hello world example: ‘hi.js’ (from nodejs)

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Worldn');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

Execute

$ node hi.js
Server running at http://127.0.0.1:1337/

Goto http://127.0.0.1:1337/ to check out the results

No markup whatsoever. Inspecting the source code of the page will get simply:

Hello World

Done and done.

REPL

REPL (Read-Eval-Print-Loop) is an interactive shell for node that can be invocated by simply calling node with no app.js to execute. It works just like the debug console in Chrome.

$ node

> 2+3
5
> console.log('hi');
hi
undefined
> ["Hello","Word"].join();
'Hello,Word'
> 

What’s next

Testing express.js, a framework over node, installing brunch, an app assembler and scafolding tool build on top of node, integrating node backend with a front-end MV* framework such as backbone.js, etc, etc, etc…

Easy HTML5 front-end development with Middleman

An awesome tool for creating simple static sites and learning new front-end technologies. Build on top of Ruby and Sinatra.

Quote:

Middleman is a static site generator based on Sinatra. Providing dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle.

MiddlemanApp.com

Middleman can be as simple or advance as needed since developers can utilize one or more of all the technologies that it supports. It extremely simplifies the process of testing some of these technologies since it installs all of its tools and compilers at once.

HTML Support
Perfect for getting into templating languages without a full Rails app to support it (ERB, Haml,…). It also incorporates an HTML5 boilerplate to get started.

CSS Support
Auto-generates your CSS from SASS or SCSS files and supports Compass.

JS Support
Supports CoffeScript as well as plain old JS