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'); | |
var app = express(); | |
app.get('/hello.txt', function (req, res) { | |
res.send('Hello World'); | |
}); | |
var server = app.listen(3000); | |
// 浏览器访问 http://127.0.0.1:3000/hello.txt |
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
// 1 CommonJS 规范 | |
// 定义 | |
// math.js | |
exports.add = function () { | |
var sum = 0; | |
for (var i = 0, l = arguments.length; i < l; i++) { | |
sum += arguments[i]; | |
} | |
return sum; |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Twister</title> | |
<style> | |
body { background: black } | |
canvas { margin: 0 auto; display: block; padding: 1px; } | |
</style> | |
</head> |
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
<!-- | |
!>#wrapper>(header>(#logo>img)+h1+nav>ul>li*3)+(#body>header>h2+p)+(footer>p) | |
--> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> |
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
/* | |
* 生成随机整数 | |
* 范围为[0, 100) | |
*/ | |
var generateNumber = function() { | |
return parseInt(Math.random() * 100, 10); | |
} | |
/* |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>RegExp Validate Demo</title> | |
</head> | |
<body> | |
<input type="text" id="txt" name="txt" /> | |
<input type="button" id="btn" value="Validate Email" /> | |
<div id="print"></div> |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>userAgent</title> | |
</head> | |
<body> | |
<div id="print"></div> | |
<script> | |
var print = document.getElementById("print"); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>run code</title> | |
</head> | |
<body> | |
<textarea name="txt" id="txt" cols="40" rows="10"></textarea> | |
<br /> | |
<input type="button" id="btn" value="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
function escapeHtml(str) { | |
return str.replace(/[<>"&]/g, function(match) { | |
switch (match) { | |
case "<": return "<"; | |
case ">": return ">"; | |
case "&": return "&"; | |
case "\"": return """; | |
} | |
}); | |
} |