03 2011 档案
摘要:脚本名: gen_include_path_for_vim.sh#!/bin/bash include_path=$(make --just-print $*\ | sed -n -e '/^g++/p' | sed -n -e "1p" \ | awk 'BEGIN{RS=" "; ORS="\n"} { print $0; }' \ | sed -n -r -e '/^-I/{s/^-I//;p}' | awk -vORS="," '{print $0;}
阅读全文
摘要:Nautilus ScriptsNautilus is the official file manager for the GNOME desktop. It has ability to run add-on scripts written in any scripting language (or binary file) without a problem. All add-on scripts must be created and stored at ~/.gnome2/nautilus-scripts ($HOME/.gnome2/nautilus-scripts) locatio
阅读全文
摘要:上编文中讲的 封装, 只实现了 setItem, getItem, removeItem接口。 如果要实现 key()和length 就不行, 也就是说如果你需要遍历的功能,那么需要选择别的方式。 这次我打算损失点性能来模拟。借助 JSON 来保存 对象。 代码 if(!window.localStorage && /MSIE/.test(navigator.userAgent)){ wind...
阅读全文
摘要:引 所有有垃圾回收的语言,都会遇到个问题, 对象的深拷贝。 可惜的是 Javascript 语言并没有在语言级别提供支持。 JSON 是 WEB中最流行的数据格式,简洁高效(比xml好), 其它如lua和ruby也学习javascript这个优点。要达到这个优势,语言必须要有足够的字面量支持(而不是像C++那样靠库实现各类结构)。 当想到要自己写一个clone方法的时候,就头大,后来想到个简洁的方...
阅读全文
摘要:引 chrome, safari, firefox, ie 9都支持 localStorage. 但可恶的是,中国 ie 6 占有最大的比例。 使用 cookie 不但容量有限,而且给我们增加了不少的带宽,也进行影响网站的性能。 所以我写了 localStorage.js 来模拟 localStorage, 这样其它js 就跨浏览器地使用localStorage了. 代码 if(!window.l...
阅读全文
摘要:最近在写一个页面,在出了ie6外的所有浏览器中都正常(ie7,8,9, firefox, chrome), IE6下提示 “无法设置selected属性。未指明的错误”。 后来发现是jquery 在 ie6 下操作 select控件有BUG. 我程序中是这样使用的: $("#genre").val(0); 改成: setTimeout(function(){ $("#genre").val(0)...
阅读全文
摘要:Chrod算法是P2P中的四大算法之一,是有MIT(麻省理工学院)于2001年提出,其他三大算法分别是: CAN Pastry Tapestry Chord的目的是提供一种能在P2P网络快速定位资源的的算法,Cord并不关心资源是如何存储的,只是从算法层面研究资源的取得,因此Chord的API就简单到只有一个set、get。 1、Chord是什么? Chord是一个算法,也是一个协议。作为一个算法...
阅读全文
摘要:Richard Jones Blog : http://www.metabrew.com/article/libketama-consistent-hashing-algo-memcached-clients In old way, clients mapped keys->servers like this:server = serverlist[hash(key)%serverlist.len...
阅读全文
摘要:function update_page_list(page_bar, total, cur_page,num__per_page) { page_bar.html(""); if(total<=0) return; var num_page = ~~((total+num__per_page-1)/num__per_page); if(cur_page > 1) { page_bar....
阅读全文
摘要:简介: 很多应用譬如监控、即时通信、即时报价系统都需要将后台发生的变化实时传送到客户端而无须客户端不停地刷新、发送请求。本文首先介绍、比较了常用的“服务器推”方案,着重介绍了 Comet - 使用 HTTP 长连接、无须浏览器安装插件的两种“服务器推”方案:基于 AJAX 的长轮询方式;基于 iframe 及 htmlfile 的流方式。最后分析了开发 Comet 应用需要注意的一些问题,以及如...
阅读全文

浙公网安备 33010602011771号