All posts tagged Express

喝coffee写coffeescript

好吧,这回中文,亚历山大……

其实英文有英文的好处,比如英文会使本人比较focus,因为没兴趣也没能力瞎扯,于是主题明确而不拖泥带水;中文的坏处便是我会常常迷失主题,跑题千里后蓦然回首,那人竟然还在灯火阑珊处……

anyway……

前几天看到sunng的take my coffee,一看title以为必是coffeescript,结果竟偏是如此纯结(纯是纯净水的纯),看来还是哥多虑了…… 想来最近的blog title里面随便带个coffee都会让人浮想联翩,coffee script的“火”冒三丈也就可见一斑。

标题起源于上周想到一个idea,便是让live fortune定时publish到新浪微博或是twitter,目前新浪的publisher已经实现,并顺便refactor了一下code,让之后twitter publisher的加入变的十分简单(在plan中);实现的过程中再次发现了sina clone的迹象,因为其oauth实现竟然连url抄的都一模一样,倒是方便了实现,因为twitter oauth的sample code基本上改个site base url后就能完全照搬,暂且认为这是新浪有意而为之的吧,目的便是方便第三方开发人员……

本来这篇文章一直draft着,再加上周末一直不available,所以拖到现在,为了应景,还特地决定一大早先跑去喝杯咖啡后再来奋笔疾书,无奈公司咖啡机几近坏掉,我修了半天搞的满身都是最后还是勉强喝到了一点味道有稍许异样的不知道还能不能叫做coffee的”coffee”,看来杯具如我辈是永远达不到sunng那种小资情调的呵呵;

吃葡萄不吐葡萄皮,不吃葡萄倒吐葡萄皮. i

[Footnotes]
  1. 喝coffee不写coffeescript,不喝coffee倒写coffeescript []

Deploying Live Fortune (Node.js) with Nginx and Monit

Here we will use Nginx to serve static resources and reverse proxy dynamic requests to the Node server. We will also use Monit to monitor the Node server and restart it automatically in case it crash. This is also the deployment I did at fortune.crash4.us.

[Nginx: Static Resources]
livefortunes use express.static to server static resources, but for better performance we will use nginx to do the job that it’s designed and built to do.

Config nginx to server all the static resources which located under /public :

server {
    listen       80;
    server_name  fortune.crash4.us;
    root         /path/to/livefortunes/public;
    index        index.html;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
         root   html;
    }
}

Continue reading →

Live Fortune (Node.js) that do not crash

Do you enjoy reading interesting or funny sentences like below?

A nuclear war can ruin your whole day.

He who knows, does not speak. He who speaks, does not know.
— Lao Tsu

If you do, check out:
http://fortune.crash4.us/ i

For the record, this is a project built with Node.js, Express and Faye. One fortune will be pushed from server to each client every 2 mins thanks to the html5 WebSocket. Client can trigger a server push/broadcast as well ii. All the source code is available at github.

Next step is to convert this project to CoffeeScript.

[Footnotes]
  1. Trust me, it won’t crash… []
  2. open multiple browser windows or tabs to test []