Skip to content

Instantly share code, notes, and snippets.

View dexteryy's full-sized avatar

Dexter Yang dexteryy

View GitHub Profile
$(new Image()).load(function(){
console.timeEnd("1");
$(new Image()).load(function(){
console.timeEnd("2");
}).attr('src', "http://shop.10010.com/images/iphone/iphone_3GS.jpg");
console.time("2");
@dexteryy
dexteryy / ctags for javascript
Created October 19, 2009 16:34
ctags for javascript
--langdef=js
--langmap=js:.js
--regex-js=/[ \t.]([A-Z][A-Z0-9._$]+)[ \t]*=[ \t]*[0-9"'\[\{]/\1/n,constant/
--regex-js=/([A-Za-z0-9._$]+)[ \t]*=[ \t]*\{/\1/o,object/
--regex-js=/['"]*([A-Za-z0-9_$]+)['"]*[ \t]*:[ \t]*\{/\1/o,object/
--regex-js=/([A-Za-z0-9._$]+)\[["']([A-Za-z0-9_$]+)["']\][ \t]*=[ \t]*\{/\1\.\2/o,object/
--regex-js=/([A-Za-z0-9._$]+)\.prototype[ \t.=]/\1/c,class/
--regex-js=/([A-Za-z0-9._$]+)[ \t]*=[ \t]*\(function\(\)/\1/c,class/
--regex-js=/['"]*([A-Za-z0-9_$]+)['"]*:[ \t]*\(function\(\)/\1/c,class/
--regex-js=/var[ \t]*([A-Za-z$][A-Za-z0-9_$()]+)[ \t]*=[ \t]*function[ \t]*\(/\1/f,function/
10/24/09 6:08:17 PM MacVim[391] -[MMVimController sendMessage:data:]@352: processInput:data: failed: pid=396 id=1 msg=SetMouseShapeMsgID reason=[NSPortCoder sendBeforeTime:sendReplyPort:] timed out (278071697.436471 278071697.438507) 1
// javascript版二分法:
function bsearch(v, data, pre){
pre = pre || 0;
var l = data.length,
half = Math.floor(l/2),
c = v - data[half];
if (c > 0)
return bsearch(v, data.slice(half + 1), pre + half + 1);
else if (c < 0)
# python版二分法:
import random, math
def bsearch(v, data, pre=0):
l = len(data)
if l <= 0:
return -1;
half = int(math.floor(l/2))
c = v - data[half]
(defun factorial (x)
(flet ((fact (x &optional (res 1))))
(if (= 1 x)
res
(factorial (1- x) (* res x)))
@dexteryy
dexteryy / gist:1289506
Created October 15, 2011 12:42
random bitmap
var tmp = document.createElement('DIV');
tmp.innerHTML = '<canvas width="512" height="512" style="position:fixed;top:10px;right:10px;z-index:99999;"></canvas>';
var e = tmp.firstChild;
document.body.appendChild(e);
var ctx = e.getContext('2d');
ctx.fillStyle = "#000";
ctx.fillRect(0, 0, 512, 512);
ctx.fillStyle = "#fff";
for (var y = 0, x; y < 512; y++) {
for (x = 0; x < 512; x++) {
TUI.swfobject = (function(TUI){
var uuid = 0;
var isie = !(navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length);
var webkit = TUI.browser.webkit;
var flashMC = TUI.getFlashMC;
var template = {
'object': '<object id="<%=id%>" <%=classid%> width="<%=width%>" height="<%=height%>" name="<%=name%>" <%=data%> style="<%=style%>" <%=mimetype%> >',
'embed': '<embed id="<%=id%>" width="<%=width%>" height="<%=height%>" flashvars="<%=flashvars%>" quality="high" name="<%=name%>" src="<%=src%>" style="<%=style%>" <%=mimetype%> ',
'pluginspage': '<a id=<%=id%> class="tui_noflash" href="#" style="width:<%=width%>;height:<%=height%>;display:block;overflow:hidden;cursor:pointer;<%=style%>" onclick="<%=fn%>()">需要flashplayer插件,点击安装</a>'
};
/**
* TUI::utilities::flash
* @created: Dexter.Yy
* @modified: $Author$
* @version: $Rev$
*/
/**
* @public 获取指定的flash对象
* @note 用于调用flash里提供的方法