Thinking beyond source code

Recording my throughs


  • 首页

  • 关于

  • 归档

  • 标签

Chromium设置默认的搜索引擎为google.com.tw

发表于 2010-04-05 | 分类于 未分类

最近google.cn & google.com 经常被墙,搞得看着看着就被重置了,使用起来很是麻烦。 我是使用chrome/界面的搜索直接搜索的。

但是发现google.com.tw并没有被封,也不会出现重置的问题,所以可以把默认浏览器的搜索引擎换成google.com.tw来解决被重置的问题。

下面是chrom的设置:

选项->搜索引擎管理->添加-> 名称就写gogoleTW 关键字: www.google.com.tw 网址: http://www.google.com.tw/search?{google:RLZ}{google:acceptedSuggestion}{google:originalQueryForSuggestion}sourceid=chrome&ie={inputEncoding}&q=%s  然后点添加。 最好再设置成默认搜索引擎就可以了。

因为firefox下面的搜索引擎必须是插件形式的, 所以暂时没有好的办法把默认搜索引擎转到google.com.tw下面,有时间也许自己可以写一个。 

Firefox下的插件已经写好了: 点这里

 

 

移动的京东的刷卡体验

发表于 2010-03-21 | 分类于 未分类

说移动改变生活,说的太多了也就和一般的广告词没什么区别了,可是今天真的体验到什么叫做移动改变生活了。

引子是从前几天我的Thinkpad的喇叭坏了,几天听着耳机下来,感觉耳朵要坏掉了,很不舒服,于是想要去买个音箱来听听,感觉自己的小屋放不下什么大的低音炮,也不好带,所以就买了一个漫步者M11,可以放在笔记本书包里也只占很小的位置。 很爽。

于是就来到新蛋和京东两家选了选,由于以前在新蛋上买东西都没怎么开心过,于是就选择京东了,¥105。星期日晚上9店下单,选择的物流是货到付款。今天(星期一)上午8点半的时候,就听到有人按门铃,京东送货的已经在楼下了。睡梦中我抓起我的钱包,靠,昨天花的只剩60多了,这下不好了。 

忽然想起记得京东在选择付款方式的时候还有POS刷卡,也许可以刷卡吧。好吧。下去试一下吧。

到了楼下,问京东的大叔说,可以刷卡吧。于是那个大叔就掏出来一个POS机,值得注意的是,这个POS机是移动(Mobile,不是中国移动那个移动)的。这样我在楼下,就刷卡拿东西上来放着贝多芬来煲音箱了。

传统的POS机是需要连线的,就像固定电话一样所以不能移动。所以京东这次拿的这个POS机是移动的,其实你也可以把它看成专门用来刷卡的手机,数据传输我想用一个EDGE的Modem就足够了。说起来好像又没什么了(当我夸赞京东大叔的POS机的时候,大叔很自豪的说,别看这个东西阿,一个要好几千呢,可不,肯定会比手机贵),如果是网上付款就可以避免这样了,可是两种支付方式购物体验是完全不一样的,毕竟我还是更喜欢一手交钱一手拿货的感觉吧。我想这是京东赞的地方,我看好你哦。把移动和电子商务结合确实很方便,很powerful。

该上班了,贴图吧:

一个音箱,一个套子,质地很好,音质的话,煲完了才知道。

竖起的显示器

发表于 2010-03-19 | 分类于 未分类

秀一下今天我的杰作。

这是开着emacs的样子,分屏下来上下看的很爽。

这是开着gmail的样子。操作系统是ubuntu 9.10

把显示器竖起来有几个好处:

1, 在编辑器里面可以看到的代码行数是横着的2倍左右
2. 看电子书也可以不用翻页
3. 很不低调

不过也有几个不好的地方:

1. 液晶显示器是有纹路的,而最佳的纹路是横着放置正前方看, 不然会有一定的虚的出现,所以在竖起来以后就好像有一些重影。 有点费眼睛。所以整个质量好的显示器才好啊。

2. 支架, 不像是有些高级液晶显示器,我们公司的显示器比较低端,没有能够旋转的支架,所以我就是把显示器放在底座上的,并不牢固,但是一个专门的支架好像卖的挺贵的。

3. 不够低调。回头率太高。有位大哥看见我这样说, “我靠,你就不能低调点啊"。

在ubuntu中添加debian的源并安装xtables-addons

发表于 2010-03-15 | 分类于 未分类

也许你想在ubuntu中安装xtables-addons来编译某个爱情故事。那么这里给出一个具体步骤。

我实验的是使用ubuntu 9.04

1. 找到一个debian源。
我用的是http://debian.ustc.edu.cn/debian 如果是用其他的源,可以下面的PUBKEY和地址要替换掉。

2. 系统 -> 系统设置 -> 软件源

在第三方软件中加入 deb http://debian.cn99.com/debian  unstable main

这时候Update有可能会提示
NO_PUBKEY 9AA38DCD55BE302B

如果提示就使用下面的命令把公钥导入,否则可以忽略这两条命令。

gpg --keyserver pgpkeys.mit.edu --recv-key F1D53D8C4F368D5D

gpg -a --export  F1D53D8C4F368D5D | sudo apt-key add -

3. update

sudo apt-get update
 
4. install
sudo apt-get install xtables-addons-common

如果你是为了编译某个爱情故事需要的xtable来的话, 可以再

sudo apt-get install --reinstall iptables-dev

就可以继续编译那个爱情故事了。

BTW,不过建议在可以编译以后,最好从源里面把debian的库去掉,再update一下,因为有可能版本差距太大,会造成apt一些依赖关系的破坏。

Android Audio System(2): ALSA Layer

发表于 2010-03-15 | 分类于 未分类
* Hardware Layer: Alsa
Author : Zhang Jiejing (http://thinksrc.com)
Data: 2010-3-15
ALSA hardware layer is becoming a standard part of Android master tree.
the Android ALSA layer library Code base:
http://android.git.kernel.org/?p=platform/hardware/alsa_sound.git;a=summary
The major development job is by WindRiver.
This paper is a continue part of the past post Audio audio system(1), if you haven't read it , I strongly suggest you read it first.

** Roles

***  AudioSystem - Audio Abstract Layer

code: frameworks/base/media/libmedia/AudioSystem.*

*** AudioPlicyManager - Platform specific policy manager
Alsa: AudioPolicyManagerALSA.* : This Manager can be implement in OSS or ALSA.
*** AudioStream[In|Out]Alsa
This class is controled by AudioPolicyManager, charge the read and audio mix job. using alsa pcm interface.
*** Alsa device handler: reference code: alsa_default.cpp
This part is compiled as a separated shared library, alsa_default.cpp just acts as a  fall back.(This is just like other libhardware modules, the libhardware frist search the [ModuleName].[ro.hardware prop].so  such as alsa.dream.so and ro.product.board, ro.board.platform, ro.arch is continue search, if can't find any of these libraries, it's will fall back to search [ModuleNmae].default.so, such as alsa.default.so)
** Communation betweens Roles:
AudioSystem has a AudioPolicyServer Client, it will PRC to AudioPlicyManager class, in this case, the class is  AudioPolicyManagerALSA.
AudioStream[In|Out] will use hardware lib via dlopen() the ALSA handler library. And the call the open/close directly.

** Control follow:

*** Media Server side.

   When recording, the AudioSystem will call AudioSystem::getInput first, this call will deliver to AudioPolicyManagerALSA::getInput();   AudioPolicyManagerALSA::getInput() will check channel, input format, sampleRate, and call the mpClientInterface openInput's interface(AudioPolicyManagerALSA.cpp:1014), this call will back into audio_flinger 's openInput(AudioPolicyServer.cpp:504),

*** Back to AudioFlinger   

   In AudioFlinger::openInput,This function will wil call AudioHardware's openInputStream(), this will drop into AudioHardwareALSA class(audioHardwareALSA.cpp:229), this fucntion will call the hardware list and call the open function of this device, this will into the hardware shared library(such as alsa_default.cpp) 's open function.

*** Into hardware handler library

In the open() it will call snd_pcm_open, this is a ALSA user library function, this function will do some check device, and apply the config (such as hooks in asound.conf) belows to this device. Also it's will do some params setting such as set Hardware params, and software params.After open() returns, the the AudioHardwareALSA will new a AUdioStreamInALSA class, by the handler open() returns,  and acoustics.

*** Leave hardware handler library

In AudioStreamInALSA, it will init the ASLAStreamOps class by the alsa hardware hander( for example, alsa_default).Also will create a acousitic device in same time.After that, AudioHardwareALSA will call a stream's set(), this will be in the ALSAStreamOPS::set() function.This function will see the channel config in hardware handler, and format and sample rate, and perpare for the parameter AudioHardwareALSA need.These paramenter will finnally return to audioFlinger, audioFlinger will check whether these valuse are same to what he want, if the value is not same and not by error, the audioFlinger will call openInputStream again by these paramenters.

   If the the input is open success, the a RecordThread will be created, and put it into the record thread pool.And then, the record precess will same to other non-ALSA sound hardware.This is how the ALSA connect to AudioSystem and how ALSA connect to ALSA hardware handler.

Emacs万能 系列之TAB转空格

发表于 2010-03-10 | 分类于 未分类

最近在参与一个开源项目, iptux ,为了统一风格我们要把代码里面所有的tab都转换成空格,大约有70个C++源文件两万行代码那么多。 

我的第一个想法是去找indent工具来作这件事清,可是当我实验了几下以后发现不对,indent会作很多其他的风格的修改,做了太多事情了,不行。

怎么办呢,上emacs,想不到该怎么办的时候我总是想到emacs,合并代码,去找BUG...不胜枚举.

我是这么作的,大约用了2分钟作了这个工作两次(因为第一次做完以后提交的时候遇到冲突,所以就revert & up了以后重新来了一次)。

1. 首先,现用C-f 打开所有的.cpp和.h文件

2. 按F3开始录制宏,

3. 然后开始一次转一个文件

C-SPC   # 设定开始标记

M-S-> # 到达文件末尾

M-x untabify ENT  # 输入转换成空格的命令并回车

C-x C-s # 保存文件

C-k ENT #关掉当前buffer

4. 按F4表示录制完毕.

然后就狂按F4执行刚才录制的宏, 直到没有窗口为止.因为我们之前已经把所有需要转换的文件都打开了,所以关到没有窗口的时候就是全部转换完了。

OK, 转换完了。提交代码了。

顺便推销一下iptux,如果你在局域网环境中,你需要一个Linux下面兼容飞鸽传书类的软件的话,就选择它吧。 

迁移到GAE上面

发表于 2010-03-10 | 分类于 未分类

由于众所周知的原因,原来BLOGGER的博客还是不能访问,于是在折腾了半天之后, 还是选择在GAE上发布了新的博客,导入的时候遇到一点问题, 是我的archive太大了, 编辑去掉以后就可以导入了。

以后就在这个上面多写写东西了。

使用的是micolog, 感谢http://xuming.net。

新域名将会在48小时内启用,这样就可以使用thinksrc.com来访问了。

终于弄好了。

android的域名解析

发表于 2010-03-07 | 分类于 未分类

android 中的域名解析库, 一般来说叫(libresolve)是netbsd中抓取出来的,在应用程序的层次上, 调用gethostbyname, 而gethostbyname中就是调用了resolve库里面的东西,
里面主要用一个 _res的全局变量,

struct __res_state _res;

由res_send, res_init来改变这个值。 在netbsd的原来实现中, 是通过查看/etc/resolve.conf来得到这个DNS服务器的。

然后通过给这些dns服务器发UDP包来获取这个域名的地址。

后来这个库的发现上做了一些感动, 通过

struct __res_state *res_state(void);
#define _res (*(res_state())

来把这个全局变量替换成一个函数, 通过这个函数来返回这个变量, 这样可以做到线程安全。

android主要做了以下修改

他没有用_res把这个变量转换成函数res_get_state(), 这个函数会去监视一个prop(属性):net.changed, 这个prop的值是最后改变了值的dns服务器的地址,如果这个值改变了, 他就会去重新刷新一下他的dns服务器的缓存, 而且,android没有使用/etc/resolve.conf, 而是去动态的获取一个叫做 net.dnsN 的prop, (N是DNS服务器地址的序号), 通过这个来取得dns服务器的地址。

这就是为什么很多做android一直的人在gprs.ppp拨通了以后可以Ping到ip, 却不能解析域名的原因。

重新开业

发表于 2010-03-06 | 分类于 未分类

今天是一个特殊的日子,收到了亲爱的寄的川味香肠,开通了她和我的顶极域名,还去第一次玩了卡丁车。

所以决定今天把以前的老地盘重新开张,开始坚持写文章。
域名商是选择的 name.com, 要感谢云风的那篇文章。

About File system logging

发表于 2009-11-29 | 分类于 未分类

This is a note @MIT OCW 6.824 Lecture 7:

The main point of a log is make complex operations atomic.

I.e. operations that involve many individule writes. You want all writes or none, even if a crash in the middle.

A "transaction" is multi-write operation that should be atomic. The logging system needs to know which set of write from a transication.

Re-do with checkpoint:

Most logs work like this, e.g. FSD,
allows much faster recovery: ca use on-disk data
write-ahead rule:

delay flushing dirty block from in-memory data cache until corresponding commit recore is on disk

Check point rules:

all data writes before check point must be stable on disk checkpoint may not advance beyond first uncommitted Begin

Recovery:

for each block mentioned in the log
find the last xaction that wrote that block
if committed: re-do
if not committed: un-do

Why is logging fast:

group commit -- batched log writes.
could delay flushing log -- may lost committed transactions but at least you have a prefix.

Single seek to implement a transaction.
maybe less if no intervening disk activity, or group commit

Write-behind of data allows batched/schedules.
one data block may reflect many transactions, i.e. create many files in a directory.
don't have to be so careful since the log is the real infomation.

1…567…11
Jiejing Zhang

Jiejing Zhang

110 日志
11 分类
24 标签
© 2017 Jiejing Zhang
由 Hexo 强力驱动
主题 - NexT.Pisces