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 * gen(){} | |
var g = gen(); | |
g.throw('got an error.'); | |
//拋出一個例外,錯誤訊息是 'got an error.' |
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 * gen() { | |
console.log('start'); | |
var got = yield 'called'; | |
console.log(got); | |
} | |
var g = gen(); | |
var a = g.next(); | |
//顯示start | |
var b = g.next('hello generator'); | |
//顯示hello generator |
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 * gen() { | |
console.log('start'); | |
yield "called"; | |
} | |
var g = gen(); | |
//nothing happened | |
var a = g.next(); | |
//顯示start | |
console.log(a.value); | |
//顯示called |
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> | |
<body> | |
<script src="https://traceur-compiler.googlecode.com/git/bin/traceur.js" | |
type="text/javascript"></script> | |
<script src="https://traceur-compiler.googlecode.com/git/src/bootstrap.js" | |
type="text/javascript"></script> | |
<script> | |
traceur.options.experimental = true; | |
</script> |
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
module.exports = function(le, cb, payload) { | |
var count = 0; | |
this.getRecurser = function() { | |
return (function(f) { | |
return f(f); | |
})(function(f) { | |
count++; | |
return le(function() { | |
var args = Array.prototype.slice.call(arguments, 0); | |
return f(f).apply(f, args); |
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
<?php | |
$units = array(3, 8, 4, 5); | |
$cn = 0; | |
$units = array_map(function($a) use(&$cn) { | |
$cn++; | |
return array($a, $cn); | |
}, $units); | |
$first = array_shift($units); | |
$s = array_reduce($units, function($res, $item) { | |
return $res." UNION SELECT ".$item[0].", ".$item[1]." "; |
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="zh-TW"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf8"> | |
<style> | |
html, body, div, span, applet, object, iframe, | |
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
a, abbr, acronym, address, big, cite, code, | |
del, dfn, em, img, ins, kbd, q, s, samp, | |
small, strike, strong, sub, sup, tt, var, |
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('/', function(req, res) { | |
res.cookie('test', '123456'); | |
res.cookie('test', '0'); | |
res.redirect('/a'); | |
}); | |
app.get('/a', function(req, res) { | |
res.send('hello cookie test'); |
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 factorial(n, a) { | |
a = a||1; | |
if(n===0) { | |
return a; | |
} | |
return function() { | |
return factorial(n-1, a*n); | |
} | |
} |
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
<html> | |
<body> | |
<body> | |
</html> | |
<script> | |
function trait(spec) { | |
this.traits = {}; | |
for(var i in spec) { | |
if(spec.hasOwnProperty(i)) { | |
if(spec[i]['deps']&&spec[i]['func']&&typeof spec[i]['func']==='function') { |