by agate - Published: 2008-09-27 [9:07 上午] - Category: 软件使用
发现 AutoIt 真的很强大! 整天编程的我怎么就老是忽略这个好东西呢? 完整的 api , 完整的 ui 组件. 还可以生成 exe 可执行文件. 现学现用, 写了一个内存整理的脚本. 原理是使用微软的 empty.exe 内存清理工具.
; 整理前的内存使用量
$old_mem = MemGetStats()
; 列出所有进程
$list = ProcessList()
for $i = 1 to $list[0][0]
RunWait("empty.exe " & $list[$i][1], ".", @SW_HIDE)
next
; 整理后的内存使用量
$new_mem = MemGetStats()
; 气泡显示
TrayTip("内存整理完成", "使用量从 " & $old_mem[0] & "% 降低到 " & $new_mem[0] & "%" & @LF & "现在内存占用情况 " & ($new_mem[1] - $new_mem[2]) / 1000 & "MB/" & $new_mem[1] / 1000 & "MB", 5, 0)
Sleep(5000)
执行脚本时将 empty.exe 放在脚本同一目录下, 或放在 PATH 路径中. 效果如下:

by agate - Published: 2008-09-26 [11:52 上午] - Category: 软件使用
今天升级到 Firefox 3.0.2 版本, 结果发现所有的密码记录已经消失的无影无踪. 密码管理器中空空如也! 查阅 google 之后方知原来是 Firefox 3.0.2 将原先保存密码的 ASCII 编码转换到了 UTF-8 编码方式. 导致读的时候傻眼了, 以为密码持久文件中的东西是乱码... 于是乎就告知使用者 "嘿! 奶奶的, 你没有保存过密码!"
这个明显是设计脑残的结果. 没有考虑到升级的影响! 解决方案: 用你喜欢的文字编辑器打开 Firefox Profiles 下的 signons3.txt 文件. 另存问 UTF-8 编码的即可!
by agate - Published: 2008-09-24 [10:23 上午] - Category: 系统操作
This workaround will help you to remove the "_CFGetHostUUIDString: unable to determine UUID for host. Error: 35" error.
1.) BACKUP your /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
2.) Open /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
3.) ADD AFTER <string>Ethernet</string></dict> the following:
<dict>
<key>BSD Name</key>
<string>en3</string>
<key>IOBuiltin</key>
<false/>
<key>IOInterfaceType</key>
<integer>6</integer>
<key>IOInterfaceUnit</key>
<integer>3</integer>
<key>IOLocation</key>
<string></string>
<key>IOMACAddress</key>
<data>
ABbPoF5V
</data>
<key>IOPathMatch</key>
<string>IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/P0P3@1C,2/
IOPCI2PCIBridge/pci14e4,4311@0/AirPort_Brcm43xx/IO80211Interface</string>
<key>SCNetworkInterfaceType</key>
<string>IEEE80211</string>
</dict>
4.) IF you have more than 3 interfaces or there is an "en3" interface change it to "en4" or a higher number, don't forget to change this "<integer>3</integer>" to "<integer>4</integer>".
5.) You need to REBOOT
6.) If this work for you please tell me.
7.) If this workaround did not work please provide your system.log and your NetworkInterfaces.plist.
Why does this error happen?
Well at looking at the source code of the configd there is a plugin "InterfaceNamer" it seams the plugin will always skip interfaces
that are IOBuiltin = false. The "<key>IOBuiltin</key>" cannot be changed because the plugin will check and restore it on next boot.
But it does not check if wireless interfaces <key>SCNetworkInterfaceType</key><string>IEEE80211</string> are IOBuiltin.
Like I say this is only a workaround and there will be more need of testing.
from url: http://sneosx86.freeflux.net/blog/archive/2007/11/10/_cfgethostuuidstring-error-workaround-fix.html
by agate - Published: 2008-09-22 [8:44 上午] - Category: 系统操作
when you execute some app, you will get this error info like:
Dyld Error Message:
Library not loaded: /usr/lib/libssl.0.9.dylib
Referenced from: /Library/Frameworks/xxxxx
Reason: no suitable image found. Did find:
/usr/lib/libssl.0.9.dylib: mach-o, but wrong architecture
/usr/lib/libssl.0.9.dylib: mach-o, but wrong architecture
The easy solution to this is to backup you libcrypto.0.9.dylib, libssl0.9.dylib and copy over the libcrypto.0.9.7.dylib and libcrypto.0.9.7.dylib.
You can use Terminal.app to make these changes. It is in your Applications folder. (Make sure that you are only copying the part after the $)
$ cd /usr/lib
$ sudo cp libcrypto.0.9.dylib libcrypto.0.9.dylib.old
$ sudo cp libssl.0.9.dylib libssl.0.9.dylib.old
$ sudo ln -sf libcrypto.0.9.7.dylib libcrypto.0.9.dylib
$ sudo ln -sf libssl.0.9.7.dylib libssl.0.9.dylib
close your Terminal. done!
by agate - Published: 2008-09-19 [8:26 下午] - Category: 程序编码
每日 rails 每日发现圈子里天才多多! 对于天赋我深信不疑! 嘿嘿! 特别喜欢天才! 对天才有特殊的癖好! 比如恋天才癖啊~
废话一大堆, 切入正题! virtual attribute 是 rails 保存 model 中使用的一个技巧! 很实用, 很天才...(又来了) 有时候我们模型的属性设置是一个样, 但是我们表单设计又是另外一个样子.(好拗口) 打个比方: 一个 user 模型, 有 first_name, last_name 等属性; 对应表单只有一个 name 输入框(规矩是根据空格区分 first_name 和 last_name). 这个问题来了, 默认情况下 controller 的 create 或者 update 都是通过 params[:user] 来注入传入表单数据到模型实体的. 问题是 user 模型中并没有 name 属性, 同时 user 的 first_name 和 last_name 也未被赋值. 在这个时候 virtual attribute 就显示他的优势了! 见代码:
<!-- users/new.rhtml -->
<%= f.text_field :name %># models/user.rb
def name
[first_name, last_name].join(' ')
end
def name=(name)
split_names = name.split(' ', 2)
self.first_name = split_names.first
self.last_name = split_names.last
end
这样, 在保存或是修改 user 模型的时候就能正常工作了!(不需变动原有控制器哦!) 这就是 'skinny controller, fat model' 的好处. 这种用法十分聪明和实用, 在使用类似 make_resourceful 这种简化 controller 代码的插件的时候这种技巧就更显得重要了!
by agate - Published: 2008-09-18 [1:27 下午] - Category: 程序编码

在尝试 rails 开发的时候, 利用 rest 开发模式, 轻量化 controller, 并丰富 model 自身功能. 每一个 controller 遵循 "金七" 方法设计(可适当补充和删减). 这样就可以做出一个好的 rails 蛋糕啦!
(皮薄馅儿厚 skinny controller, fat model)
by agate - Published: 2008-09-17 [6:07 下午] - Category: 程序编码
在使用 acts_as_voteable 插件开发的过程中, 发现这个插件是服务于 rails1.2.x 的. 但是在 rails2.0+ 下执行某些方法的时候会出现如下错误.
ArgumentError: The :dependent option expects either :destroy, :delete_all, or :nullify (true)
解决方法是修改#{RAILS_ROOT}/vendor/plugins/acts_as_voteable/lib/acts_as_voteable.rb
替换 :dependent => :true
为
:dependent => :nullify
就OK了. 这种方法同样适用于 acts_as_commentable 等此类插件. 因为作者只不过简单重写了一下.
注意的是, 这些插件默认情况下都是真对 MYSQL 编写的. 在 SQLite 下要注意需要修改插件 lib 目录下主文件中的 SQL 语句, 把 FALSE 替换为 '0', TRUE 替换为 't'.
by agate - Published: 2008-09-17 [5:39 下午] - Category: 数据库
从 MySQL 迁移到 SQLite 发现了很多原有程序中出现错误…… 这个问题我也在 <<Agile Web Development With Rails>> 书中的 Depot 工程里体会到了 now 的问题, 在这个文章中作为这些小区别的一个累计.
1. 日期类
SQLite包含了如下时间/日期函数:
datetime().......................产生日期和时间
date()..............................产生日期
time()..............................产生时间
strftime()........................对以上三个函数产生的日期和时间进行格式化
(以上函数都可加参数)
2. Boolean 类型
普通的 SQL 语句都可以直接使用 FALSE 和 TRUE 关键字执行. 但是 SQLite 必须使用 't' 和 '0' (注意必须小写)
[ 不断更新中... ]
by agate - Published: 2008-09-16 [11:01 上午] - Category: 开发环境
首先声明, 我爱 linux 我爱开源, 但是我舍弃不下微软视窗下的众多好应用, 我丢不下我的 qq 离不开我的搜狗... 而且现在我又多了一个牵挂 --- Intype 这个出色的文本编辑器. 一边享受网络生活, 一边编程何乐不为!
但是问题是在 windows 下 ruby 解释器的工作效率实在是太低了! 简简单单的一个命令要经过等待响应/执行/结束三个过程, 偏偏是那个等待响应的时间大大地超过执行的时间... 怀念 linux 下"唰"一下就好的感觉了!
折腾了半天现在我使用 vmware + ubuntu-server + PuTTY 的方式进行 ROR 开发. 安装和使用 vmware 在这里就不多说了, 主要是提及 ubuntu-server 这个系统, 提供了 LAMP 的服务整合, 还有 SSH 的接入, samba 的文件共享服务. PuTTY 是一个 Linux 的命令行接入客户端, 在 Windows 下我就主要靠这个来和 Linux 进行交互(说白了就是一个终端, 只不过是远程的)
现在秀一下我的桌面布局:

具体的布局框架是:

做 ROR 我喜欢大屏幕! 嘿嘿~
by agate - Published: 2008-09-14 [11:00 下午] - Category: 软件使用
自从升级到 Firefox3 后, 已经离开迅雷 Firefox 插件好多个月了. 但是总是不爽! 并不是所有的链接都可以简简单单拖到浮动窗口中了事的~ 现在一大堆反盗链的很讨厌, 老是给出错误的东西, 必须到其专属页面才能下载. 我火大了! 开始搜寻解决之道, 嘿~ 被我给找到了!
在 ${迅雷目录}\Components\ExplorerHelper\ 目录下有一个叫做 thunder.xpi 的文件, 这个就是我们的迅雷 Firefox 插件了, 但是由于 Firefox3 的安全限制不能使用! 所以, 动手修改其并让其兼容 Firefox3.
第一步, 重命名 thunder.xpi 为 thunder.zip. 提取其中的 install.rdf 文件.
第二步, 修改:
<em:updateURL>https://addons.mozilla.org</em:updateURL>
黄色部分修改部分
第三步(可选), 修改:
<em:version>3.9</em:version>
只是为了区分原来的版本拉!
第四步, 将修改好的 install.rdf 替换原来 thunder.zip 中的文件, 最后将 thunder.zip 重命名为 thunder.xpi
我们的修改就完工了, 最后在 Firefox 运行的时候将 thunder.xpi 拖到界面中安装/重启即可使用!
(注: 似乎用下来没什么兼容性问题!)