上周拿到小米。最近一周在尝试开发通迅薄。一方面是系统自带的通迅薄的确有些不爽的地,一方面也是想尝试写一些手机应用。
中间碰到两个问题,估计其它人也会碰到,就一并写下。
1 效率太慢。
网上有大量的帖子(如http://blog.csdn.net/yao_guet/article/details/6626001),先要去查所有联系人(有些人根本没有电话),接着去查电话纪录(一个人可能有多个电的话)。如果你的联系很多,比如像我有600多个联系人,那打开通迅薄差不多要3秒以上(小米的硬件还是很强悍的)。问题的关键就这在两个while上。
其实只需要直接查询ContactsContract.CommonDataKinds.Phone.CONTENT_URI就可以拿到DisplayName和PhoneNumber。我想内部很可能只查了一个表就搞定了。
另外,我的应用只需要手机,所以加上以下条件
StringBuffer selection = new StringBuffer()
.append(pn + " NOT LIKE '106%'")
.append(" and substr("+pn+",0,3) != '106'")
.append(" and "+pn + " NOT LIKE '010%'")
.append(" and length("+pn + ") >= 11")
.append(" and ("+pn + " LIKE '1%' or "+pn + " LIKE '01%')");
基本上够我用了。
针对查询速度问题,有熟手自己写AyncQueryHandler。我这种菜鸟没敢尝试。
2 通迅薄拼音排序
网上的例子大部份都是
sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
本来以为Sqlite和SQL server差不多应该能换那个LOCALIZED,结果都不行。
其实一句话就能搞定
sortOrder = "sort_key_alt";
我想可能在表中有个字段就叫sort_key_alt。
二个问题都很常见,网上也有很多人问,不过正确答案确不多。另外,Android的API也的确比较乱点,中文资料也很少(个人观点)。
1 安装软件
msysgit
http://code.google.com/p/msysgit/



TortoiseGit
http://code.google.com/p/tortoisegit/

2 获取私钥
运行Puttygen(开始菜单->TortoiseGit->Puttygen)

点击上图的“Generale”,稍等片刻

选择“Save private key”,将Key保存到你的硬盘(下次直接可以点击“Load”,不用再次生成)。
将你的Key发给git admin。
安装gcc编译器
sudo apt-get install gcc
安装盘pcre库,以支持正则
apt-get install libpcre++0
安装zlib,支持gzip压缩
apt-get install zlib1g-dev
安装打包程序
apt-get install make
wget http://nginx.org/download/nginx-1.0.8.tar.gz
tar xzvf nginx-1.0.8.tar.gz
cd nginx-1.0.8
./configure --prefix=/opt/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
make
sudo make
设置开机启动
wget http://www.cslog.cn/wp-content/uploads/2010/10/nginx.gz
gunzip nginx.gz
sudo mv nginx /etc/init.d
sudo chmod +x /etc/init.d/nginx
sudo update-rc.d -f nginx defaults
摘要: ep.io是一个基于python的云托管服务商。创始人Andrew (python最流利web框架Django的主要贡献者),现在的技术层面的支持都是他在。目前是邀请质,你需要留个email给他,他过一段时间就会帮你开通了。现在让我们来看看如何在ep.io上如何写一个Hello world站点。因为不是很喜欢Django那种很重的框架,所以选用Flask.你一步是确保你的机器安装了下面的组件sudo apt-get gitsudo apt-get python-pipsudo apt-get openssh-client安装epio的管理组件pip install epio之后再來就是 dep
阅读全文
摘要: #!/usr/bin/python#coding=utf-8import osimport marshal,cPickle"""marshal只能序列化有限的类型而cPickle能够序列化自定义的类型"""class Foo: def __init__(self, name): self.name = name def __str__(self): return self.nameo=range(0,10)L = Foo("Goodspeed")cls = [marshal,cPickle]for c in cls
阅读全文
摘要: #! /usr/bin/python# coding=utf-8import calendar"""返回的某个月的日历返回类型是字符串型"""cal = calendar.month(2011, 11)"""返回一年的日历"""cal = calendar.calendar(2011)cal = calendar.HTMLCalendar(calendar.MONDAY)"""打印出一个月日历"""cal.forma
阅读全文
摘要: #! /usr/bin/python# coding=utf-8from datetime import datetime, tzinfo,timedelta"""tzinfo是关于时区信息的类tzinfo是一个抽象类,所以不能直接被实例化"""class UTC(tzinfo): """UTC""" def __init__(self,offset = 0): self._offset = offset def utcoffset(self, dt): return tim
阅读全文
摘要: #! /usr/bin/python# coding=utf-8from datetime import datetime,date,time"""date类型顾名思义就是只表示日期,而time只表示time"""today = date.today()attrs = [("year","年"),( 'month',"月"),( 'day',"日")]for k,v in attrs: "today.%s = %s
阅读全文
摘要: #! /usr/bin/python# coding=utf-8from datetime import datetime,timedelta"""timedelta代表两个datetime之间的时间差"""now = datetime.now()past = past = datetime(2010,11,12,13,14,15,16)timespan = now - past#这会得到一个负数past - nowattrs = [("days","日"),( 'seconds'
阅读全文
摘要: #! /usr/bin/python# coding=utf-8import datetime"""datetime的功能强大能支持0001年到9999年""""""当前时间返回的是一个datetime类型now方法有个参数tz,设置时区类型。如果没有和方法today的效果一样"""now = datetime.datetime.now()#UTC时间datetime.datetime.utcnow()attrs = [("year","年&qu
阅读全文
摘要: #! /usr/bin/python# coding=utf-8import timefrom datetime import datetime"""表示日常所用时间的类,是用C实现的内嵌类。功能比较简单,但效率高。表示的时间范围有限1970年1月1日到2038年1月19日。""""""当前时间 返回的一个float型,以一个固定时间epoch(1970年1月1日0时起经过的秒数)因为time终究是以float型来表示的,所以对于timespan的问题,基本就成了数字问题。""&quo
阅读全文
摘要: # -*- coding: UTF-8 -*-#!/usr/bin/env pythondef pairwise(iterable): """ 交叉形成字典 """ itnext = iter(iterable).next while True: yield itnext(),itnext()def distinct(seq): """ 对序列进行去重 """ return dict.fromkeys(L).keys() if __name__ == '__main_
阅读全文
摘要: 本文介绍如何用lambda实现一个递归。包括整个思考的过程。供大家参考。
阅读全文
摘要: 本文皆在尝试ServiceStack.Redis在大并发下可能碰到链接数和存储冗余问题的解决方案。文章给出相关代码修改示例、分析代码及原因。
阅读全文
摘要: 在ubuntu 11.04上安装supervisorsudo apt-get install supervisor会得到以下错误Reading package lists... DoneBuilding dependency treeReading state information... Donesupervisor is already the newest version.0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.1 not fully installed or removed.After this ope
阅读全文
摘要: 1 X-AspNetMvc-Version在Global.asax的Application_Start方法中加入 MvcHandler.DisableMvcResponseHeader=true;2 X-AspNet-Versionweb.config中<httpRuntimeenableVersionHeader="false"/>3 X-Powered-Byweb.config中<httpProtocol><customHeaders><removename="X-Powered-By"/></c
阅读全文
摘要: The problem:Recently I have updated my system and also mecrurial. Today I tried to do some work with a repository hosted in another machine and I got the following warning:warning: bitbucket.org certificate with fingerprint 81:2b:08:90:dc:d3:71:ee:e0:7c:b4:75:ce:9b:6c:48:94:56:a1:fe not verified(che
阅读全文
摘要: docky模式下背景不透明的解决办法:由于ubuntu10.10-netbook采用了unity界面,所以,安装完Docky后,屏幕下方会出现一条黑边,并提示需安装混合管理器以启用Docky。解决方法:打开配置编辑器(press Alt-F2 to open the Run Application dialog and type gconf-editor),依次apps–>metacity–>general,在general中compositing_manager后打勾,即可正常使用Docky!
阅读全文
摘要: 现象:在Dell vostro 1088上装上ubuntu 10.10 桌面版64位。发现当耳机插入后,耳机没有声音,喇叭依然发声。解决方法在/etc/modprobe.d/alsa-base.conf 插入options snd-hda-intel model="olpc-xo-1_5"保存后重启就ok了
阅读全文
摘要: 在Linux下使用rdesktop链接windows server 2008 sp2时,每当尝试使用共享文件时,就会有提示框出来说设备断开。同时在Linux这边,rdesktop会报一个"NOT IMPLEMENTED: IRP Query Volume Information class: 0x7".幸好还有一个补丁放出,不过目前的发行版本还没有把这个补丁加上。http://csiuo.com/drupal/sites/csiuo.com/files/rdesktop-1.6.0.patched.2022945.tar.bz2下载下来sudo ./configuresud
阅读全文
摘要: $(".class")到底发生了什么。让我们一步一步来看注意rootjQuery其实就是$(document),绕了半天$(".class")就是$(document).find(".class")。接着看注意下面这行代码jQuery.find = Sizzle;也就是说jQuery.find默认是由Sizzle引擎提供的。那么开始进入Sizzle的代码了。先从简单的说起好的,这就很明白了,如果你的浏览器支持document.querySelectorAll,那么jQuery就直接用document.querySelectorAll来做了。有点区别的是IE8需要在document上设个id(如
阅读全文
摘要: 碰到 command 'gcc' failed with exit status 1
阅读全文