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
| /** | |
| * Created by yuansc on 14/11/26. | |
| */ | |
| //'use strict'; | |
| //var Server = require('mongodb').Server; | |
| //var Db = require('mongodb').Db; | |
| //var replsetServer = require('mongodb').ReplSetServers; | |
| //var server1 = new Server('172.16.137.135', '27017', {}); | |
| //var server2 = new Server('172.16.137.136', '27017', {}); | |
| //var server3 = new Server('172.16.137.137', '27017', {}); |
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
| /** | |
| * Created by yuansc on 14/11/19. | |
| */ | |
| 'use strict'; | |
| var fs = require('fs'); | |
| function fib() { | |
| var cache = ['1', '1']; | |
| return function (n) { | |
| if (n >= cache.length) { | |
| for (var i = cache.length; i < n ; i++ ) { |
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
| /** | |
| * Created by yuansc on 14/10/28. | |
| */ | |
| 'use strict'; | |
| function merge(a, low, mid, high, b) { | |
| var i = low; | |
| var j = mid + 1; | |
| var p = 0; | |
| // 合并两个有序数组 子序列1 a[low..mid] 子序列2 a[mid+1..high] |
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
| /** | |
| * Created by yuansc on 14/10/27. | |
| */ | |
| 'use strict'; | |
| function insertsort(array) { | |
| for (var j = 1; j < array.length; j = j + 1) { | |
| var i = j - 1; | |
| var key = array[j]; | |
| while (j > 0 && array[i] > key) { |
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
| /** | |
| * Created by yuansc on 14/9/18. | |
| */ | |
| "use strict"; | |
| var Promise = require('bluebird'); | |
| var fs = require('fs'); | |
| function callbackTest(callback) { | |
| return new Promise(function (fuifilled, rejected) { | |
| fs.readFile('./file1', function(err, result) { |
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
| /** | |
| * Created by yuansc on 14/9/9. | |
| */ | |
| 'use strict'; | |
| var obj = { | |
| name:'yuansc' | |
| }; | |
| function test(callback) { | |
| try { |
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
| /** | |
| * Created by yuansc on 14-8-15. | |
| */ | |
| /** | |
| * Created by witmob on 14-8-13. | |
| */ | |
| var mqtt = require('mqtt'); | |
| var redis = require('redis'); | |
| var allMqttClients = {} | |
| var Timer = {}; |
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 host = 'bj.58.com'; | |
| var http = require('http'); | |
| var cheerio = require('cheerio'); | |
| var async = require('async'); | |
| var path='/chuzu/'; | |
| var title=[]; | |
| function getPageNum(callback){ | |
| var options = { | |
| host: host, | |
| port: 80, |
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 cluster = require('cluster'); | |
| var http = require('http'); | |
| if (cluster.isMaster) { | |
| var numCPUs = require('os').cpus().length; | |
| var numReqs = 0; | |
| console.log(numCPUs) | |
| // 启动多个进程. | |
| for (var i = 0; i < numCPUs; i++) { | |
| //增加一个进程 |