1 安装Ruby1.9.1
sudo apt-get install ruby1.9.1-full
安装后gem也安装好了。是1.8.21
2 安装rails
sudo gem install rails
安装后是3.2.3
装完运行一下
bundle install
还没完,还得装一下nodejs
sudo apt-get install nodejs
以上所有代码是在ubuntu 11.10运行的。
从这几天的感受来看,Ror比较让我失望,框架太重了。我只写个helloworld,搞出一堆文件,而且安装太麻烦,又是什么execjs,又是jquery的,我最怕这种大而全的框架。
那个gem慢不说,还没有进度条。
Ror的安装还只能拿这个gem装,真是蛋痛呀。
(本人非专业人士,只作学习笔记,不对正确性负责)
普通年金就是一年存一笔钱,加上利息。类似于零存整取。
计算终值的意思就是零存几年后,最后能拿多少钱。
例如:小明计划一年存100元,银行利率是10%,问三年后本息合计多少?
详细分解如下
| 帐户金额 |
年底获得利息 |
| 100 |
10 |
| 210 |
21 |
| 331 |
33.1 |
| 364.1 |
|
或通过公式 P4 = 100 * (((1 + 10%)4-1) / 0.1)) = 364.1
注明:因为普通年金是每期期末发生,而零存整取是期初发生,所以公式年限需要加一。
计算现值就是计算终值反过来推。白话解释就是,如果想最后拿到多少钱,现在应该每年投多少钱呢?
例如:某人出国3年,请你代付房租,每年租金100元,设银行存款利率10%,他应当现在给你在银行存入多少钱?
| 帐户金额 |
年底获得利息 |
| 248.6852 |
24.86852 |
| 173.55372 |
17.355372 |
| 90.909092 |
9.0909092 |
| 100.0000012 |
|
将上面的参数带入公式 PV = 100 * (1-1/(1+10%)3) / 10% = 248.67
上周拿到小米。最近一周在尝试开发通迅薄。一方面是系统自带的通迅薄的确有些不爽的地,一方面也是想尝试写一些手机应用。
中间碰到两个问题,估计其它人也会碰到,就一并写下。
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 makewget http://nginx.org/download/nginx-1.0.8.tar.gztar xzvf nginx-1.0.8.tar.gzcd nginx-1.0.8./configure --prefix=/opt/nginx --conf-path=/etc/nginx/nginx.conf --pid
阅读全文
摘要: 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
阅读全文