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 libuv filesystem operations are different from socket operations. Socket | |
| operations use the non-blocking operations provided by the operating system. | |
| Filesystem operations use blocking functions internally, but invoke these | |
| functions in a thread pool and notify watchers registered with the event loop | |
| when application interaction is required. |
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
| So now the real architecture of libuv is: | |
| IOCP(Windows) + epoll<with Edge triggered interface>(*nix) ===> libuv |
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
| /** | |
| * A typical connect middleware | |
| */ | |
| module.exports = function dist (/* options */) { | |
| // stuff | |
| return function (req, res, next) { | |
| // stuff | |
| next(); | |
| } | |
| } |
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'), | |
| connect = require('connect'), | |
| fs = require('fs'), | |
| util = require('util'), | |
| port = process.env.PORT || 8000, | |
| form = fs.readFileSync('./form.html'); | |
| var app = connect(); | |
| app.use(function (req, res, next) { |
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
| (function() | |
| { | |
| var | |
| defaultCompare, | |
| defaultSwap, | |
| partition, | |
| quickSort; | |
| Array.prototype.quickSort = function(compare, swap) | |
| { |
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 express = require('express'), | |
| url = require('url'), | |
| port = process.env.PORT | 8000, | |
| events = {}, | |
| pending = {}, | |
| maxAge = 60, | |
| lastRequestId = 0, | |
| connectionTimeout = 60; | |
| var app = express(); |
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; | |
| /** | |
| * Not Thread Safe | |
| */ | |
| public class MutableInteger { | |
| private int value; | |
| public int getValue() { |
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; | |
| class Event { | |
| public Event() { | |
| } | |
| } | |
| abstract class EventListener { | |
| public abstract void onEvent(Event event); | |
| } |
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 LeetCodeSix { | |
| private static boolean isMatch(String s, String p) { | |
| if (p.length() == 0) { | |
| return s.length() == 0; | |
| } |
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'), | |
| iconv = require('iconv-lite'); | |
| var server = http.createServer(function (req, res) { | |
| var chunks = [], | |
| size = 0, | |
| finish = function (res) { | |
| res.end('beepboop\n'); | |
| }; | |