Skip to content

Instantly share code, notes, and snippets.

View fillano's full-sized avatar

Hsu Ping Feng fillano

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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;
}
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 / test755.html
Created November 24, 2011 15:33
trace animate behavior
<!DOCTYPE HTML">
<html>
<head>
<meta charset="utf-8" />
<!-- jQuery -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<!-- CSS -->
<style type="text/css">
@fillano
fillano / another wait.js
Created September 22, 2011 16:53
try another way to Do.parallel, inspired by Tim Caswell's howtonode blog articles
function Wait(fns, done) {
var count = 0;
var results = [];
this.getCallback = function(index) {
count++;
return (function(waitback) {
return function() {
var i=0,args=[];
for(;i<arguments.length;i++) {
args.push(arguments[i]);
@fillano
fillano / example.js
Created August 29, 2011 06:07
CORS test
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': 'http://localhost'
});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/ with CORS.');