April 2012
8 posts
text-transform →
Apr 27th
1 tag
simple chat room with nodejs & Socket.IO
本想跟据这篇教程用websocket写个聊天室,发现了socket.io后一切就变得更没技术含量了。 中途遇到个问题,本机上挺好的,在室友机子能收到我的html,但老是xhr失败,我以为是防火墙的原因,找了篇略正解的教程开关了下node监听的端口(terminal里输): 开启81端口: iptables -I INPUT -i eth0 -p tcp --dport 81 -j ACCEPT iptables -I OUTPUT -o eth0 -p tcp --sport 81 -j ACCEPT 关闭81端口: iptables -I INPUT -i eth0 -p tcp --dport 81 -j DROP iptables -I OUTPUT -o eth0 -p tcp --sport 81 -j DROP 用lsof...
Apr 24th
1 tag
Detect user is viewing the page
http://stackoverflow.com/questions/6308124/javascript-detect-user-is-viewing-the-page window.onblur= window.onfocus=
Apr 23rd
1 tag
“Although it was nice to have jQuery at your disposal whenever you felt like...”
– http://www.nodebeginner.org/
Apr 21st
1 tag
bad and improved: a carousel
bad: //carousel function carousel(id){ this.container = o_o(id); this.cases = this.container.getElementsByTagName('a'); this.count = this.cases.length; if(!this.count > 1){ return } this.current = 0; //control init this.control = this.container.getElementsByTagName('ul')[0]; if(!this.contro){ this.control = document.createElement('ul'); ...
Apr 17th
1 tag
Ubuntu 4
scim sublime里打不了中文,根据教程(还有一个有图有真相版的)是要用scim打字,用apt-get装完scim后,网上的方法是装scim-chinese,但我这边提示没这个包,回头看下安装信息,有个scim-pinyin的包。装之不仅没有搞定,还把全系统的文字都变成了难看的宋体,坑爹。 最后无奈去研究ubuntu字体,找到了这个和这个,不过gnome-tweak-tool什么的完全没气作用,最后还是到/etc/fonts/fonts.conf 改了半天的系统字体设置,但sublime可以显示中文却始终切不出输入法,虽然又找到篇教程折腾scim,不过我还是换回ibus,用vim吧。 sudo mv /home/ocean/dl/fonts.conf /etc/fonts/fonts.conf 老是忘了/home/ocean… ...
Apr 8th
1 tag
Ubuntu 3
nodejs npm less 为了装less compiler先得装nodejs,用官方的命令行方法装了node,然后装npm,按照官方的方法用: curl http://npmjs.org/install.sh | sh 结果即使加了sudo,还是 find: `/usr/lib/node': 没有那个文件或目录 ... Error: EACCES, mkdir '/usr/lib/node_modules', ...一堆红色的ERR! 最后竟然用apt-get装了npm, 但用: $ npm install less 装less时之前什么结果没记,现在是: npm http GET https://registry.npmjs.org/less npm http 304 https://registry.npmjs.org/less ...
Apr 4th
1 tag
Ubuntu 2
sublimeText2 goagent packageControlPlugin_for_sublimeText2 早上起来继续折腾linux,先装sublimeText2,找到了篇靠谱的教程,其实也没教什么,主要说了下怎么生成快捷方式和系统变量,只是发现官网下的其实可以算是“免安装”的,用 tar -xjvf ****.tar.bz2 解压到当前文件夹就好。 装好sublime就想装它的PackageControl插件,用官网上的指令后发现出现了urlopen error 104之类的东西,离线的也下不下来,怀疑是网络不行,于是开始装goagent,服务器端我已经有了,用 unzip ****.zip 解压,然后改下local/proxy.ini,用 python proxy.py 运行下就好。 ...
Apr 4th