Skip to content

Instantly share code, notes, and snippets.

View fillano's full-sized avatar

Hsu Ping Feng fillano

View GitHub Profile
var input = 2011,
output = 2012,
depthLimit = 30,
countLimit = 100000;
count = 0,
depth = 0,
comp = [
function(x){return x+7},
function(x){return x/2},
function(x){return x*3},
@fillano
fillano / test772b.html
Created March 7, 2012 03:21
fix for answer in ithelp.ithome.com.tw
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>按 Alt 鍵,對 Div 裡的 Label 文字進行多選,一起移動、改變字型大小(IE only)</title>
<style type="text/css">
.drag{
position:relative;
cursor:pointer;
cursor:hand\9;
}
@fillano
fillano / test774.js
Created March 14, 2012 08:53
callback with binary tree tranversal
function ObjectId(str) {
return str;
}
var Subject = {
"data": {
"4f5ca201e7a3792f5e000003": {
"_id": ObjectId("4f5ca201e7a3792f5e000003"),
"childId": ObjectId("4f5ca5939da509475e000003"),
"name": "資產類",
@fillano
fillano / test782.html
Created April 24, 2012 03:28
worked fine with node-websocket server. websocket now supports both utf8 and binary data frame.
<html>
<body>
<input id="msg" type="text">
<input id="send" type="button" value="send">
<input id="file" type="file">
<div id="panel" style="border:solid 1px #336699"></div>
<div id="info" style="border:solid 1px #336699"></div>
<div id="img"><img id="imgtarget"></div>
</body>
</html>
@fillano
fillano / fwajax3.js
Created April 25, 2012 01:41
an ajax multipart/form-data uploader
function FwAjax3(host, cb) {
var req = function() {
try{ return new XMLHttpRequest();} catch(e){}
try{ return new ActiveXObject("Msxml2.XMLHTTP.6.0") }catch(e){}
try{ return new ActiveXObject("Msxml2.XMLHTTP.3.0") }catch(e){}
try{ return new ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
try{ return new ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
return null;
}(),
boundary = function () {
@fillano
fillano / test786ws.js
Created April 27, 2012 05:29
simple websocket server app demo
var WebSocketServer = require('websocket').server;
var http = require('http');
var server = http.createServer(function(request, response) {
console.log((new Date()) + ' Received request for ' + request.url);
response.writeHead(404);
response.end();
});
server.listen(8000, function() {
@fillano
fillano / test786.html
Created April 27, 2012 05:31
simple websocket app demo, a shared whiteboard
<!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,
@fillano
fillano / test793.html
Created May 14, 2012 10:47
demo for Javascript object clone and traits
<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') {
@fillano
fillano / test798.js
Created June 26, 2012 02:58
trampoline sample
function factorial(n, a) {
a = a||1;
if(n===0) {
return a;
}
return function() {
return factorial(n-1, a*n);
}
}
@fillano
fillano / app.js
Created August 13, 2012 12:02
test cookie and res.redirect()
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');