hu's profileBEST DAYS OF MY LIFEPhotosBlogLists Tools Help

hu

Location

BEST DAYS OF MY LIFE

DARE TO LOSE

香港每年7/1都游行

自从回归以后,每年7/1都有游行。
今天第一次听说...

wikipedia link: click here

招标公示

http://www.mof.gov.cn/mof/xinxi/zhongyangbiaoxun/zhongbiaogonggao/

里面的内容还删除,前几天刚发现这个地方的时候,里面有个大会堂洗手间装修招标的公示,三个洗手间要100多万,今天找就找不到了,还好,有个灯的还在:

受人民大会堂管理局委托,我中心对人民大会堂三楼中央大厅大花灯采购项目(招标编号为RC-G09012)进行了公开招标。现将招标结果公示如下:
中标人名称:东莞梵尔赛灯饰有限公司。
中标金额:2889800.00元。
集中采购机构:全国人大机关采购中心。
集中采购机构地址:北京市宣武区永定门内西街甲2号。
联系人:张鸿郭凯 电话:83102131 传真:83102131。
我们在此谨对参与本项目的各投标人表示感谢。
特此公告。

这也不便宜。还有好多公示里没有价格,是怎么回事?不给价格也叫公示?还有的公示里甚至连中标单位都不写...这公示什么啊。

I SAW EXCHANGE ACTIVESYNC ON HTC HERO!

Which mean Android supports activesync now? Great news to me.

真的无语了

http://www.tianya.cn/publicforum/content/free/1/1601558.shtml

源自天涯,为防止原贴被和谐,摘录如下:

6月18日央视《焦点访谈》
记者:通过谷歌中国能搜索出来的淫秽色情和低俗信息非常的丰富,不仅有交友、视频、还有文字等等,而且搜索起来非常方便,它还提供了这么一种功能,你只要输入一个词,甚至是一个字它就能给你提供若干种选项,更为夸张的是,即使你输入的这个词并不暧昧,但是它却能给你引导到低俗的内容上,不信我们来看一下:输入一个儿子,它下面缺出现了这样的一些选项“儿子母亲不正当关系”等等十个选项,而且这十个选项可以说都将引导你进入到那些低俗的内容,这样的结果应该说我们谁都没有想到。

Google的搜索引导词是根据近期搜索频率来分的,也就是说,引导词里会出现最近一段时间内搜索的次数较多的组合。Google Trends上就能查到流量比较大的情况下的搜索频率走势。

而更为先进的Google Insights for Search(http://www.google.com/insights/search/)里则详细地记录下了2004年至今各搜索组合的次数涨落,并且还可细分网页搜索、图片搜索、新闻搜索,和按不同国家与地域、不同时间段来进行检索。

在这几张“30天内统计数量”的表里我们可以看到,从6月10日起,“儿子与情人”和“儿子母亲不正当关系”两种搜索组合的搜索率直线上升,而之前的搜索量则几乎可以忽略不计。并且这些搜索近100%都是由北京的用户完成的。而且这些词条总共也就被搜索了十几二十来次。同样,在搜索频率上升排行中我们也可以得到印证,这两个条目在过去从来没有这么“火热”过。
  
巧合?

link1

link2

我错了,是我导致了google被封

我错了,我在google上阅读了大量关于绿坝和石首的反动材料;并通过google搜索了草泥马、天安门、土共等多个敏感词汇;我大量阅读并使用blogspot;我使用gmail、google docs、picasaweb等反动服务;我在生活中不遗余力地蛊惑周围不明真相的群众,向他们介绍从google上学来的歪理邪说。还好我们伟大英明的党及时发现了我的错误,并通过封锁google.com来对我进行挽救。因此连累了众多不明真相的群众,我错了,我对不起大家。

一个新发现的好网站

http://net.china.com.cn/

Snow Leopard is not that ready

I downloaded and installed Snow Leopard A380(WWDC version). It feels a little bit faster than Leopard. But lack of some features I wanted:

1. Exchange support. It may support Exchange 2007 only. I cannot get my corp's Exchange server 2003 setup.

2. Dock Expose. Demoed at WWDC, but not included in the version distributed in WWDC?

3. Cisco VPN. The new cisco VPN network connection cannot work. I have to use cisco's own vpn client again.

绿坝-花季护航-中国软件产业的丑恶

中国软件产业的问题有很多,最严重的大约有以下两点:

1. 抄袭开源软件

很多国内的公司的软件都公开抄袭开源软件,抄GPL的不开源,抄BSD的不保留License声明。抄了之后的软件直接去商用、去骗国家的项目。

2. 投标暗箱操作

比较低级和常见的操作方法是,通过事先的默契,影响招标的技术指标和商务要求,在其中放入有针对性的内容。之后影响招标专家组,控制招标结果。比较高级的手段就是搞定某个行业的政府组织,让某软件成为这个行业的强制性要求。

这里有一个非常完美的实例

Speed: JRuby 1.2.0 > Ruby 1.9.1 >> Ruby 1.8.7

Question No. 14 of Euler Project:

euler hu$ time jruby 014.rb
real    0m12.686s

euler hu$ time ruby1.9 014.rb
real    0m15.701s


euler hu$ time ruby 014.rb
real    1m14.751s

Uploading multiple large files to a Rails application

Abstract

This article solves 2 problems in Rails application development:

  1. Uploading multiple files into Rails app
  2. Uploading large files into Rails app

Backgrounds

What's the problem of uploading multiple files in Rails?

The tricky thing is how rails convert the names of form fields into the hash variable "params". Without properly naming, it will be very difficult to process uncertain number of files.

What makes rails cannot handle uploading of large files?

In the default rails implementation, it will read the whole file uploaded from the browser into memory, then write to disk. Which is very time consuming and inefficient. I'm not going into this as there is a very comprehensive blog on JEDI.

Solutions

To upload multiple files into rails, Brain has a nice post here. I just followed his steps with the following changes:

  1. Change the element name to "attachment[]" in the MultiSelection js function:
    this.addElement = function( element ) {
      if( element.tagName == 'INPUT' && element.type == 'file' ) {
        element.parentNode.id = 'attachments_container';
    //  element.name = 'attachment[file_' + (this.id++) + ']';
        element.name = 'attachment[]';
    ......
  2. Now we can process the attachments as array
    def process_file_uploads
      return if params[:attachment].nil?
      
      params[:attachment].each do |file|
        @attachment = Attachment.new( { "uploaded_data" => file } )
        @picture.attachments << @attachment
      end
    end
    

By reading JEDI's blog, I decide to go to nginx + upload module. Download source code of nginx and upload module, configure nginx with command:

./configure --add-module=../upload_module_dir

then make and install it.

nginx.conf as following

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    # back-end server
    upstream mongrel {
      server 127.0.0.1:3000;
    }
    server {
        listen       80;
        server_name  localhost;
        client_max_body_size 0; # don't limit the upload file size
        location /documents/upload { # use upload module on this URL
          upload_pass /;
          upload_store /tmp; # save uploaded files here
          upload_set_form_field "attachment[]name" "$upload_file_name";
          upload_set_form_field "attachment[]content_type" "$upload_content_type";
          upload_set_form_field "attachment[]path" "$upload_tmp_path";
          upload_store_access user:rw group:rw all:rw;

          # pass authenticity_token and all html form fields start with document to http://mongrel/documents/upload
          upload_pass_form_field "^authenticity_token$|^document.*"; 
        }
        
        location / {
          proxy_pass http://mongrel;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;
        }
    }
}

In the erb template:

<% form_for @document, :url=>{ :action => "upload" }, :html => { :multipart => true } do |f| %>
  <%= f.label :title %>
  <%= f.text_field :title %>
  <% fields_for(:attachment) do |a| %>
    <%= a.label :files %>
    <%= a.file_field :files %>
  <% end %>
  <script type="text/javascript">
    var multi_selector = new MultiSelector($('pending_files'));
    multi_selector.addElement($('attachment_files'));
  </script>
  <%= f.submit 'Create' %>
<% end %>

As we are using form_for helper, the generated field name will have 'document' prefix. So the upload_pass_form_field config in nginx.conf will pass all fields start with document to back-end. And the uploading multipart data will be processed by the nginx upload module, then create fields of attachment[]name, attachment[]content_type, attachment[]path for each file. The rails will process the request using DocumentController's upload method. The params is

{
  "attachment"=>[
    {"name"=>"Firefox_by_IQEye.jpg", "content_type"=>"image/jpeg", "path"=>"/tmp/0000370374"}, 
    {"name"=>"f616d49511f4a9d1.jpg", "content_type"=>"image/jpeg", "path"=>"/tmp/0000493833"}
  ], 
  "authenticity_token"=>"OQayTGSPwCjStPgYrYGnob4G8S1Z53qD9olwyL8TE0k=", 
  "document"=>{
    "author"=>"b", 
    "title"=>"a"
  }
}  

过去了

20周年,就这么过去了。

spaces.live.com和flicker.com又可以访问了。

Number of Divisors

http://en.wikipedia.org/wiki/Divisor_function

to calc number of divisors of X:

  1. found all prime factors of X and number of each factors: X = f1^a1 * f2^a2 * f3^a3 ……
  2. number of divisors = (a1 + 1) * (a2 + 1) * (a3 + 1) * …

product

Product (mathematics), the result of multiplying

Didn't know this before...

质数/素数的检验与生成

在做Project Euler的第4题,是关于质数的。

有以下事实很有趣:

1. 一个合数总是可以分解成若干个质数的乘积。很明显,也很容易证明。

2. 判断一个数X是质数,只要用X依次除小于SQRT(X)的质数,看是否可整除即可。如果你有一个生成过的质数序列的缓存,这里就可以用上了...

3. 判断一个数X不是质数,可首先检查它是不是某个质数的整数倍,这里同样可以用上缓存。

4. 纯数值计算,Ruby 1.9比Ruby 1.8至少快一倍

所以:

1. 要分解一个数,我们只需要尝试质数即可,所以我们需要一个从小到大的质数序列

2. 要生成一个质数序列,非常容易,只要保存一个质数由小到大的数组,这个数组中开始可以只有一个数字2,然后:

1) 取出数组中最大的数,作为要寻找的下一个素数X

2) 从已有的质数序列中取出所有小于SQRT(X)的数,用X依次除,只要除不尽,X就是素数,只要除尽,X就不是素数

3) 如果X是素数,将X加入数组

4) 如果X不是素数,将X加1,重复2)

无题

认识到失败并不是一件容易的事情,在大部分情况下,失败并没有明显的标志。

认识到了失败后,愿意承认失败更加不容易。承认失败意味着对自己努力的否定,意味着放弃。

但我必须得说,认识到失败并承认失败,不再为难自己,确实会让生活变得更容易。


通过Google Reader也无法阅读blogspot了?

我党真是英明伟大,以前wp和blogspot被封的时候,我通过google reader订阅的rss好歹能看一下,现在竟然连这都不行了。只要在google reader中一访问blogspot的rss,立即报错,顺便停止我访问google若干分钟。

伟大!万岁!

COMPLAIN !!!

新源里太堵了!东二环太堵了!朝内太堵了!太阳太亮了!车太多了!我为什么不 走四环呢!

时间差

“每条路每天早高峰都有一段空闲的时间”

比如东二环,我发现这段路的空闲大约在9:00左右,9:15之前。今天早上从东便门到东直门只花了不到10分钟的时间。

to love somebody

There’s a light
A certain kind of light
That never shone on me
I want my life to be
Lived with you
Lived with you

There’s a way
Everybody say
To do each an every little thing
But what does it bring
If i ain’t got you, ain’t got you

You don’t know what it’s like, baby
You don’t know what it’s like
To love somebody
To love somebody
The way i love you

In my brain
I see your face again
I know my frame of mind
You ain’t got to be so blind
I’m blind, so so so blind
I’m a man, can’t you see
What i am
I live and breathe for you
But what good does it do
If i ain’t got you, ain’t got you

hear it:

by Michael Bolton

by Bee Gees

by 林忆莲

最好听的应该是Ray LaMontagne的版本,youtube

手机屏幕打磨指南

手机屏幕有很多划痕?可用如下工具打磨之。

包括:600/800/1000/2000/3000/5000标号的砂纸各一张。镜面抛光液一管。

打磨方法:将砂纸剪成小块,蘸水打磨,打磨只向一个方向进行,不要来回,也不要交叉

视磨损程序,先用1000以下标号的砂纸打磨,去除主要的划痕,再用2000号的打磨,再用3000号,5000号,这样一路慢慢打磨下去,最后抹上抛光液,用软布打磨,即可成功。

过几天再买个打磨的小机器,用羊毛的打磨轮打一下试试,估计效果更佳。

moc -- command line music player

moc is a nice CLI based music player, which supports background server mode. It can be easily installed on Mac with:

$ sudo port install moc

A moc server can be easily startup by:

$ mocp -S *.mp3

$ mocp -p # start playing

$ mocp -x # exit the server

水木十年

刚才上水木的时候查了一下自己的信息,原来我是1999年注册的。到今年,在水木上竟然也十年了。

十年之前...十年之后...

What's the Point?

I'm not going to ask questions about meanings of life/work/blahblah... I'm going to quote some lines from Boston Legal.

> Denny Crane: Edwin Poole's problem is he doesn't like being Edwin Poole(Edwin is a named partner and a psycho). From time to time he'd look in the mirror and ask, "What's the point?" I never do that. Questions like that'll kill you.

> Alan Shore: Questions like, "What's the point?"

> Denny Crane: ...... What's the point? You don't ask -- that's the point. You gonna win, by the way? The world wants to know.

正常, 疯狂, 理想

你有理想吗?你的理想是什么?

你在做的事情是在实现你的理想吗?

我在日复一日从事着自己不喜欢的工作,拿着薪水用于生存,我被认为是一个正常人。如果我放弃这一切,去追求我心中的理想,我会被认为是疯狂。

其实生活总是在别处,人总是不满足。也许当我实现那个理想的时候,我还是会不喜欢,不满意。

如果我看透了这一切,走向纯精神领域的追求,相信解决一切烦恼的终极方案是戒而定,定而慧.....我一定会被看成是一个疯子。