This file contains 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'), spawn = require('child_process').spawn; | |
var util = require('util'); | |
var app = express.createServer(); | |
app.use(app.router); | |
var svn; | |
app.get('/svn', function(req, res) { | |
res.writeHead(200, { | |
'Content-Type': 'text/html;charset=utf-8' |
This file contains 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 library was developed by Will Honey. | |
It is licensed under the GPLv3 Open Source License | |
This library requires the underscore library found at http://documentcloud.github.com/underscore/ | |
This library requires the underscore string library found at http://edtsech.github.com/underscore.string/ | |
This library requires the support of localStorage. Updates could be easily made to change that. | |
*/ |
This file contains 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
/** | |
* filter css rule(去掉前面相同的规则,保留最后那条规则) | |
* */ | |
module.exports = function(css, filePath) { | |
var list = [], index; | |
css.split(/\}/g).forEach(function(rule) { | |
rule = rule.trim(); | |
if(rule !== '') { | |
rule = rule + '}'; | |
index = list.indexOf(rule); |
This file contains 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 childProcess = require('child_process'); | |
var path = require('path'); | |
if(cluster.isMaster) { | |
childProcess.fork(path.join(__dirname,'worker.js')); | |
} else { | |
//do nothing | |
} |
This file contains 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 spdy = require('spdy'), fs = require('fs'); | |
var options = { | |
key : fs.readFileSync(__dirname + '/keys/spdy-key.pem'), | |
cert : fs.readFileSync(__dirname + '/keys/spdy-cert.pem'), | |
ca : fs.readFileSync(__dirname + '/keys/spdy-csr.pem') | |
}; | |
var server = spdy.createServer(options, function(req, res) { | |
res.writeHead(200, { |
This file contains 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 fs = require('fs'), path = require('path'); | |
path.existsSync = fs.existsSync ? function(uri){return fs.existsSync.call(fs,uri)} : path.existsSync; |
This file contains 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 fs = require('fs'), path = require('path'); | |
var pDir = ''; | |
function mkdriP(uri,mode) { | |
if(uri === '') {//递归结束 | |
pDir = null; | |
return ; | |
} | |
var list = uri.split(path.sep); | |
pDir = path.join(path.sep, pDir, list.shift()); |
This file contains 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 https = require('https'); | |
var path = require('path'); | |
var fs = require('fs'); | |
var qs = require('querystring'); | |
var express = require('express'); | |
var multiparter = require("multiparter"); | |
process.on('uncaughtException', function(err) { | |
console.error('Caught exception: ', err); | |
}); |
This file contains 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'); | |
var qs = require('querystring'); | |
function parse_response(res, callback) { | |
var list = []; | |
res.on('data', function(chunk) { | |
list.push(chunk); | |
}); | |
res.on('end', function() { | |
callback(Buffer.concat(list).toString()); |
This file contains 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 fs = require('fs'); | |
var path = require('path'); | |
var html = fs.readFileSync(path.join(__dirname,'./img-original.html'),'utf-8'); | |
var htmlLazy = html.replace(/\s+src="(.+?)"/ig,function(){ | |
var m = RegExp.$1; | |
if(m.match(/[\.png|\.jpg|\.jpeg|\.gif]$/)){ | |
return ' data-src="' + m +'" ' ; | |
}else{ |