Shaun Xu

The Sheep-Pen of the Shaun


News

logo

Shaun, the author of this blog is a semi-geek, clumsy developer, passionate speaker and incapable architect with about 10 years’ experience in .NET and JavaScript. He hopes to prove that software development is art rather than manufacturing. He's into cloud computing platform and technologies (Windows Azure, Amazon and Aliyun) and right now, Shaun is being attracted by JavaScript (Angular.js and Node.js) and he likes it.

Shaun is working at Worktile Inc. as the chief architect for overall design and develop worktile, a web-based collaboration and task management tool, and lesschat, a real-time communication aggregation tool.

MVP

My Stats

  • Posts - 122
  • Comments - 549
  • Trackbacks - 0

Tag Cloud


Recent Comments


Recent Posts


Article Categories


Archives


Post Categories


Image Galleries


.NET


 

Reactive Extension (Rx), which is introduced by Microsoft, is a library for composing asynchronous and event-based programs, by using observable, observer with LINQ-style query operators. If LINQ is the first generation on how people deal with data, Rx should be next generation. [Read More] ......

 

We should NOT write a lot of code inside one file, or in one class, not only in JavaScript in theory. But in practice we might need to write a huge class. I know in C# we can split one class in multiple files, which they called partial class. How...[Read More] ......

 

Recently I was working on a project to make our production, Worktile Pro, to be able to on-premise deploy. Besides some code changes one of the problem we were facing is how to protect our source code. This can be resolved by compiling to binary. There are some tools can... [Read More]

 

Our production Worktile Pro was built based on Node.js 0.12 when we firstly developed and at that moment we tried our best to prevent our code from the callback hell.

With Node.js v6 we can use iterator and tj’s co to flatten our code. While with Babel.js we can use Async/Await introduced in ES7.


 

When I’m developing Worktile Pro with ES6 and ES7, arrow function is one of features I like most. This makes me to use arrow function as anywhere as I could. But I also encountered some problem by using it. For example, in one my previous post, I found arguments are not defined in arrow function. Several days ago I found another problem about this in arrow function.


 

ES6 introduced a new way to organize modules. It’s different from CommonJS and AMD we are currently using, which through the new keywords import and export. It still NOT being supported by the latest version of Node.js. But fortunately we can leverage Babel.js to play it right now.When we are rewriting the next version of Instant Message module of our production - Worktile Pro, we used this feature under Node.js v6 and Babel.js. So in this post I would like to introduce what it is and how I was using.Read ......

 

DocumentDB, provided by Microsoft Azure, is a low latency, NoSQL document database service for web high-scale gaming, social, and Internet of Things (IoT) app scenarios. Similar as Microsoft Azure Table Storage Service, when using DocumentDB developers don’t have to worry about managing schemas anymore. But additionally, DocumentDB automatically indexes all JSON documents added to the database, letting you use familiar SQL syntax to query them without having to specify the schema or secondary indices ......

 

Worktile Pro contains three main modules: task, calendar and drive. In calendar module user can create events such as meeting, appointment with participants, location, resources and recurrence. It also supports multiple types of reminders such as Worktile build-in message, email, SMS and phone-call. But some of our customers would like to us it in some third calendar application, such as Mac OS Calendar, Google Calendar, etc.. In this post I will describe how to build a calendar subscription service ......

 

There is an enhancement in ECMAScript 6 named "Arrow Functions", which likes lambda expression in C#, allow us to define a function within less lines of code. I like this new feature and began to use it in my Node.js application as many as I could. But today when II was using JavaScript build-in "arguments" variant I found something wrong. Assuming we have a module to add parameters, which is very simple. I'm using Arrow Functions to implement as below. // calc.js (() => { 'use strict'; exports.add ......

 

Features always grows much faster than we expect. When I am build Worktile Pro I created a JavaScript file contains all business logic in class for the task module. But after several months development it became over 7000 lines of code, which is horrible. Last week I decided to split it into multiple files. It may not be a big problem to split one JavaScript file into multiple, especially in Node.js environment. We can put functions and variables into many files as we wanted and "require" them in ......

 

When I was developing Worktile Enterprise we are using MongoDB with an ODM framework called Mongoose. It provides sachems-based validation in top of native MongoDB driver, and for each collection we also need to define schema. When the business became more complex we found it needs to share part of schema between collections. For example, in calendar module there are two collection one for event series the other for each individual event instance. Both of them contains properties such as event name, ......

 

In the TechED North America Microsoft announced another cache service in Azure which is the Redis Cache Service. This is the 4th cache service Microsoft introduced in Azure. The first one is Shared Cache which is going to be retired in Sep as it has very critical performance issue. The second one is In-Role Cache, which is built on top of AppFabric engine, is high performance and dedicates to the role instances in the same cloud service. The third one is Managed Cache, which is based on AppFabric ......

 

There are three functions under JavaScript Function object which are bind, call and apply. They are very useful when we need to pass the function as a variant but very confused. I'd like to try to explain them here with a sample code in Node.js environment. Pass Function as a Variant Assume we have a class named "Person" as below. The constructor accepts two parameters for the person's first name and last name. We also added a method named "say", which accepts one parameter then return a string with ......

 

May I firstly ask a question for developers writing Node.js application on Windows platform, which editor are you using currently. Being a geeks working with Node.js on Windows for about 1.5 year, I used to use NotePad ++ for the first half a year. Then I switched to use Sublime Text till now on Windows and Mac. I also tried to use WebStorm but give up as I really don’t like its UI, although I knew it’s a powerful tool for web and Node.js development. Today I was informed that Microsoft publish a ......

 

Working behind a proxy server is a very common scenario in a cooperation environment. If we are using Windows and using some windows based application, such as Office, Visual Studio, etc. we almost no need to care about the proxy setting since they will use the Internet Connection setting to communicate with the services out of our company. But if we are using some cross platform or *-nix application, such as Node.js and some of tis 3rd party modules, they might not able to load the proxy setting ......

 

It has been long time didn’t blog anything since last November. There are many exciting things happened during this period. I attend Microsoft TechED 2012 China and provided a session about Node.js and Windows Azure. I also provided a small but funny session at the Microsoft China Community New Year Party on this January. Then I enjoyed Chinese New Year at Lvshun, a quiet and beautiful city aside Bohai Bay with my wife, where her hometown is. But I decided to write something when I read this. On ......

 

In one of my previous post I described and demonstrated how to use NPM packages in Node.js and Windows Azure Web Site (WAWS). In that post I used NPM command to install packages, and then use Git for Windows to commit my changes and sync them to WAWS git repository. Then WAWS will trigger a new deployment to host my Node.js application. Someone may notice that, a NPM package may contains many files and could be a little bit huge. For example, the “azure” package, which is the Windows Azure SDK for ......

 

In the first post of this series I mentioned some popular modules in the community, such as underscore, async, etc.. I also listed a module named “Wind (zh-CN)”, which is created by one of my friend, Jeff Zhao (zh-CN). Now I would like to use a separated post to introduce this module since I feel it brings a new async programming style in not only Node.js but JavaScript world. If you know or heard about the new feature in C# 5.0 called “async and await”, or you learnt F#, you will find the “Wind” ......

 

When I described on how to host a Node.js application on Windows Azure, one of questions might be raised about how to consume the vary Windows Azure services, such as the storage, service bus, access control, etc.. Interact with windows azure services is available in Node.js through the Windows Azure Node.js SDK, which is a module available in NPM. In this post I would like to describe on how to use Windows Azure Storage (a.k.a. WAS) as well as the service runtime. Consume Windows Azure Storage Let’s ......

 

In my previous post I demonstrated about how to develop and deploy a Node.js application on Windows Azure Web Site (a.k.a. WAWS). WAWS is a new feature in Windows Azure platform. Since it’s low-cost, and it provides IIS and IISNode components so that we can host our Node.js application though Git, FTP and WebMatrix without any configuration and component installation. But sometimes we need to use the Windows Azure Cloud Service (a.k.a. WACS) and host our Node.js on worker role. Below are some benefits ......

 

In the first post of this series I introduced on how to run Node.js application on Windows. In the second one I demonstrated about how to use SQL Server in Node.js. That was the steps when I was learning Node.js, firstly made it work on Windows, then try to use SQL Server. But returned back to my original goal, I need to implement a synchronization service for Wang Tao’s worktile, and planed to have a prototype hosted on Windows Azure. So the previous two posts are preparation. In this post I am ......

 

In my previous post I demonstrated how to install, configure and run Node.js application on Windows. In this post I will cover a specific and short topic, which is how to use SQL Server in Node.js. Install SQL Service Module In NPM there are many SQL Server modules. From the command windows we can use “npm find” to find the modules for specified terms. For example, below is the result when I found “sqlserver”. In this post I will describe one of them, the “node-sqlserver” module. This module was ......

 

Two weeks ago I had had a talk with Wang Tao, a C# MVP in China who is currently running his startup company and product named worktile. He asked me to figure out a synchronization solution which helps his product in the future. And he preferred me implementing the service in Node.js, since his worktile is written in Node.js. Even though I have some experience in ASP.NET MVC, HTML, CSS and JavaScript, I don’t think I’m an expert of JavaScript. In fact I’m very new to it. So it scared me a bit when ......