Skip to content

Commit

Permalink
chaos2node joyent done...
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoom.Quiet committed May 19, 2012
1 parent 9d7a328 commit 1414805
Show file tree
Hide file tree
Showing 15 changed files with 444 additions and 84 deletions.
1 change: 1 addition & 0 deletions source/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
修订记要
===============

- 120519 `Zoom.Quiet`_ 发布只有 `Joyent`_ 的初版乱入...
- 120322 `Zoom.Quiet`_ 启动乱入 node 的收集
- 120308 `Zoom.Quiet`_ 启动乱入系列手册,分享乱来的学习体验;-)
- 120216 `Zoom.Quiet`_ 基本完成 `node.js`_ 的实战并分享 `{2月16日语音讲座vol.42}ZQ: 网址云安node.js结合 <http://bbs.code.ijinshan.com/thread-1578-1-1.html>`_
Expand Down
15 changes: 12 additions & 3 deletions source/LINKS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,27 @@
.. 外部链接收集~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. _tmux: http://www.linuxtoy.org/archives/from-screen-to-tmux.html
.. _node.js: http://nodejs.org/
.. _V8: http://code.google.com/p/v8/

.. .. _V8: http://code.google.com/p/v8/
.. _V8: http://zh.wikipedia.org/wiki/V8_(JavaScript%E5%BC%95%E6%93%8E)

.. _JavaScript: https://developer.mozilla.org/en/JavaScript
.. _AJAX: https://developer.mozilla.org/en/AJAX
.. _SSH: http://zh.wikipedia.org/zh/SSH
.. _CoffeeScript: http://jashkenas.github.com/coffee-script/
.. _Express: http://expressjs.com/

.. _Joyent: http://wiki.joyent.com/display/www/Documentation+Home
.. _no.de: http://wiki.joyent.com/display/node/Node.js+Home
.. _npm: http://npmjs.org/
.. _git: http://progit.org/book/zh/
.. _Solaris: http://zh.wikipedia.org/zh/Solaris_(%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F)

.. _AJAX: https://developer.mozilla.org/en/AJAX
.. _SSH: http://zh.wikipedia.org/zh/SSH

.. _GFW: http://zh.wikipedia.org/wiki/Great_Firewall

.. _cnodejs: http://cnodejs.org/

.. _NAE: http://cnodejs.net/
.. _GAE: http://zh.wikipedia.org/wiki/GAE
.. _PaaS: http://zh.wikipedia.org/wiki/PaaS
Expand Down
Binary file added source/_static/figs/coffee-hollo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/_static/figs/joyent-no.de.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/_static/figs/joyent-order-host.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 20 additions & 11 deletions source/ch00/try.rst
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
.. include:: ../LINKS.rst


+10分钟:初尝
+7分钟:初尝
==============

整起来先!
- 嗯嗯嗯,现在可以计时了: `00:00`
- 嗯嗯嗯,现在可以计时了:

安装
--------
00:00~安装
------------------------

`参考:` `官方安装说明 <https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager>`_


.. sidebar:: 提示

- 不专门说明的话,指的都是笔者的个人环境:
不专门说明的话,指的都是笔者的个人环境:

- MAC OS X 10.7.3
- MAC OS X 10.7
- brew 0.8.1
- node 0.6.12
- coffeescript 1.2.0
Expand Down Expand Up @@ -85,6 +85,15 @@
└── which@1.0.3


.. seealso:: (^.^)

- 好吧,俺是使用舒服无比的 "`家酿 <http://mxcl.github.com/homebrew/>`_" 软件包管理系统
- 事实上在各种 Linux/UNIX 发行版中都有对应的软件包管理系统,耳目能详的 apt/ports/rpm/yum ...
- 只有 M$ 中真心没有,不过, `node.js`_ 的安裝是提供有专门的 `.msi安装包的! <http://nodejs.org/#download>`_
- `npm`_ 当然也有方法,不过是需要使用安装好的 `node.js`_ 进行编译, 参考: `InfoQ: 深入浅出Node.js(二):Node.js&NPM的安装与配置 <http://www.infoq.com/cn/articles/nodejs-npm-install-config>`_




.. note:: (~_~)

Expand Down Expand Up @@ -159,15 +168,15 @@
那么接下来怎么整?


小结
------
07:01 小结
------------------------------

不出意外的话, `10:00` 用在这个阶段,太足够了!
不出意外的话, 7分钟 用在这个阶段,太足够了!

应该已经体验到 `node.js`_ 的核心爽直了?!

- 只要具备 JavaScipty 的编程经验,就可以进行服务端的开发了!
- 而且, 性能在 **`V8`_** 引擎的强力支持下一点也不差!
- 只要具备 `JavaScript`_ 的编程经验,就可以进行服务端的开发了!
- 而且, 性能在 `V8`_ 引擎的强力支持下一点也不差!



62 changes: 62 additions & 0 deletions source/ch01/app.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#120215 appended sync http get support
fetch = require('fetch').fetchUrl
#120211 appended base web dev support
crypto = require('crypto')

http = require('http')
#io = require('socket.io')

express = require("express")
app = module.exports = express.createServer()
app.configure ->
app.use express.bodyParser()
app.use express.methodOverride()
#app.use express.logger()
app.use app.router
app.configure "production", ->
app.use express.errorHandler()

app.get "/", (req, res) ->
res.send '''Hollo there!
this is URIsaOK v12.02.16, usage as:
$ curl --data "uri=http://douban.com" http://urisaok.no.de/chk
doc: https://github.com/ZoomQuiet/urisaok
'''
PHISHTYPE = (code) ->
switch code.toString()
when "-1" then 'UNKNOW'
when "0" then 'GOOD'
when "1" then 'PHISH'
when "2" then 'MAYBE PHISH'

APPKEY = "k-60666"
SECRET = "99fc9fdbc6761f7d898ad25762407373"
ASKHOST = "http://open.pc120.com"
ASKTYPE = "/phish/?"

checkForValidUrl = (uri) ->
crtURI = Buffer(uri).toString('base64')
timestamp = Date.parse(new Date())/1000+".512"
signbase = ASKTYPE+"appkey="+APPKEY+"&q="+crtURI+"&timestamp="+ timestamp
#console.log signbase
#console.log signbase+SECRET
sign = crypto.createHash('md5').update(signbase+SECRET).digest("hex")
#ASKHOST+signbase+"&sign="+sign
signbase+"&sign="+sign

app.post '/chk', (req, res) ->
askurl = checkForValidUrl(req.body.uri)
answer = ''
fetch ASKHOST+askurl , (error, meta, body) ->
if error
console.log "ERROR", error.message || error
else
console.log meta
console.log body.toString()
answer = JSON.parse(body) #body.toString()
console.log PHISHTYPE(answer.phish)
res.send "/cnk KSC::\t"+PHISHTYPE(answer.phish)
#res.send "/cnk KSC::\t"+answer.phish
#res.send "\n\t..."+answer

app.listen 8001
15 changes: 15 additions & 0 deletions source/ch01/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,23 @@

- 其实,真心简单,毕竟, `node.js`_ 实在是非常简单的 `脚本语言`
- 其实,任何开发语言的乱入,完全可以不管什么设计思想,开发模式之类的高级东西
- 不过,真心对于手工写 JS 有心理抵触吼,,,特别是:


.. code-block:: js
var server = http.createServer(function (req, res) {
res.writeHead(200, { "Content-Type": "text/plain" })
res.end("Hello world\n");
});
这种 `()` 中包含多行 `function(){...}` 结构的

- `node.js`_ 更加经常见到多层这种嵌套的情景
- 非常难以说服自个儿不会套错了,,,

所以,好在,万幸,我们有 `CoffeeScript`_

.. warning::

Expand Down
5 changes: 3 additions & 2 deletions source/ch01/preknow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ Coffee整备


中文的推荐:

- `为什么CoffeeScript这么美? - CNode <http://club.cnodejs.org/topic/4f16442ccae1f4aa270010cb>`_
- `10个让朋友对你刮目相看的CoffeeScript单行代码绝技 <http://heikezhi.com/2011/06/08/10-coffeescript-one-liners-to-impress-your-friends/>`_
-



基本语法
---------------


.. code-block:: js
::

# 单行注释
###
Expand Down
4 changes: 2 additions & 2 deletions source/ch01/so.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
- 输出友好化?
- 发布问题:

- 上哪儿发布 `node.js`_ 应用?
- 如何安装管理 node 模块?
- 如何在大量模块中进行挑选可用模块?
- 上哪儿发布 `node.js`_ 应用?
- 怎么对运行中的 `node.js`_ 进行版本控制


...
Expand Down
Loading

0 comments on commit 1414805

Please sign in to comment.