周五node分享会,大家有空提前准备一些东西
(1) 先到下面的链接 找对应文件的node安装文件安装。
http://nodejs.org/dist/v0.10.22/
在命令行
$ node -v
/** | |
* steal from: https://raw.githubusercontent.com/lindenb/jsandbox/master/src/sandbox/MakeGraphDependencies.java | |
* thanks a lot | |
*/ | |
package sandbox; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; |
周五node分享会,大家有空提前准备一些东西
(1) 先到下面的链接 找对应文件的node安装文件安装。
http://nodejs.org/dist/v0.10.22/
在命令行
$ node -v
"use strict"; | |
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances. | |
// If one of those happens, we want to retry until it doesn't. | |
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a | |
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects; | |
// it has no synchronous behavior (e.g. throwing). | |
function dontGiveUp(f) { | |
return f().then( | |
undefined, // pass through success |
function keepTrying(otherArgs, promise) { | |
promise = promise||new Promise(); | |
// try doing the important thing | |
if(success) { | |
promise.resolve(result); | |
} else { | |
setTimeout(function() { | |
keepTrying(otherArgs, promise); |
module.exports = { | |
get: function (req, res) { | |
res.sendfile(req.path.substr(1)); | |
}, | |
_config: { | |
rest: false, | |
shortcuts: false | |
} | |
}; |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Enter your title here</title> | |
<link rel="stylesheet" href="styles/main.css"> | |
</head> | |
<body> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
'use strict'; | |
/*global module:false , require:false*/ | |
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
// Task configuration. | |
connect: { | |
options: { |
/* | |
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js | |
*/ | |
var http = require('http'), | |
fs = require('fs'), | |
util = require('util'); | |
http.createServer(function (req, res) { | |
var path = 'video.mp4'; |