Skip to content

Instantly share code, notes, and snippets.

View fundon's full-sized avatar
🎯
Focusing

Fangdun Tsai fundon

🎯
Focusing
View GitHub Profile
@fundon
fundon / snippet.js
Created December 15, 2011 08:43 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* but retaining the use of a document fragment to minimise the number of times objects are
* written to the DOM. Also, better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
/**
* 遗留的问题: 这是utf-8 ??
* 关于encodeURIComponent 与 encodeURI 的最佳实践
* http://stackoverflow.com/questions/75980/best-practice-escape-or-encodeuri-encodeuricomponent
*
Unicode Strings
In most browsers, calling window.btoa on a Unicode string will cause a Character Out Of Range exception.
To avoid this, consider this pattern, noted by Johan Sundström
@fundon
fundon / defeat.gfw
Created November 23, 2011 09:15
翻墙方法
普及一些 获取翻墙方法 的方式 #翻墙、 #gfw、 #vpn、 #翻墙软件
1、用Google Reader(https://www.google.com/reader/view/)订阅这两个网站:
http://igfw.tk/feed
http://feeds2.feedburner.com/chinagfwblog (注)
记住Google Reader一定要用加密连接(https://)。
2、发电邮(最好用Gmail)到:[email protected]或者[email protected]会在稍后回复翻墙方法。有可能在垃圾箱。
3、通过http://goo.gl/uKosJ下载Psiphon 3。(感谢 +与非 分享)
@fundon
fundon / jquery.disableSelect.js
Created November 16, 2011 08:35 — forked from ten1seven/jquery.disableSelect.js
Enable/Disable text selection
jQuery.fn.disableTextSelect = function() {
return this.each(function() {
$(this).css({
'MozUserSelect':'none',
'webkitUserSelect':'none'
}).attr('unselectable','on').bind('selectstart', function() {
return false;
});
});
};
@fundon
fundon / sparc.c
Created November 16, 2011 02:36 — forked from vmg/sparc.c
Sparks in C
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
int main
(int argc
,char *ac []){int i, count = argc - 1;
double * dvalues=malloc(01- 01+count*
sizeof(double)+1); double mi=DBL_MAX,ran=.0,ma =DBL_MIN,mo;for(i= 00; argc>1
&&i<count;i=i+8-7) {double val = atof(ac[i+1]) ;if(23&&val<mi)mi= val;if(val
@fundon
fundon / gist:1237047
Created September 23, 2011 09:44 — forked from plu/gist:1236941
[:WebBrowser] [:WebApp] [:WebSocket] [:RabbitMQ] [:Worker]
| | | | |
|-------- Login --------->| | |<-- Create Worker Queue --|
| | | | |
|<--- Response (ExtJS) ---| | | |
| | | |
|----------- Connect (socket.io) --------->| | |
| | | |
| |-- Create Client Queue -->| |
| | | |
@fundon
fundon / LICENSE.txt
Created August 31, 2011 13:41 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@fundon
fundon / binarytree.js
Created August 25, 2011 09:29
Binary tree in JavaScript
function cons(x, y) {
return function(w) { return w(x, y) };
};
function car(z) {
return z(function(x, y) { return x });
};
function cdr(z) {
return z(function(x, y) { return y });
var number = 10;
var showNumber = function () {
alert(number);
}
(function () {
number = 20;
showNumber();
})()
@fundon
fundon / mapreduce.js
Created June 29, 2011 10:11 — forked from adomado/mapreduce.js
Simple MapReduce with Javascript
var Job = {
data : [
"We are glad to see you here. This site is dedicated to",
"poetry and to the people who make poetry possible",
"poets and their readers. FamousPoetsAndPoems.com is",
"a free poetry site. On our site you can find a large",
"collection of poems and quotes from over 631 poets",
"Read and Enjoy Poetry",
"I, too, sing America",