-
Recent Posts
Tags
Categories
Recent Comments
- rp on Riak vs CouchBase
- Typo 6.1 Exporter for Wordexpress | Competo Tech Blog on Migrating a blog from Typo 6 to WordPress 3.4
- Migrating a blog from Typo 6 to Wordpress 3.4 | Competo Tech Blog on Migrating a blog from Typo 6 to WordPress 3.4 (imported)
- rp on Migrating a blog from Typo 6 to WordPress 3.4 (imported)
- rp on Migrating a blog from Typo 6 to WordPress 3.4
Archives
Tag Archives: coffeescript
“Synchronous” MongoDB Calls with Fibers
Here I’m showing an example of converting MongoDB node driver into “synchronous” APIs from callback based asynchronous APIs. We define two new classes to wrap up the native Db and Cursor. Two methods are converted: Db.Open and Cursor.toArray. The “sync” … Continue reading
Posted in JavaScript, Node.js, NoSQL
Tagged coffeescript, fibers, mongodb
Comments Off on “Synchronous” MongoDB Calls with Fibers
Node-Fibers Example
With node-fibers, we can write codes in traditionally synchronous fashion and avoid deep nested callback calls without blocking the Node event loop. Below is an example to generate Fibonacci series. Each run resumes the calculation loop and returns a number … Continue reading
Mindful of CoffeeScript Function Return Value
Here’s a gotcha if you’re not careful when writing CoffeeScript. Notice the generated js code where constructor now returns this._cursor!! #c.coffee Cursor = (cursor) -> this._cursor = cursor 0 // c.js 1 // Generated by CoffeeScript 1.6.2 2 (function() … Continue reading
Posted in General, JavaScript
Tagged coffeescript
Comments Off on Mindful of CoffeeScript Function Return Value
Encapsulation in Coffee Script
m.coffee ——— publicMethod1 = -> @publicMember1 = "public member 1" @publicMember2 = "public member 2" console.log ‘publicMethod1***’ console.log ‘*’ + @publicMember1 publicMethod2 = -> console.log ‘publicMethod2***’ @publicMethod1() console.log ‘*’ + @publicMember2 class Foo … Continue reading
Write Module in Coffee Script for Node
There are a few ways to write a module in Coffee Script for Node. Below are two ways to contrast their usages. Notice how they share data @url and use function @find. 1. user.coffee ————- class User constructor: (url) … Continue reading
Function call in CoffeeScript
Here’s a little hassle in CoffeeScript syntax. Calling a function with parameter but without parentheses is fine. Below sample code works. express = require ‘express’ app = express() app.configure -> app.use express.bodyParser() app.use express.methodOverride() app.use app.router app.get … Continue reading