欧拉工程

十月 15th, 2008

显然这不是一个创造欧拉的工程,做做题而已,一想到欧拉几百年前就懂了我现在还不明白的东西就比较汗颜。

http://projecteuler.net

第一题

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

 

static int  Euler(int max)
{
    int mul5 = (max - 1) / 5;
    int mul3 = (max - 1) / 3;
    int mul15 = (max - 1) / 15;
    int sum=0;
    sum =  (1 + mul5)*mul5 / 2 * 5;
    sum += (1 + mul3)*mul3 / 2 * 3;
    sum -= (1 + mul15)*mul15 / 2 * 15;
     return sum;
}

 

第二题

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

Find the sum of all the even-valued terms in the sequence which do not exceed four million.

static int  Euler(int max)
{
    int i = 1, j = 2, sum = 2, count = 0, tem = 0;
    while (j <= max)
    {
        tem = i;
         i = j;
        j = tem + j;
        count += 1;
        if (count == 3)
        {
            sum += j;
            count = 0;
        }
    }
    return sum; 
}

只有奇数加奇数才能得到偶数,所以偶数的出现稳定在3次一个循环,引入count来避免使用偶数判断运算。

Linux输入法

十月 8th, 2008

Linux下的输入法有一个XIM框架,X程序通过XIM协议与输入法联系。如用户按下键盘按键后不直接把字符传给X程序,而是输入法程序,输入法处理后再传给X程序。aptitude install scim-pinyin同时安装了scim平台和拼音输入法。接下来就是启动scim和通知x程序使用scim。把这些事情放在一个脚本里面就是:

/usr/bin/scim -d
export  XMODIFIERS=”@im=SCIM”
export GTK_IM_MODULE=scim

XMODIFIERS是X程序用来识别输入法的标记,GTK和QT也有单独的一套。

为了开机自动运行把这个脚本保存为~/.xinput,然后再~/.xinitrc中加一句source ~/.xinput。

如果输入法工作不正常,检查一下

ps aux|grep scim                         scim是否启动。
export |grep XMODIFIERS        XMODIFIERS变量是否正确设置。
locale                                           LC_CTYPE是否设为zh_CN.UTF-8

 

http://www.scim-im.org/projects/imengines
http://code.google.com/p/ibus/wiki/PinYinUserGuideCN
http://sourceforge.net/projects/novel-pinyin/
http://www.opensolaris.org/os/project/input-method/

 

Aptitude替换apt-get

十月 1st, 2008

apt-get install aptitude install pkgname 安装软件
apt-get update aptitude update 更新本地软件数据库
apt-get upgrade aptitude upgrade 更新所有软件
apt-get dist-upgrade aptitude dist-upgrade 版本升级
apt-get remove aptitude remove pkgname 卸载软件
apt-get –purge remove aptitude purge pkgname 卸载软件并删除配置
apt-cache search string aptitude search string 搜索软件
apt-cache show pkgname aptitude show pkgname 显示包信息
apt-get clean aptitude clean 删除安装包
apt-get autoclean aptitude autoclean 删除过期的安装包
  aptitude hold pkgname upgrade时不升级

E2开发资料

九月 15th, 2008

http://www.linuxdevices.com/articles/AT8243331060.html

http://wiki.openezx.org/Rokr_E2

http://moto4lin.sourceforge.net/wiki/FlashingEZX

http://wiki.openmoko.org/wiki/Main_Page

https://opensource.motorola.com/sf/frs/do/viewSummary/projects.rokre2/frs

https://developer.motorola.com/

交叉编译相关

http://wiki.openezx.org/Crosscompile

https://sourceforge.net/projects/libxze2/

http://kegel.com/crosstool/

http://www.freaknet.org/martin/crosstool/

http://blog.chinaunix.net/u/26710/showart_394113.html

http://cross-lfs.org/view/clfs-sysroot/arm/

xscale-gcc-vfp-3.3.tar.gz

e2资料

SD卡USB2.0支持

130万像素摄像机

2inch ,240X320QVGA,26万色TFT显示屏

调频收音机 无线蓝牙

系统:MontaVista Linux Kernel + Framebuffer + Qte + ezx/Chemalon

Telnet

UsbNet模式连接电脑,装USB Net Drivers 驱动或moto全能驱动包

telnet 192.168.16.2 用root登录。

Linux

modprobe usbnet
modprobe cdc-acm

$ sudo ifconfig usb0 192.168.1.1
$ telnet 192.168.1.2

刷系统

安装RSD lite软件。

下载要刷的系统包,sbx是内核,sbf是图形界面。

关机。按住侧边右上的语音键,同时按下挂机键,进入初级启动界面,稍后片刻继续按语音键进入第二启动界面。

把手机连上电脑,打开RSD,刷sbx文件(有些包只有sbf文件,那就刷sbf)。

刷完sbx,拔下手机卸下电池关机,按第一步进入初级启动界面,开始刷sbf。

over。详细

http://www.kmobiletools.org

http://www.aktaeon.com/tag/e2/

http://www.e2mod.com/

APT

九月 15th, 2008

APT配置文件 /etc/apt/apt.conf
APT软件服务器地址 /etc/apt/source.list
下载的安装文件 /var/cache/apt/archives/
本地软件数据库(通过apt-get update与服务器同步)/var/lib/apt/lists/

apt-spy 自动生成source.list

CD-ROM加入source.list文件 apt-cdrom add
#apt-get install nano-tiny -s(–simulate)
#apt-get install nano-tiny -d(–download-only)
# apt-get –reinstall install nano
apt-cache search mysql-server –names-only
apt-cache show mysql-server
apt-cache depends mysql-server

apt-file 的主要用途是确定某个文件是由哪个软件包提供的
apt-file search filename apt-file list packagename apt-file update

apt-get remove vim

如果想彻底删除这些包及其配置文件

apt-get remove vim –purge

如何清除下载到本地的软件库
#apt-get clean
apt-get autoclean //仅删除那些不需要再次下载的文件.

先运行 apt-get update 更新数据库
版本内升级, 只需一条命令即可完成更新:
#apt-get upgrade -u 让 APT 显示完整的可更新软件包列表.
升级到新版本
apt-get dist-upgrade

升级内核
apt-get install linux-image

aptitude另一种方法

下载软件的源代码 #apt-get source packagename
http://debian.linuxsir.org/doc/inthedebianway/Debian_Tools_apt.html

字符编码

九月 15th, 2008

GB2312是最早的汉字编码,只有6千多个汉字。
GBK是微软对GB2312的扩展,有2万多汉字并向下兼容GB2312.
GB18030是现行国家标准,PC平台必须支持,四字节字符空间,兼容ASCII,兼容GBK,感觉就是中国版的UTF-8。
BIG5是一个通行于台湾香港地区的繁体字编码方案。
CJK代表中日韩用到的字符集,占了Unicode的大部分(人家26个字母就搞定了)。
code page是微软对不同的编码定义的一个编号。
UTF-8是一种Unicode实现,一共用到四字节字符空间,但用1个字节编码英文字母,3个字节编码汉字,就是说如果文本全是英文的话它与ASCII没有区别,一个字符只需8位存储空间,一般汉字的话需要24位存储空间。UTF8用的不爽的人是像斯拉夫语和希腊语那样本来全部字符集也是8位就可以搞定的但在UTF-8中却被分到了高8位,于是所有的编码要用16位,足足增加了一倍。
汉字的话如果单独编码也只需要2个字节(2^16=65536个字符)就够了,但在UTF-8需要三个字节。

UTF-16是Unicode另一种实现,和UTF-8一样也是变长编码,只是他由16位起步编码,不够在加16位,因为16位已经可以覆盖大部分常用Unicode字符了,所以会用到32位的情况很少,用UTF-16汉字是用两个字节表示的。

Unicode最原始的实现是UTF-32,不像UTF-8为ASCII优化,UTF-16为包括汉字在内的BMP部分优化,UTF-32中任何字符都是四个字节的,简直直接就把Unicode标准照搬过来了,因此没有太大实用价值。

在因特网世界统一使用Unicode是必然的趋势,只是在选择具体编码的时候,当英文数据占多数的时候用UTF-8比较划算,当东亚文字包括中日韩文占多数的时候就应该用UTF-16了,期待着那一天,顺便BS一下百度还在用GB2312的状态。

Hello world!

四月 8th, 2008

欢迎使用 七十二松 (72pines) WordPress 。这是系统自动生成的演示文章。编辑或者删除它,开始您的博客!