———–
vim->email->wordpress
一个未成形的富文本编辑器
六月 18th, 2011
comet的两个小问题
五月 31st, 2011
最近做了一个webim的项目,使用长连接做push,在chrome和ie下有些小问题
1. chrome的左下角下一直显示等待push.xx.com的响应
解决方法:接到请求立刻返回http头就可以了,不等到有了推送再返回http头
2.ie下对于每个域名同一时刻最多只能有两个并发请求,如果开多个窗口(这个限制不是针对单个窗口的),有的请求便会被阻塞。
解决方法:对每个窗口使用不同的请求域名
使用三级泛域名配置起来最简单,例如:123.push.xx.com.但是JS里涉及到跨域的问题,所以还是要使用push-123.xx.com这样的二级域名。查了下bind9的手册可以这么搞
;示例 $GENERATE 0-100000 push-$ IN A xx.xx.xx.xx
这样ie下JS可以用时间戳或随机数决定一个domain去请求,不会产生阻塞
乱马~
四月 22nd, 2011
~/.bashrc
#flex sdk在ubuntu上好好的,到了mac os下就乱码了~~! mxmlc() { /Users/hualu/opt/flex_sdk_4.1.0.16076/bin/mxmlc $* | iconv -f gb2312 -t utf-8 } #tree,一条基本不用的命令,给同学发目录列表用过一次,中文会被编码 tree() { /opt/local/bin/tree $* | ascii2uni -aK }
关于js的字符串编码
四月 21st, 2011
The String type is the set of all finite ordered sequences of zero or more 16-bit unsigned integer values (“elements”). The String type is generally used to represent textual data in a running ECMAScript program, in which case each element in the String is treated as a code unit value (see Clause 6). Each element is regarded as occupying a position within the sequence. These positions are indexed with nonnegative integers. The first element (if any) is at position 0, the next element (if any) at position 1, and so on. The length of a String is the number of elements (i.e., 16-bit values) within it. The empty String has length zero and therefore contains no elements.
When a String contains actual textual data, each element is considered to be a single UTF-16 code unit. Whether or not this is the actual storage format of a String, the characters within a String are numbered by their initial code unit element position as though they were represented using UTF-16. All operations on Strings (except as otherwise stated) treat them as sequences of undifferentiated 16-bit unsigned integers; they do not ensure the resulting String is in normalised form, nor do they ensure language-sensitive results.
按照ECMA标准,无论引擎底层如何实现,js的字符串看起来都应该是UTF-16编码的字符串,并且每个字符串单元代表一个UTF-16的双字节
例如:
>”中”.length
1
(不知道这是啥特殊字符,发到wordpress有问题,直接贴图,那我是怎么输进去的呢,后面说转义符)
“中”编码成UTF-16为一个双字节0x4E2D,所以长度为1
长的像口的字符编码成UTF-16占4字节 0xD950 0xDF21,占用两个双字节,长度为2
(下面用”口”代替这个特殊字符)
>”口”[0]
“”
>”口”.charCodeAt(0).toString(16)
“d950″
所以字符串的长度显然是占用双字节的个数,而非我以前想当然认为的实际字符的个数。。。
\udddd形式的转义同样用来表示一个双字节,而非字符本身,”口”用转义符来表示的话:
最后我要的结论是:
对于像objective c里unichar一样的UTF-16编码格式的字符串可以通过@“\\u04x”直接得到json转义串~
VimiTunesList for vim on Mac OS X
四月 17th, 2011
2011.4.18更新
增加了一个选项,可以指定一个播放列表
let g:vim_itunes_playlist = “音乐”
——————-
本来用automator为itunes添加了一个全局搜索的快捷键,无奈快捷键不快捷,点击到激活延迟严重,从itunes选完不能自动返回vim,跟我ubuntu上自己写的mpd搜索不能比。so,写了一个vim插件,效果看我用quicktime录的屏幕(唉,ubuntu上完全没有好用的屏幕录像工具)
第一次加载列表慢点,以后有缓存就瞬间了,刷新缓存用 ctrol+r
安装方法:
下载两个文件
vimiTunesList.vim
vimitunes
将vimiTunesList.vim放到 ~/.vim/plugin/目录
将vimitunes放入$PATH里面随便一个目录,比如我的~/bin
使用方法:
开vim或macvim,输入:IT,会加载一次列表,在想要播放的曲目上回车播放,可以vim的搜索方式搜索。