Current language: 中文 (简体)
2010-03-10 19:55:32 · Author: 五帝 · Tagged with: Hack, Computer Software, Computer Hardware | Comments
EPC 刚买回来时就发现硬盘有噪声了,知道是磁头归位导致的。但机子带的硬盘是希捷的,查了一下貌似没办法从硬件上设置 APM 值,就搞来了 Windows 版的 hdparm 凑合用着。
但用 hdparm 有个问题,就是从休眠状态恢复过来时,只能手动执行设置 APM 参数,比较麻烦。这两天想倒腾一下 EPC 上的系统,顺便也把这个问题解决了。这次搜索 Seagate APM,发现了 quietHDD 这个软件,可以在系统启动后和从休眠、待机状态中恢复后自动设置 APM 和 AAM 值。用着感觉很不错,问题就算是解决了。
PS,我的 Asus WL-500gP 路由器外接的是一块从笔记本中换下来的东芝硬盘,可能也是默认的 APM 值低,总是咔咔响。我的解决办法是写了一个 access-hdd 丢到 /opt/bin 中,并使它在系统初始化时运行,内容如下:
但用 hdparm 有个问题,就是从休眠状态恢复过来时,只能手动执行设置 APM 参数,比较麻烦。这两天想倒腾一下 EPC 上的系统,顺便也把这个问题解决了。这次搜索 Seagate APM,发现了 quietHDD 这个软件,可以在系统启动后和从休眠、待机状态中恢复后自动设置 APM 和 AAM 值。用着感觉很不错,问题就算是解决了。
PS,我的 Asus WL-500gP 路由器外接的是一块从笔记本中换下来的东芝硬盘,可能也是默认的 APM 值低,总是咔咔响。我的解决办法是写了一个 access-hdd 丢到 /opt/bin 中,并使它在系统初始化时运行,内容如下:
- #!/bin/sh
- while true
- do
- ls /opt/tmp/empty > /dev/null
- sleep 5
- done
Current language: 中文 (简体)
Current language: 中文 (简体)
I remember that I tested the forwarding email address after I got a CVS account at php.net, and it worked fine. But today when I test it again, I found the mails sending from 126.com was rejected by php.net for the reason "4.7.1 our policy says no mail from your domain". And then I sent two mails from hotmail and yahoo, all succeeded.
Maybe the spam mails from domain 126.com are a little much. But I still intend to use this forwarding email address for the programs such as PEAR packages.
Maybe the spam mails from domain 126.com are a little much. But I still intend to use this forwarding email address for the programs such as PEAR packages.
首先,我得说一下我是 Linux 新手,这个解决方法只是能用而已。
gnome-power-manager 没低电量提示的问题困扰了我将近半个月的时间,期间曾按网上大多数人提供的方法修改 gconf 配置中的 /apps/gnome-power-manager/general/use_time_for_policy 的值为 false,让 gnome-power-manager 使用电量百分比作为判断依据,但没有效果。
后来仔细得浏览了一下这个页面,发现 Joakim Andersson 所写的回复,非常明确得指出了问题所在。但继续往后浏览,发现有管理者说这个问题已于去年9月修复。而这个页面讨论的似乎是 Ubuntu 库里的版本,经过检验发现我这 Arch Linux 里装的 gnome-power-manager 虽然是最新的 2.24.4 版,但是这个问题依然没有解决。
运行 gconf-editor,修改 /apps/gnome-power-manager/general/debug 的值为 true,开启额外的调试信息输出。执行
$ gnome-power-manager --verbose
观察其详细信息,会发现当电量百分比低于设定值时,会有一句
profile is not accurate. Not doing policy action
这就是 bugs 反应页面里提到的那个原因。
到 gnome 的 ftp 里下载一份 2.24.4 版本的 gnome-power-manager,解压缩。经过搜索,发现上面提到的那个除错信息在 src/gpm-cell-array.c 的 gpm_cell_array_emit_system_action() 函数内
- static gboolean
- gpm_cell_array_emit_system_action (GpmCellArray *cell_array,
- GpmWarningsState warnings_state)
- {
- gfloat accuracy;
- GpmCellUnit *unit;
- g_return_val_if_fail (GPM_IS_CELL_ARRAY (cell_array), FALSE);
- /* do we trust the profile enough to make a decision? */
- unit = &(cell_array->priv->unit);
- if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY) {
- accuracy = gpm_profile_get_accuracy_average (cell_array->priv->profile,
- unit->is_discharging);
- if (accuracy < GPM_PROFILE_GOOD_TRUST) {
- egg_debug ("profile is not accurate. Not doing policy action");
- return FALSE;
- }
- }
- /* we are not primary, or we are primary with a trusted profile */
- if (warnings_state == GPM_WARNINGS_ACTION) {
- egg_debug ("** EMIT: charge-action");
- g_signal_emit (cell_array, signals [CHARGE_ACTION], 0, unit->percentage);
- } else if (warnings_state == GPM_WARNINGS_CRITICAL) {
- egg_debug ("** EMIT: charge-critical");
- g_signal_emit (cell_array, signals [CHARGE_CRITICAL], 0, unit->percentage);
- } else if (warnings_state == GPM_WARNINGS_LOW) {
- egg_debug ("** EMIT: charge-low");
- g_signal_emit (cell_array, signals [CHARGE_LOW], 0, unit->percentage);
- }
- return TRUE;
- }
而经过搜索 CHARGE_LOW,发现似乎低电量的信号只能由这个函数发出,但很明显当 accuracy < GPM_PROFILE_GOOD_TRUST 时,就直接 return FALSE 了,所以不管 use_time_for_policy 是 true 还是 false,只要 accuracy 的值不够高,低电量提示就不可能出现。知道了这些,下面的工作就好办了,把涉及到 profile 准确度的几行注释掉,同时保证 /apps/gnome-power-manager/general/use_time_for_policy 的值为 false,程序就能正常工作了。
将定义 accuracy 变量的语句和为 unit 赋值的语句下方的 if 语句都注释掉
- static gboolean
- gpm_cell_array_emit_system_action (GpmCellArray *cell_array,
- GpmWarningsState warnings_state)
- {
- // gfloat accuracy;
- GpmCellUnit *unit;
- g_return_val_if_fail (GPM_IS_CELL_ARRAY (cell_array), FALSE);
- /* do we trust the profile enough to make a decision? */
- unit = &(cell_array->priv->unit);
- /*
- if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY) {
- accuracy = gpm_profile_get_accuracy_average (cell_array->priv->profile,
- unit->is_discharging);
- if (accuracy < GPM_PROFILE_GOOD_TRUST) {
- egg_debug ("profile is not accurate. Not doing policy action");
- return FALSE;
- }
- }
- */
然后编译安装。经过测试,低电量提示可以正常显示了。
参考:
1. Bug #135548 in gnome-power-manager...
2. Brian Jones - Re: Autoconf problems?
3. Charles Wilson - Re: 'can not find install-sh' when running configure
4. Re: difficulties with gnome-doc-utils.make
5. automake: 7.3.9.1 required file `./ltmain.sh' not found
6. Automake(1) - 一蓑烟雨任平生 Le blogspot de Leizhige - CSDNBlog
Current language: 中文 (简体)
2009-01-31 05:32:06 · Author: 五帝 · Tagged with: Computer Hardware | Comments
去年 8 月买来 Asus WL-500gP v2 后,刷 oleg 固件就没无线信号,用官方的就有。在网上各处都问了一下,没有解决办法,因为基本没有遇到这个问题的。那时电脑还比较少,可以不用无线,就用了一学期 oleg 固件,来做下载。但现在电脑多了,就必须得开无线了。
昨天把 Eee PC 上的系统也配置得差不多了,考虑将来移动用的话 Subversion 版本库还是有个统一的地存放比较好,就又想起来这个路由器了。随便去 oleg 首页看了一下,还是去年 3 月的。想去论坛看看有没有什么别的消息,居然看到了一帖 New oleg firmware version,仔细看了看,原来在 Google Code 上有 oleg firmware 的项目,而且更新得比较勤快。下载后刷上,无线信号出来了~~~
昨天把 Eee PC 上的系统也配置得差不多了,考虑将来移动用的话 Subversion 版本库还是有个统一的地存放比较好,就又想起来这个路由器了。随便去 oleg 首页看了一下,还是去年 3 月的。想去论坛看看有没有什么别的消息,居然看到了一帖 New oleg firmware version,仔细看了看,原来在 Google Code 上有 oleg firmware 的项目,而且更新得比较勤快。下载后刷上,无线信号出来了~~~
Current language: 中文 (简体)
今天凌晨比较仔细的研究了一下 HP LaserJet 3052 一体机的扫描。以前就发现了扫描后再打印,比直接复印出来的东西质量差很多,主要是背景色不是纯白色的,字比较模糊。
这个型号的一体机配套的软件有个位于开始菜单中的扫描程序 (hppscan3.exe),使用很简便,扫描时颜色、分辨率、纸张尺寸以及输出文件的质量都可设置。但经过试验发现这个程序最后的图像处理部分非常弱,生成的图像都不干净 (字迹锐利度不够,有杂点)。
用 IrfanView 把这个机器选为 TWAIN 源扫描,默认会蹦出 HP 扫描 (hpqscnvw.exe) 这个程序进行扫描图像的预览和处理。处理时发现只要把中间色拖到 -100 (这块只考虑文档的灰度扫描),有了加深的效果,再打印就比较接近直接复印的了。
2012-03-17 添加:
今天看站点统计信息发现,这一个多月以来有很多搜“hp扫描软件”找到这个页面的,觉得有必要添加一些内容。
我现在是在虚拟的 Xubuntu 系统中,通过 Xsane 来进行扫描的,设置的 Gamma 值、亮度和对比度看起来都是直接影响扫描的,而不是扫描之后再处理的。
扫描灰度和彩色文件效果都很好,灰度扫描对应的参数是 0.3, 16, 0,彩色扫描对应的是 0.5, 18, 0。

这个型号的一体机配套的软件有个位于开始菜单中的扫描程序 (hppscan3.exe),使用很简便,扫描时颜色、分辨率、纸张尺寸以及输出文件的质量都可设置。但经过试验发现这个程序最后的图像处理部分非常弱,生成的图像都不干净 (字迹锐利度不够,有杂点)。
用 IrfanView 把这个机器选为 TWAIN 源扫描,默认会蹦出 HP 扫描 (hpqscnvw.exe) 这个程序进行扫描图像的预览和处理。处理时发现只要把中间色拖到 -100 (这块只考虑文档的灰度扫描),有了加深的效果,再打印就比较接近直接复印的了。
2012-03-17 添加:
今天看站点统计信息发现,这一个多月以来有很多搜“hp扫描软件”找到这个页面的,觉得有必要添加一些内容。
我现在是在虚拟的 Xubuntu 系统中,通过 Xsane 来进行扫描的,设置的 Gamma 值、亮度和对比度看起来都是直接影响扫描的,而不是扫描之后再处理的。
扫描灰度和彩色文件效果都很好,灰度扫描对应的参数是 0.3, 16, 0,彩色扫描对应的是 0.5, 18, 0。
Current language: 中文 (简体)
In November the last year, I received an email which informed me that the encryption result of my Crypt_XXTEA package differs from some other implementations. And I made a reply to explain the reason.
XXTEA is a block cipher which requires the block size is at least two words, i.e. 32 bits. If the length of string is not multiples of 4, the last block must be fill up to 32 bits by some junk data. Thus the decrypted string will have the junk data at its end too. To solve this problem, the initial version of Crypt_XXTEA appends the length of string to the end of the converted long integer array, which can be used to cut the decrypted string to get the correct result.
Rencently, considered that this default behavior may confuse the user, I made some modifications. In the version of 0.9.0, users can handle the converting between string and long integer array with their own functions.
Link: http://pear.php.net/package/Crypt_XXTEA
XXTEA is a block cipher which requires the block size is at least two words, i.e. 32 bits. If the length of string is not multiples of 4, the last block must be fill up to 32 bits by some junk data. Thus the decrypted string will have the junk data at its end too. To solve this problem, the initial version of Crypt_XXTEA appends the length of string to the end of the converted long integer array, which can be used to cut the decrypted string to get the correct result.
Rencently, considered that this default behavior may confuse the user, I made some modifications. In the version of 0.9.0, users can handle the converting between string and long integer array with their own functions.
Link: http://pear.php.net/package/Crypt_XXTEA
2007-03-17 21:35:00 · Author: 五帝 · Tagged with: Computer Software | Comments
Becky! 用了近 3 年了。但为了将来用 Linux 做准备,上次部分硬盘数据(包括邮件)丢失后,想用 Thunderbird 作邮件客户端。
用了一段时间 Thunderbird,发现了很多问题(和 Becky! 比较)。最不能忍受的就是附件无法单独存储,而是邮件内容存放到一起,编辑或查看带有附件的邮件时速度十分缓慢。剩下的就是整体上功能相比 Becky! 弱很多。现在感觉 Thunderbird 和 Becky! 相比优点主要是它的 Webmail 插件收发 Hotmail 邮件比 Becky! 里的 Hotmail 插件好很多,Enigmail 也比 Becky! 里那个 PGP 插件做得好。
用了一段时间 Thunderbird,发现了很多问题(和 Becky! 比较)。最不能忍受的就是附件无法单独存储,而是邮件内容存放到一起,编辑或查看带有附件的邮件时速度十分缓慢。剩下的就是整体上功能相比 Becky! 弱很多。现在感觉 Thunderbird 和 Becky! 相比优点主要是它的 Webmail 插件收发 Hotmail 邮件比 Becky! 里的 Hotmail 插件好很多,Enigmail 也比 Becky! 里那个 PGP 插件做得好。
Current language: 中文 (简体)
- public static class TextFileReader
- {
- public static string ReadFile(string path)
- {
- FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read,
- FileShare.Read, 8192, FileOptions.SequentialScan);
- return ReadStream(stream);
- }
- public static string ReadStream(Stream stream)
- {
- byte[] bytes = new byte[stream.Length];
- long length = (stream.Length > 8192) ? (long)8192 : stream.Length;
- byte first;
- long pos = 0;
- bool is_utf8 = true;
- while (pos < length)
- {
- first = bytes[pos++] = (byte)stream.ReadByte();
- if (first < 192)
- {
- }
- else if (first < 224)
- {
- if ((length - pos > 1) &&
- (bytes[pos++] = (byte)stream.ReadByte()) < 128)
- {
- is_utf8 = false;
- break;
- }
- }
- else if (first < 240)
- {
- if ((length - pos > 2) &&
- !((bytes[pos++] = (byte)stream.ReadByte()) > 127
- && (bytes[pos++] = (byte)stream.ReadByte()) > 127))
- {
- is_utf8 = false;
- break;
- }
- }
- else
- {
- if ((length - pos > 3) &&
- !((bytes[pos++] = (byte)stream.ReadByte()) > 127
- && (bytes[pos++] = (byte)stream.ReadByte()) > 127
- && (bytes[pos++] = (byte)stream.ReadByte()) > 127))
- {
- is_utf8 = false;
- break;
- }
- }
- }
- if (pos < stream.Length)
- {
- stream.Read(bytes, (int)pos, (int)(stream.Length - pos));
- }
- if (is_utf8)
- {
- return Encoding.UTF8.GetString(bytes);
- }
- else
- {
- return Encoding.Default.GetString(bytes);
- }
- }
- }