Angel \”Java\” Lopez on Blog

January 10, 2012

Node.Js: Links, News And Resources (5)

Filed under: JavaScript, Links, NodeJs — ajlopez @ 7:06 pm

Previous Post
Next Post

These days, I was working with Node.js and Social Gaming. There is more support for Windows (now we have npm) and for Azure. My new links:

Case study: How & why to build a consumer app with Node.js
http://venturebeat.com/2012/01/07/building-consumer-apps-with-node/

shinuza / node-cc-module-boilerplate
https://github.com/shinuza/node-cc-module-boilerplate
A C++ module boilerplate for Node.js

Building native modules for nodeJs 0.6+ with visual studio
http://botsikas.blogspot.com/2011/12/building-native-modules-for-nodejs-06.html

tjanczuk / iisnode
https://github.com/tjanczuk/iisnode
Hosting node.js applications in IIS on Windows

WindowsAzure / azure-sdk-for-node
https://github.com/WindowsAzure/azure-sdk-for-node/
Windows Azure SDK for Node.js
This project provides a set of Node.js packages that make it easy to access the Windows Azure storage and queue services

Accessing Azure Role Environment information from NodeJS
http://nodeblog.cloudapp.net/accessing-azure-role-environment-information-from-node

Running wheat git-based blog engine on Windows Azure
http://nodeblog.cloudapp.net/running-wheat-git-based-blog-engine-on-windows-azure

Windows Azure Startup task to run npm install to avoid deploying node modules
http://nodeblog.cloudapp.net/startup-task-to-run-npm-in-azure

KABA-CCEAC / nodeEventStore
https://github.com/KABA-CCEAC/nodeEventStore
EventStore Implementation in node.js

I/O Completion Ports
http://msdn.microsoft.com/en-us/library/aa365198(VS.85).aspx
I/O completion ports provide an efficient threading model for processing multiple asynchronous I/O requests on a multiprocessor system. When a process creates an I/O completion port, the system creates an associated queue object for requests whose sole purpose is to service these requests. Processes that handle many concurrent asynchronous I/O requests can do so more quickly and efficiently by using I/O completion ports in conjunction with a pre-allocated thread pool than by creating threads at the time they receive an I/O request.

Leveraging Node.js’ libuv in Windows Azure
http://msdn.microsoft.com/en-us/library/hh527737(v=VS.103).aspx

Getting the samples to work on the Azure Node.js SDK
http://coderead.wordpress.com/2012/01/03/getting-the-samples-to-work-on-the-azure-node-js-sdk/

Write Logs for Machines, use JSON
http://journal.paul.querna.org/articles/2011/12/26/log-for-machines-in-json/

thejh / node-forum
https://github.com/thejh/node-forum
You know, a forum. In nodejs.

Microsoft Windows Azure PaaS Gets Node.js Update
http://www.talkincloud.com/microsoft-windows-azure-paas-gets-node-js-update/

scriby / asyncblock
https://github.com/scriby/asyncblock
A simple and powerful abstraction of node-fibers

Azure On GitHub
https://github.com/blog/1010-azure-on-github

Building Hypermedia APIs with HTML5 and Node
http://www.amazon.com/Building-Hypermedia-APIs-HTML5-Node/dp/1449306578/ref=ntt_at_ep_dpt_1

Pollenware / comb
https://github.com/Pollenware/comb
Framework for node that provides a one stop shop for frequently needed utilities (OO, collections, logging, string and date formatting, proxy, flow control, date management)

Real Time Editing with Sockets, Node and Redis
http://dailyjs.com/2010/05/26/realie/

28c3: Effective Denial of Service attacks against web application platforms
http://www.youtube.com/watch?v=R2Cq3CLI6H8

Ryan Dahl and software complexity
https://plus.google.com/115094562986465477143/posts/Di6RwCNKCrf

dreamerslab / thunder
https://github.com/dreamerslab/thunder
A lighting fast template parser for node.js

Control Flow in Node
http://howtonode.org/control-flow

Control Flow in Node Part II
http://howtonode.org/control-flow-part-ii

Control Flow in Node Part III
http://howtonode.org/control-flow-part-iii

substack / node-bigint
https://github.com/substack/node-bigint
Arithmetic on big integers using libgmp

caolan / nodeunit
https://github.com/caolan/nodeunit
Easy unit testing in node.js and the browser, based on the assert module.

cloudkick / whiskey
https://github.com/cloudkick/whiskey
A powerful test runner for NodeJS applications.

c9 / kernel
https://github.com/c9/kernel
A simple async template language similair to dustjs and mustache

Dux Released
http://joshuakehn.com/2011/12/19/Dux-Released.html
At it’s core dux is a flexible container that accepts drop in functionality that can be executed from a common command line interface. Adding new commands or extending others is straight forward and simple.

caolan / async
https://github.com/caolan/async
Async utilities for node and the browser

RailwayJS – MVC framework
http://railwayjs.com/
Create NodeJS web apps faster with more energy, using RailwayJS

Ryan Dahl – History of Node.js
http://www.youtube.com/watch?v=SAc0vQCC6UQ
What does he drink ;-)

Testing / Spec Frameworks
https://github.com/joyent/node/wiki/modules#wiki-testing

Node Modules
https://github.com/joyent/node/wiki/modules

Search NPM packages
http://search.npmjs.org/

observing / eventreactor
https://github.com/observing/eventreactor
EventEmitters on a syntax suger rush

Debugging native node modules loading failure on windows
http://botsikas.blogspot.com/2011/12/debugging-native-node-modules-loading.html

The Switch: Python to Node.js
http://journal.paul.querna.org/articles/2011/12/18/the-switch-python-to-node-js/

Welcome Nodesters!
http://nodester.com/help.html
There are many avenues to get help with hosting or deploying your node.js applications to Nodester.

apla / workflow.nodejs
https://github.com/apla/workflow.nodejs
Workflow processing for node.js
Every application is based on series of workflows. if your workflow is written in a program code, you have a problem. people don’t want to screw up, but they do. workflow.nodejs is an abstract async processing framework for describing workflows in simple configuration.

What’s new in Windows Azure
http://www.infoworld.com/d/microsoft-windows/whats-new-in-windows-azure-181578
Seeking greater relevance and functionality, Microsoft adds a free trial and more open source support

What are the disadvantages of using Node.js?
http://www.quora.com/What-are-the-disadvantages-of-using-Node-js
@zef: “I like Javascript and node.js, but there’s one disadvantage: its asynchronous programming model…
…Until I used Python for a server-side project and remembered how much simpler the synchronous programming style is. How cleaner your code looks. I suppose I had the Stockhold syndrom for a while there.”

The Pass Pattern
http://josephmoniz.github.com/blog/2011/12/14/js-pass-pattern/

Node.JS in Windows Azure
http://channel9.msdn.com/Events/windowsazure/learn/Node-JS-in-Windows-Azure
by @ntotten

Transform your IIS into a real-time pub/sub engine with Faye-Node
http://weblogs.asp.net/cibrax/archive/2011/12/12/transform-your-iis-into-a-real-time-pub-sub-engine-with-faye-node.aspx
Faye is a simple Http Pub/Sub server initially implemented by John Coglan in Ruby, and also later ported by himself to Node.js. The version for Node.js implements the Bayeux protocol, which at first glace, many of us known as http long polling.
This project just represents another alternative to Socket.IO, which also works for client applications that are not necessarily implemented within a web browser.  As many http pub/sub engines out there, Faye also uses the idea of channels for routing messages, and it ships with two message repositories out of the box, a repository that runs in memory and a repository that stores the messages in REDIS.

Azure price cuts, bigger databases, now with node.js and MongoDB support, Hadoop on its way
http://arstechnica.com/microsoft/news/2011/12/azure-price-cuts-bigger-databases-now-with-nodejs-and-mongodb-support-hadoop-on-its-way.ars?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+arstechnica/index+(Ars+Technica+-+Featured+Content)

Node js Book Shelf
http://astore.amazon.com/nodejs-20

substack / node-browserify
https://github.com/substack/node-browserify
Make node-style require() work in the browser, as if by magic!

Improved Developer Experience, Interoperability, and Scalability on Windows Azure
http://blogs.msdn.com/b/windowsazure/archive/2011/12/12/improved-developer-experience-interoperability-and-scalability-on-windows-azure.aspx

Node.js Developer Center
https://www.windowsazure.com/en-us/develop/nodejs/

Node.js core contributor explains why it’s ready for the big time (video)
http://venturebeat.com/2011/12/09/node-js-rackspace/

Deploying Node.js Applications to Windows Azure via Blobs or Git Sync
http://blog.smarx.com/posts/deploying-node-js-applications-to-windows-azure-via-blobs-or-git-sync
by @smarx via @asehmi

ajaxorg / node-github
https://github.com/ajaxorg/node-github
node library to access the GitHub API

pksunkara / octonode
https://github.com/pksunkara/octonode
github api v3 in nodejs

My Links
http://delicious.com/ajlopez/nodejs

More links and examples are coming.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

January 9, 2012

Social Games Programming (Part 8) Adding Node.Js

Filed under: Azure, Game Development, JavaScript, NodeJs — ajlopez @ 7:46 pm

Previous post

In the previous post, we explored the game processing in the current Windows Azure Toolkit for Social Gaming. Now, it’s time to add Node.js as game server, in our Tic Tac Toe simple game.

All the Game Service client code is game agnostic. And it can be changed to use another services. In this post, I will change the play move processing to be directed to a Node.js instance.

You need to download the node folder from my GitHub:

https://github.com/ajlopez/SocialGamingExtensions

Then, follow these steps:

1 – Download and setup the Windows Azure Toolkit for Social Gaming version 1.1.1, from:

http://watgames.codeplex.com/releases/view/77091

1 – Install Node.js for Windows, from http://nodejs.org/#download

2 – Change to the server folder, and execute this command line:

npm install socket.io

The socket.io library is downloaded and installed in a node_modules subfolder:

This is the folder tree:

3 – Start the node.js server:

node gameex.js

The server starts to listen:

4 – Copy the client folder to your SocialGaming.Web project folder. Web.config, BaseController.cs, TicTacToeController.cs files will be replaced. New files will be added: Scripts\game\GameServiceNodeJs.js, Areas\Samples\Views\TicTacToe\NodeJs.cshtml.

5 – Open the solution in Visual Studio 2010 (run as administrator) and add these files to SocialGaming.Web project. The new Game Service for Node.js:

The new TicTacToe view that uses Node.js:

The new action in the replaced TicTacToe controller:

There is a new entry in the web.config file:

The replaced BaseController reads that setting:

6 – Start the application (it should run as http://127.0.0.1:81 to be accepted by the Federated Security running in ACS portal). See the invite URL:

7 – Browse to /Samples/TicTacToe/NodeJs:

8 – The client connects with the Node.js game server:

My browser doesn’t understand the WebSocket version implemented in the socket.io server library. Then, Socket.io fallback to use xhr long polling.

9 – Open a new browser, in a private session, with the URL provided by the step 6

10 – These are the two players. The left one played at top left cell. The right player receives the new move and update its view.

11 – See the server console: the move was received and broadcasted to the game participants:

Nice! Homework: add the Node.js to a worker role (see @ntotten post NodeJS on Windows Azure).

Next topics: explain in detail the server code (it supports client that uses plain TCP sockets instead of socket.io, so you can program a client in other platforms, from Silverlight to iPhone to Android).

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

January 7, 2012

Social Games Programming (Part 7) Game Moves Processing

Filed under: .NET, Azure, Game Development, JavaScript — ajlopez @ 5:24 pm

Previous Post
Next Post

In this post, I want to discuss the game play processing in Tic Tac Toe. It involves many pieces, from Razor view using Javascript to Web Role, to Azure Blob Storage.

These are the javascript files referenced in Tic Tac Toe view (at SocialGame.Web/Areas/Samples/Views/TicTacToe/Index.cshtml):

<script src="@Url.AreaContent("Scripts/jQuery.tmpl.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/knockout-1.2.1.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/ServerInterface.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/GameService.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/UserService.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeBoard.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeGame.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeViewModel.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeController.js")" type="text/javascript"></script>

As I wrote in the previous post, ServerInterface, GameService and UserService are game-agnostic components. They could be used in any game. For each new kind of game X, you must implement XBoard, XGame logic, XViewModel and an appropiate XController.

At the end of that view, there is the creation of the game-agnostic services:

var apiURL = "@this.ViewBag.ApiUrl";
var blobURL = "@this.ViewBag.BlobUrl";
var si = new ServerInterface();
var gs = new GameService(apiURL, blobURL, si);
var user = new UserService(apiURL, blobURL, si);

The @this.ViewBag properties are filled in the ASP.NET MVC controller (see BaseController.cs)

The creation of the game controller:

// check for canvas, show an "Upgrade your browser" screen if they don't have it.
var canvas = document.getElementById('board');
if (canvas.getContext == null || canvas.getContext('2d') == null) {
    $("#game").toggle();
    $("#notSupported").toggle();
    return;
}
var board = new TicTacToeBoard(canvas);
var game = new TicTacToeGame();
var controller = new TicTacToeController(viewModel, gs, board, game);
controller.setGameQueueId(gameQueueId);
controller.start();

But the interesting part is in the controller constructor:

function TicTacToeController(viewModel, gameService, board, game) {
    this.viewModel = viewModel;
    this.gameService = gameService;
    this.board = board;
    this.game = game;
    this.started = false;
    var controller = this;
    this.board.onMove = function (x, y) { controller.onMove(x, y); };
};

Notice the this.board.onMove: the controller register itself to process new moves detected by the board component. At its start method, the controller register itself to process game service updates:

controller.gameService.process(
        gameQueueId,
        function (queue) { controller.processGameQueue(queue); },
        function (action) { controller.processAction(action); }
        );

Let's examine the processing of game moves.

1 - The board component detects a click, then it sends a new move to controller (using the onMove callbalk)

2 – The controller sends the new move to game logic, to update state (I omitted the view model in this sequence/graph)

3 – The controller sends the new move to game service.

4 – The game services sends a new command to web role, using the server interface

5 – The Web Role API receives the new command

6 – The command info is appended to the game status blob, at Azure storage

Now, the other client processing:

1 – The game service, using a timer, polls the game status, calling the service interface

2 – The service interface, using JSONP, retrieves the current game status from Azure Blob storage

3 – If a new move is detected, the game service calls a callback function provided by the controller (game service has no reference to controller).

4 – The controller sends the new move to game logic, updating state (I omitted the view state here)

5 – The controller sends the new move to board component, to update the canvas

A key point: the controller knows NOTHING about the service interface, WCF Web API, blob storage. So, you can change the game service to route and detect new moves in other ways. Next post: modify game service to use a Node.js server for game move processing.

Keep tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

January 6, 2012

Content Repository: Links, News and Resources (1)

Filed under: AjCoRe, Content Repository, Java, Links — ajlopez @ 5:35 pm

Recently, I was working on my open source simple content repository, AjCoRe, having nodes and properties, based on the JSR-170 concepts. Now, I’m reading some additional resources: API, concrete implementations, uses cases, etc. This is the list of links I have collected about the topic:

http://en.wikipedia.org/wiki/Content_repository

A content repository is a store of digital content with an associated set of data management, search and access methods allowing application-independent access to the content, rather like a digital library, but with the ability to store and modify content in addition to searching and retrieving. Acontent repository thus typically forms the technical underpinning of a content application, like a Content Management System or a Document Management System. It functions as the logical storage facility for content

A content repository exposes amongst other the following facilities:

  • Read/write of content
  • Hierarchy and sort order management
  • Query / search
  • Versioning
  • Access control
  • Import / export
  • Locking
  • Life-cycle management
  • Retention and hold / records management

What is Java Content Repository
http://onjava.com/pub/a/onjava/2006/10/04/what-is-java-content-repository.html?page=1
The Java Content Repository API (JSR-170) is an attempt to standardize an API that can be used for accessing a content repository. If you’re not familiar with content management systems (CMS) such as Documentum, Vignette, or FileNet, then you must be wondering what a content repository is. Think of a content repository as a generic application "data store" tht can be used for storing both text and binary data (images, word processor documents, PDFs, etc.). One key feature of a content repository is that you don’t have to worry about how the data is actually stored: data could be stored in a RDBMS or a filesystem or as an XML document. In addition to providing services for storing and retrieving your data, most content repositories provide advanced services such as uniform access control, searching, versioning, observation, locking, and more.
Introducing the Java Content Repository API

http://www.ibm.com/developerworks/java/library/j-jcr/

JCR Primer
http://jtoee.com/jsr-170/
The following pages contain a primer on the Java Content Repository specification.
JSR170, the Java Content Repository, constitutes an extremely complex specification. The successor, JCR 2.0 / JSR 283, specification adds even more complexity. However, the JCR REPRESENTS a very generic and object-oriented content repository which touches almost all features known in the space. The content repository is not a full-fledged content management system or a content management API. It is only the small subset of a content repository, a storage engine, which a content management system can be built on top of.

Java Content Repository: The Best Of Both Worlds
http://java.dzone.com/articles/java-content-repository-best

Compact Node Type Notation in a Nutshell
http://jtoee.com/jsr-170/compact-node-type-notation-in-a-nutshell/

Content Management with Apache Jackrabbit
http://www.slideshare.net/jukka/content-management-with-apache-jackrabbit

JCR In Action
http://www.slideshare.net/cziegeler/jcr-in-action-apachecon-us-2009
Content-based Applications with Apache Jackrabbit

Apache Jackrabbit Examples
http://wiki.apache.org/jackrabbit/ExamplesPage

Introducing the Alfresco Java Content Repository API
http://wiki.alfresco.com/wiki/Introducing_the_Alfresco_Java_Content_Repository_API
This article introduces you to the Alfresco implementation of the Java Content Repository API (aka JCR or JSR-170) by designing and developing a simple WIKI like back-end using both Level 1 and Level 2 JCR features.

Oracle Beehive Java Content Repository
http://docs.oracle.com/cd/E13789_01/bh.100/e13801/toc.htm

Catch Jackrabbit and the Java Content Repository API
http://www.artima.com/lejava/articles/contentrepository.html

The SharePoint content repository: It’s just a database
http://searchwinit.techtarget.com/feature/The-SharePoint-content-repository-Its-just-a-database
SharePoint’s repository — where all its content lives, is indexed, and is version-controlled — isn’t some special data construct. It’s just a database — a SQL Server database, to be specific.

Apache Sling – Bringing Back the Fun
http://sling.apache.org/site/index.html
Apache Sling in five bullets points:
- REST based web framework
- Content-driven, using a JCR content repository
- Powered by OSGi
- Scripting inside, multiple languages (JSP, server-side javascript, Scala, etc.)
- Apache Open Source project

Apache Jackrabbit
http://en.wikipedia.org/wiki/Apache_Jackrabbit
Apache Jackrabbit is an open source content repository for the Java platform. The Jackrabbit project was started on August 28, 2004, when Day Software licensed an initial implementation of the Java Content Repository API (JCR). Jackrabbit was also used as the reference implementation of JSR-170, specified within the Java Community Process. The project graduated from the Apache Incubator on March 15, 2006, and is now a Top Level Project of the Apache Software Foundation.

Content Repository API for Java
http://en.wikipedia.org/wiki/Content_repository_API_for_Java

Content repository like JSR-170 in .net?
http://forums.asp.net/t/1201446.aspx/1

Sensenet
http://www.sensenet.com/
Open Source Sharepoint Alternative

Eclipse Enterprise Content Repository
http://www.slideshare.net/efge/eclipse-enterprise-content-repository-ecr
Overview of Nuxeo Core

IIOP enabled jackrabbit-jcr-rmi, .NET 2.0 Remoting Layer Implementation, .NET 2.0 Repository Explorer implementation, .NET 2.0 implementation of JSR-170 API
https://issues.apache.org/jira/browse/JCRRMI-24

JSR 283: Content Repository for JavaTM Technology API Version 2.0
http://jcp.org/en/jsr/detail?id=283

JCR or RDBMS
http://www.scribd.com/doc/11163161/JCR-or-RDBMS-why-when-how
Why, when, how?

My own work, AjCoRe
http://ajlopez.wordpress.com/category/ajcore/

My Links
http://delicious.com/ajlopez/contentrepository

More work on AjCoRe is coming.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

January 3, 2012

What is Windows Azure?

Filed under: Azure, Cloud Computing, Video — ajlopez @ 11:06 am

Past year, I wrote many blog post about Azure programming. Maybe, you know about cloud computing in general, but not about Azure in particular. Today, thanks to Windows Azure + a pinch of UK published by Eric Nelson (@ericnel), I found this video, that explain in simple terms the key technical pieces of Azure:

http://www.youtube.com/watch?v=poDRw_Xi3Aw

For more information about the video, see Steve Marx (@smarx) post:

What is Windows Azure? (a Hand-Drawn Video)

It has an interesting section title: “How I Made It”.

Notice the difference of compute nodes and storage nodes. Both service can be emulated in your local machine, thanks to Azure tools for Visual Studio.

My links about azure:

http://delicious.com/ajlopez/azure

A post about Azure, games and Node.js is comming.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

January 1, 2012

New Month’s Resolutions

In my opinion, using a year for resolutions is too much time. I prefer to have smaller periods for life iteration. One year gives a lot of time for procrastination and lost of focus. My proposal: to have monthly resolution. Yesterday, I wrote about my public not technical resolutions, in Spanish. Now, it’s time to write down a short list of technical resolutions, with public outcomes:

- Implements Id in Nodes in AjCoRe (simple Content Repository)
- Implements Server/Client in AjKeyvs (Key Value Store)
- Start a new version of my PHP simple framework, revamping old one, to publish in my GitHub account
- Publish a simple web server example at my Node.js samples
- Publish a simple HTML5/Canvas game using Node.js as game server (at Node.js samples)
- Continue working on AjLang interpreter, Ruby-like syntax over .NET types and objects
- Continue working on AjLisp in Java
- Play with Clojure REPL
- Start writing AjRools.Expert, rule engine in C#, a la JBoss Drools Expert (it will be published in GitHub account)

I could add some posts about these items, but all them have public repository, so the commits will serve as a proof of advance of this list.

After this first month (January 2012), I will write down a new list, maybe with improvements (better definitions, improved defined outcomes, etc.). Most of these resolutions are centered on studying new things, and practice, practice, practice, practice.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

The Shocking Blue Green Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 65 other followers