Skip to content

Instantly share code, notes, and snippets.

@brothertao
brothertao / loadscript.js
Created May 21, 2013 08:58
load script to chrome page
(function(window) {
var document = window.document;
var loadScript = function(uri) {
var script = document.createElement('script');
script.src = uri;
document.querySelector('head').appendChild(script);
};
window.loadScript = loadScript;
})(window)
@brothertao
brothertao / sss.js
Last active December 17, 2015 11:39
simple static server use nodejs usage: cp this file to you want serve directory and run node sss.js [port] eg: cp sss.js /opt/www node sss.js 8888
var connect = require('connect');
var port = parseInt(process.argv[2]) || 3000;
var app = connect()
.use(connect.logger('dev'))
.use(connect.static(__dirname))
.use(connect.directory(__dirname))
.use(function(req, res){
res.end('wrong url\n');
})
.listen(port);
@brothertao
brothertao / this.js
Created January 29, 2013 09:23
有关javascript的this
var a = {
b:function() { console.log(this); }
}
//求下面的输出
a.b();
c = a.b();
(1, a.b)();
(a.b)()