Gecko Reflow

Jan 发表于 2008-05-30 11:27:58

关键词(Tag): gecko reflow
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

Quick change directory in urxvt - with QuickJump

Jan 发表于 2008-05-23 16:51:50

http://code.google.com/p/allruby/wiki/QuickJump

First download the script from here. Save it to somewhere on your local machine.

add these lines to your .zshrc (or .bashrc etc.):

alias jump="$YOUR-QUICKJUMP-SCRIPT-PATH/quickjump.rb&& source /tmp/quickjump"
alias add_quickjump_dir='echo $PWD >> ~/.quickjumprc' # note use single quote here

add this line to your .Xdefaults: (for urxvt user)

URxvt.keysym.M-j: jump \n
URxvt.keysym.M-a: add_quickjump_dir \n

Then try to press alt and j in your urxvt :)

See a better formatted document here.

关键词(Tag): urxvt directory zsh
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

A better way of doing daily task in Rails

Jan 发表于 2008-05-23 14:49:45

Instead of write your code in lib/xxx.rb and add sth. like script/runner into crontab:

15 2 * * * /usr/local/bin/rake -f /var/www/site/Rakefile do:something
RAILS_ENV=production

#and in lib/tasks/something.rake:

namespace :do do
  desc "does something"
  task :something => :environment do
    #<code moved from the action in your controller to here>
  end
end

From Here.
关键词(Tag): crontab rails task
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

rand() in PHP and Ruby

Jan 发表于 2008-05-21 14:43:16

See the original post I read here: http://www.boallen.com/random-numbers.html
And the discussion here: http://reddit.com/r/programming/info/6k4gz/comments

It's interesting that PHP on windows has such a fake random function - yeah, I know, no body is true random, but this one is too far away... Guys on reddit says rand() use OS provide rand function buy mt_rand() use PHP's own implementation. It's really a big securiy hole.

And just for fun I write the data visualization code for ruby rand(): (Use RMagick)
require 'rubygems'
require 'RMagick'

include Magick
SIZE=512

img = Image.new SIZE, SIZE
d = Draw.new
d.fill 'black'
1.upto(SIZE) do |x|
  1.upto(SIZE) do |y|
    d.point(x, y) if rand > 0.5
  end
end
d.draw img
img.write 'random.png'
exit

You can see the output:



And here's the output from PHP:

关键词(Tag): ruby windows php rand
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

My top used commands ..

Jan 发表于 2008-05-21 09:51:47

09:50:~$ cat ~/.zsh/history | awk '{a[$1]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head -n 20                                     
784 ls
544 cd
460 svn
316 v
249 sudo
199 git
162 darcs
138 rm
91 exit
88 rake
54 cp
52 cap
49 ssh
49 evince
48 fg
45 script/server&
43 sup
34 ps
33 tail
33 pacman

# v is my alias to vim
关键词(Tag): linux commands
阅读3832次 评论1条 个人主页 扔小纸条 文件夹: Linux
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

CCTV

Jan 发表于 2008-05-16 11:17:08

关键词(Tag): cctv earthquake
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

谷歌去死吧

Jan 发表于 2008-05-16 09:11:01

整天就知道舔美国主子的屁股

地震几天了?今天换上了个庆祝发明激光的logo。 google.com都没庆祝你们急着庆祝什么?

一群王八蛋


关键词(Tag): google cn
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

Sun adds support for Amazon Web services, targets start-ups

Jan 发表于 2008-05-14 18:13:31

"That's because until now, you risked losing data in your database if your instance of EC2 crashed. Now Sun will give you a way to save that data and even a customer service number to call, when you think all is lost and you\u2019re about to jump off the balcony."

I'm curious how to achieve this ...

http://venturebeat.com/2008/05/04/sun-offers-support-for-amazon-web-services-aims-at-start-ups/
关键词(Tag): sun mysql support ec2
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

Polymorphic Association

Jan 发表于 2008-05-13 16:12:00

"The polymorphic association, on the other hand, while it bears some resemblance to the regular polymorphic union of a class hierarchy, its not really the same since you're only dealing with a particular association to a single target class from any number of source classes, source classes which don't have anything else to do with each other; i.e. they aren't in any particular inheritance relationship and probably are all persisted in completely different tables. In this way, the polymorphic association has a lot less to do with object inheritance and a lot more to do with aspect oriented programming (AOP); a particular concept needs to be applied to a divergent set of entities which otherwise are not directly related. Such a concept is referred to as a cross cutting concern, such as, all the entities in your domain need to support a history log of all changes to a common logging table. In the AR example, an Order and a User object are illustrated to both require links to an Address object."

http://techspot.zzzeek.org/?p=13
关键词(Tag): rails association polymorphic
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

一方有难,八方支援(捐款捐物渠道)

Jan 发表于 2008-05-13 14:50:56

发信人: Penhui (2007), 信区: Quake5.12
标  题: ★一方有难,八方支援(捐款捐物渠道)★
发信站: 水木社区 (Tue May 13 01:26:17 2008), 站内

额外提醒:小额金额推荐使用短信捐款。

 建议渠道1:中国红十字会总会救灾账号和方式

  银行汇款
 开户单位:中国红十字会总会
 人民币
      开户行:中国工商银行北京分行东四南支行
  账  号:0200001009014413252
 外币
      开户行:中信银行酒仙桥支行
  账  号:7112111482600000209

  邮局汇款
    中国红十字会总会
 地址:北京市东城区北新桥三条8号
 邮编:100007

  网上捐款
    登陆中国红十字会总会网站:www.redcross.org.cn (访问人数过多可能导致崩溃)
    点击捐款热线栏目进行在线捐款。

 (通过银行、邮局和网上捐款在捐款时请注明捐款人姓名、通信地址、捐款意
     向如:四川地震捐款等信息,以便邮寄捐赠收据和感谢信)

  短信捐款
    中国移动、中国联通手机用户以及中国电信、中国网通小灵通用户均可编辑
    短信1或2,发送至1069999301,即向"红十字救援行动"捐款1元钱或2元钱。

 建议渠道2:中国红十字基金会

  邮局汇款
 地址: 北京市东城区东单北大街干面胡同53号
 邮编:100010

  银行汇款
 户名: 中国红十字基金会
 人民币
      开户银行1: 中国银行北京分行
  账号: 800100921908091001
  开户银行2:中国工商银行北京东四南支行
      账号:0200001019014483874
  开户银行3:中国建设银行北京朝内大街支行
  账号:11001070300059000427
    外币
      开户银行:中国银行
      账号: 800100086608091014

 建议渠道3:中国扶贫基金会"我们心在一起"--汶川地震紧急救援行动

 捐赠标准
  类别       价值           备注
  棉被       100元
  粮食       300元     大米、方便面、水等
  食用油     50元           5升
  执行费用   50元    用于救灾物资仓储、运输、发放等
  总计       500元   可以帮助灾民度过灾后一个月的生存危险期

 捐赠方式

  银行汇款
    开户单位:中国扶贫基金会
    开户行:中国银行北京科技会展中心支行
    账号:8145-11681908091001 (捐款请注明"汶川地震救援")

  邮局汇款
    地址:北京市海淀区双榆树西里36号南楼五层
    邮编:100086(捐款请注明"汶川地震救援")

      现场捐赠
    办公地址 北京市海淀区双榆树西里36号南楼五层
      咨询热线:010-62655199(8:30-21:00)
关键词(Tag): earthquake 512
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

地震了

Jan 发表于 2008-05-12 16:56:35

正在办公室happy coding,忽然头有点儿晕,身子骨发颤,心想真好玩,难不成是癫痫发作的预兆?

一转念想自己不是癫痫病人,然后发现显示器在晃,把腿抬起腿在晃,整个椅子都在晃,站起来终于发现原来是地在晃。。。顿时寒了一下,抓起钥匙冲了出去。本来想走楼梯,又怕走楼梯速度太慢走到一半被震了就不好玩了(谁让我在19楼。。。),于是等电梯,然后发现这果然是个非常失败的决定,电梯几乎在每一层都停一下,然后呼啦上来一堆人。。。如果真的地震我肯定挂了。电梯里面晃的很厉害。

还好老天保佑一坨人摇摇晃晃到了一楼,心稍安。过了一会儿有人说北京地震了,心想完了,死党不是在北京吗?赶忙打个电话过去,发现是假消息。待了一会儿好像没事了,回家先。。。 上网才知道四川地震了,老天保佑,大家平安。

对本次地震的反应,网易比新浪快多了。可惜网易的服务器不行啊,评论4页的时候服务器就挂了,我再也刷新不开。新浪虽然后发然而先至,瞬间评论超过50页,网页打开依旧流畅。新浪在我心中形象瞬间高大了许多~,新浪能成为国内新闻第一大站不是吹的。难道是nginx+memcache的功劳?网易不知道用的什么服务器,apache? 

后来发现CnBeta的报道似乎最早而且很全面,比网易新浪枯燥的几个字好许多。Web2.0的胜利?

国家地震局的网页打不开,邮件列表里面有朋友贴了美国地震局的报告,心里无限悲凉,别提向外输出价值观了,什么时候中国能向外输出地震报告了,也算是真正崛起了。
关键词(Tag): earthquake
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

Moto with one wheel

Jan 发表于 2008-05-08 20:29:34

关键词(Tag): moto
收藏: QQ书签 del.icio.us 订阅: Google 抓虾