This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.westudio.java; | |
| public class LeetCodeTwo { | |
| public static void main(String[] argv) { | |
| } | |
| /** | |
| * Naive programing | |
| * @param s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This script will boot app.js with the number of workers | |
| // specified in WORKER_COUNT. | |
| // | |
| // The master will respond to SIGHUP, which will trigger | |
| // restarting all the workers and reloading the app. | |
| var cluster = require('cluster'); | |
| var workerCount = process.env.WORKER_COUNT || 2; | |
| // Defines what each worker needs to run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.westudio.java; | |
| import java.util.*; | |
| /** | |
| * Created with IntelliJ IDEA. | |
| * User: tonyhe | |
| * Date: 14-5-28 | |
| * Time: 上午10:56 | |
| * To change this template use File | Settings | File Templates. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Event_pub_sub with many to one | |
| * | |
| */ | |
| var after = function (times, callback) { | |
| var count = 0, | |
| results = {}; | |
| return function (key, value) { | |
| results[key] = value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.ado.java.odata.util; | |
| import java.util.concurrent.atomic.AtomicInteger; | |
| import static java.lang.Float.*; | |
| /** | |
| * Created with IntelliJ IDEA. | |
| * User: nankonami | |
| * Date: 14-5-12 | |
| * Time: 下午11:39 | |
| * To change this template use File | Settings | File Templates. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Web.xml常用元素 | |
| <web-app> | |
| <display-name></display-name>定义了WEB应用的名字 | |
| <description></description> 声明WEB应用的描述信息 | |
| <context-param></context-param> context-param元素声明应用范围内的初始化参数。 | |
| <filter></filter> 过滤器元素将一个名字与一个实现javax.servlet.Filter接口的类相关联。 | |
| <filter-mapping></filter-mapping> 一旦命名了一个过滤器,就要利用filter-mapping元素把它与一个或多个servlet或JSP页面相关联。 | |
| <listener></listener>servlet API的版本2.3增加了对事件监听程序的支持,事件监听程序在建立、修改和删除会话或servlet环境时得到通知。 | |
| Listener元素指出事件监听程序类。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class Lazy<T> implements AutoCloseable { | |
| private volatile T instance = null; | |
| protected abstract T makeObject(); | |
| protected abstract void destroyObject(T obj); | |
| public T get() { | |
| if (instance == null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This should works in ES3, ES5 and ES5-strict | |
| var global = (function () { | |
| return this || (1, eval)('this'); | |
| }()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http'); | |
| http.createServer(function(req, res) { | |
| var options = { | |
| hostname: req.headers.host, | |
| port: 80 | |
| }; | |
| var request = http.request(options, function(response) { | |
| res.writeHead(response.statusCode, response.headers); | |
| response.pipe(res); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| The truth of cluster&child_process module | |
| 周五的tech_talk中关于cluster和child_process这块的知识讲的不是很好,同时多少也有些 | |
| 问题,所以利用周天的时间再写点关于这方面的杂文,加深下自己的了解(PS:这么好的天气实在 | |
| 是应该出去赏樱花而不是在这里写东西啊,好像出去找个草坪躺在上面写也不错嗒!) | |
| 感叹到此为止,言归正传,Node在v0.8版本时新增了cluster模块,用于解决多核CPU的利用率 | |
| 问题,同时也提供了完善的API,用于处理进程的健壮性问题。在v0.8版本之前,要实现多进程架 | |
| 构只能通过child_process模块,考虑到有很多细节问题需要处理,可想而知这不是一件简单的事 | |
| 情。好在我们有cluster,事实上cluster模块就是child_process模块和net模块的结合。cluster | |
| 启动时,它会在内部启动TCP服务器,在cluster.fork()子进程时,将这个TCP服务端socket的文件 | |
| 描述符发送给工作进程,如果工作进程中存在listen()侦听网络端口的调用,它将拿到该文件描述 |