mysql,Linux,HighPerformance,ruby on Rails

2009年4月19日星期日

Scrubyt抓取非utf-8的代码Sample

如下参考:这里


#!/usr/bin/ruby -Ku

# source must be written in UTF-8
$KCODE = 'u'

require 'rubygems'
require 'iconv'

# Patching Mechanize...
require 'mechanize'

# Perform iconv() before Mechanize parses the page
class IConvParser < WWW::Mechanize::Page
def initialize(uri = nil, response = nil, body = nil, code = nil)
new_body = Iconv.conv("UTF-8//IGNORE", "GB2312//IGNORE", body)
super(uri, response, new_body, code)
end
end

# Set IConvParser as default HTML parser, you don't have to
# run iconv() to each page manually.
class WWW::Mechanize::PluggableParser
def initialize
@parsers = { CONTENT_TYPES[:html] => IConvParser }
@default = File
end
end

# Scrubyt::FetchAction initializes its @@agent as PluggableParser.new
# at class context, so we manually require 'scrubyt'
# AFTER the above patch was installed.
require 'scrubyt'

# Now definition is quite simple
baidu_data = Scrubyt::Extractor.define do
fetch "http://www.baidu.com/"

fill_textfield 'wd',"ruby"
submit
result "Ruby_百度百科"
end

puts baidu_data.to_xml




2009年4月7日星期二

学习新语言的方法总结---ruby版




第一,看一遍语法,快速,需要2小时左右。
第二,找到应用点,比如rails,直接上手作一个小项目。按书上的来写的话,好像就是一个商城。
第三,解决实际问题,分析,写代码,重构
第四,记笔记,share!

Done!

2009年4月2日星期四

uninstall installed 64 bit MySQL dmg on mac



uninstall installed 64 bit MySQL dmg as follows ( There is no good way to uninstall MySQL from Mac other than below)
    * sudo rm /usr/local/mysql
* sudo rm -rf /usr/local/mysql*
* sudo rm -rf /Library/StartupItems/MySQLCOM
* sudo rm -rf /Library/PreferencePanes/My*
* edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
* sudo rm -rf /Library/Receipts/mysql*
* sudo rm -rf /Library/Receipts/MySQL*

ref:
http://akrabat.com/2008/09/11/uninstalling-mysql-on-mac-os-x-leopard/

勿在浮沙筑高台-要诚实的面对生活,社会,职场

先看一下这里的广告贴,有几段我感觉很经典的场景,希望点点给一些同学打打气。
一段:“一年多以前,我还沉浸在大学生毕业即失业的迷惘境地里...”...."现在,我已经在世界500强之一的Motorola公司里上班"
分析:每个人的情况是不一样的,别人行,不一定代表你就行。所以如果你根本对编程没兴趣,看看有没有其它行业机会。

如何走出这个谜局:问题是你,不是工作。钱不是唯一的标准,你要看能不能给你带来事业,这个很重要。不要为了眼前的利益去放弃未来。

没有神化的技术和人。你要想成功,就一定要付出,这并不是以钱为标准。有的朋友不服气 ,为什么我付出那么多,就是没有同伴拿的多呢。问题是复杂的,也是简单的。仅仅是因为你还没有到时候而以。你要看明白自已的条件和优势,去争取而不是去投机。

你说你喜欢技术,因为他让你显的很牛,是的。很多人喜欢这种优越,但如果你想把它作为事业,或者你现在开始算起,作为事业,你就要放下所有的一切,对待每一件事。去做好它们。当你把所有应该作的事情作好的情况下,再去为你这个技术事业奉献十年,二十年的话,你就是专家级的人物了,你的优越会让你知道什么是成功。这不仅仅只有企业家才有。