Skip to content

Instantly share code, notes, and snippets.

View fillano's full-sized avatar

Hsu Ping Feng fillano

View GitHub Profile
@fillano
fillano / test920.html
Created March 5, 2014 17:45
getting started example from traceur-compiler
<!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>
function * gen() {
console.log('start');
yield "called";
}
var g = gen();
//nothing happened
var a = g.next();
//顯示start
console.log(a.value);
//顯示called
function * gen(){}
var g = gen();
g.throw('got an error.');
//拋出一個例外,錯誤訊息是 'got an error.'
function * serial() {
var c = 0;
while(true) {
yield c;
c++;
}
}
var s = serial();
console.log(s.next().value);
//顯示 0
function * gen() {
var c = 0;
while(true) {
yield c;
c++;
}
}
function run() {
var g = gen();
co(withYield);
withoutYield();
function timeout(sec) {
return function(notify) {
setTimeout(function() {
notify(null, new Date().getTime());
}, sec*1000);
};
}
function co(gen) {
@fillano
fillano / test.js
Created August 7, 2015 09:48
just for a reformation of code
$(function() {
function split( val ) {
//alert(val);
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
$("#S1")
@fillano
fillano / ecmascript2015.md
Last active August 29, 2015 14:27
ECMAScript 2015課程簡介

什麼是ECMAScript?

ECMA(European Computer Manufacturers Association)是一個標準組織,他底下有許多委員會,負責制定各種標準。其中一個標準叫做ECMA-262,就是Javascript的標準。這個標準除了定義型別、語法、敘述等程式語言的基本要素,也定義了一套核心的物件。不論在怎樣的平台上執行,Javascript都遵循一樣的語法,也一定內建了這些核心物件。我們所熟悉的Javascript,就是由這些核心的部分,再加上其他函數與物件所組成。在網頁中使用Javascript,除了核心物件,最重要的就是HTML DOM相關物件。如果使用伺服器端的語言例如Node.js,也是由這些核心物件加上執行環境提供的物件所組成。

註:ECMA還制定了其它各種不同的標準,例如C#的標準是ECMA-334,Microsoft Office使用的Office Open XML格式的標準是ECMA-376。對於軟體工程師來說,可能還聽過CLI、Eiffel、JSON、Dart等語言與技術,他們的標準都是由ECMA組成委員會制定的。

ECMAScript的演進

@fillano
fillano / 顯示audio物件資訊
Created October 18, 2010 15:04
利用audio標籤加上controls屬性來控制,然後檢視相關屬性在播放中的變化。
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
</head>
<body>
<audio src="bwv4_overture.mp3" controls id="player"></audio>
<div id="panel"></div>
</body>
</html>
@fillano
fillano / html5 video tag test
Created October 19, 2010 15:55
play a m4v or ogg video in different browser and see the status of video object
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
</head>
<body>
<video id="player" src="crockonjs-1.m4v" controls poster="vlcsnap-00001.png"></video>
<!--<video id="player" src="Apollo_15_liftoff_from_inside_LM.ogg" controls></video>-->
<div id="panel"></panel>
</body>