123
 123

Sun 01 June, 2008

Click here to bookmark this link.Channel Image05:23 Kernel#maybe etc with Perce...» Projectionist

Kernel#maybe etc with Percentage::Chance

class Percentage def chance Chance.new(self) end class Chance attr_reader :odds, :happens alias :happens? :happens def initialize(percent) @odds = percent.amount @happens = @odds > Kernel.rand(100) end def of(&block) yield if happens? end end end module Kernel def maybe(percent = 50.percent, &block) if block_given? percent.chance.of &block else percent.chance.happens? end end def probably(&block) 80.percent.chance.of &block end def rarely(&block) 20.percent.chance.of &block end end

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Sat 31 May, 2008

Click here to bookmark this link.Channel Image12:55 Twitter Updates for 2008-05-30» halostatue
I’m thinking a short little round of Mario Kart Wii and then bed. # MarioKart # @schwa You underestimate the power of the block-side. Join me and we can rule the galaxy… # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:54 Ruby网络框架:Merb框架视频教程开播!» 天天红玉世界
Merb框架视频教程开播!
  • 说明
    • Merb框架 是一个正在崛起的类似于Rails的Ruby网络框架。以今天形势看,在未来,就Ruby网络框架领域而言,只有该框架可以与Rails抗衡。在这个网站上还有该框架的大量基础教材。

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:09 Desert Code Camp Tomorrow» James Britt - Code, Content, Caffiene

Don’t forget: Desert Code Camp tomorrow, Saturday May 31.

Logan will be leading several Ruby talks, with topics covering basic Ruby, JRuby, and building kick-ass GUI apps with Monkeybars.

I’ll be there, too, lending a hand and grooving to the geek vibe.

If you’re in or around Phoenix, don’t miss this.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image08:22 致敬!5.12地震中最伟大的中国母亲» 天天红玉世界
母亲用身体护住婴儿 手机留下感人遗言
亲爱的宝贝 如果你能活着 请你一定要记住我爱你!


妈妈:
  孩子,快抓住我的手
  孩子,快
  快抓紧妈妈的手
  去天堂的路 太黑了
  妈妈怕你 碰了头
  快 抓紧妈妈的手 让妈妈陪你走

孩子:
  妈妈 我怕
  天堂的路 太黑
  我看不见你的手
  自从倒塌的墙 把阳光夺走
  我再也看不见 你柔情的眸

妈妈:
  孩子 你走吧
  前面的路 再也没有忧愁
  没有读不完的课本 再也没有爸爸的拳头
  你要记住 我和爸爸的模样
  来生还要一起走

孩子:
  妈妈 别担忧
  天堂的路有些挤
  有很多同学和朋友
  我们说 不哭不哭
  哪一个人的妈妈都是我们的妈妈
  哪一个孩子都是妈妈的孩子
  没有我的日子
  你把爱给活着的孩子吧

  妈妈
  你别哭
  泪光照亮不了
  我们的路
  让我们自己
  慢慢的走
  妈妈
  我会记住你和爸爸的模样
  记住我们的约定 来生还要一起走


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image03:05 I urge you to please notice...» Projectionist
I urge you to please notice when you are happy, and exclaim or murmur or think at some point, “If this isn’t nice, I don’t know what is.”

Kurt Vonnegut


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image03:04 Displacements – Micha...» Projectionist

Displacements – Michael Naimark


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image03:04 Kernel#probably & Kerne...» Projectionist

Kernel#probably & Kernel#rarely

module Kernel def probably yield if (0...8).include? Kernel.rand(10) end def rarely yield if (0...2).include? Kernel.rand(10) end end 1_000_000.times do probably do good end rarely do evil end end # Good done 799,086 of 1,000,000 # Evil done 199,662 of 1,000,000

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image02:56 移动世界:拥有3G的第二代iPhone即将发布» 天天红玉世界
拥有3G的第二代iPhone即将发布
  • 说明
    • iPhone是一款划时代的 智能手机 ,该手机的市场占有率将会越来越大!与之相关的软件业将是一个不可低估巨大而又惊人的潜力市场。未来的三、五年与之能够竞争的巨头将会出现,它将会是使用 Google Android系统 的智能手机。
    • 发布时间:2008.06.09
    • 发布会议:WWDC (Worldwide Developers Conference)
    • iPhone 2价格: US$ 299 或者 $349 (目前价格 US$ 399)

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:10 明天开始» Ruby 语言 思想驱动生活
这几天主要考察了一下,主要想的都差不多了。明天开始就可以编码了,应该。 今天装了PEAR::Log 自己也想了2种多语言支持的方法,一个是用smarty的注册方法,一个是修饰子 注册方法的使用为: {getMessage id=”some message”  name=”asdf “   mail= “hotmail”} 而语言定义文件为 “some message”=> “hello {name}, mail to {hotmail}” 取出的字符串当然会被asdf等实际传递的字符串替换。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Fri 30 May, 2008

Click here to bookmark this link.Channel Image23:10 IronRuby and Rails» John Lam on Software
IronRuby dispatched some simple requests through an unmodified copy of Rails a few days ago. Today, we’re going to show off our progress live at RailsConf. This is an important milestone for IronRuby; it’s our ‘ticket to entry’ to the...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image19:38 Egregious Spelling Errors» Joey Gibson's Blog

Yesterday I received a packet in the mail from Disney's Pirates of the Caribbean Online game. I am a charter member or something like that since I joined up really soon after it launched and I might have paid for some length of time. Anyway, so this packet comes with some neat maps and such, but also some glaring spelling errors in the first paragraph.


(Click the image for a larger version.)

I was shocked at those. Disney usually has much better quality control, so I'm really surprised this slipped out the door. For those of you scratching your heads about what's wrong with the circled words, let me 'splain. "You're" is a contraction of "you" and "are". The word they really wanted was "your." And "adieu" is French for "goodbye." The word they wanted was "ado," as in "Much Ado About Nothing."

Come on Disney people, you can do better than that.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:58 Twitter Updates for 2008-05-29» halostatue
updating to 10.5.3 # made red-skinned potato salad tonight. yum. # @bbum my left ⌘ and right shfit keys are heavily worn down. My left cmd looks a lot like yours. # @jbrains Will do. Download says “two hours” (420Mb download! OUCH!) If I’m not back by morning… weep. # Now entering the reboot phase of 10.5.3 update ;) [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image12:11 Handy git-daemon Ruby script» James Britt - Code, Content, Caffiene

Last night’s Refactor meeting was great. A big thanks to Austin for his detailed Git talk, and to David for demoing some git repo sharing.

Austin has posted his slides on his website:

http://uberhip.com/projects/presentations.html

And you can clone it from the repo with: git clone http://uberhip.com/git/gitintro.git

Earlier in the day David and I were poking around with git-daemon, getting the parameters Just So and experimenting with basic repo sharing. It crossed my mind that the process for selecting the git-daemon arguments and kicking off the process should be automated with a script; David, though, was way ahead of me and quickly had a working version running.

We now have a nice little Ruby script that makes sharing a git repo snake simple. David posted the code to the Refactor mailing list.

You just drop the script in your bin dir, and when you want to share a git repo you cd to the root of the working directory and run share_git_repo (or whatever you’ve named it).

It will figure out the correct base path and display the URL needed by the client.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Thu 29 May, 2008

Click here to bookmark this link.Channel Image17:01 Rails框架:如何演练Rails 2.1 RC1» 道喜技术日记
Rails框架讲座:如何演练Rails 2.1 RC1

目录
 (一)系统环境:

  1. Ruby 语言 1.8.6版本, 点击这里Ruby1.8.4。要想安装多个Ruby语言运行环境请看这里
  2. Rails 框架 2.0.2版本,安装方法请看这里,最简单方法是第一种方法即可。
  3. Windows XP 或者 Windows 2000操作系统 或者 Linux Ubuntu操作系统
  4. 需要一个浏览器,如FireFox1.5.0.1以上版本。
  5. 开发编辑工具 Notepad2 ,安装方法请单击这里,复制一个notepad2.exe,并且更名为vi.exe。
  6. 在Windows XP上安装Linux核心命令,点击这里
  7. 如何在Windows Console下使用命令svn(下载软件),点击这里
  8. 在Windows上安装版本控制系统Git作为客户端使用,点击这里
  9. 安装数据库系统SQLite3,点击这里

 (二)前提条件:

  1. 在本机Winodw操作系统上,我们的工作目录为d:\works_rails2008。
  2. 你的电脑必须在线。
  3. 安装Rails框架插件thin:
    gem install thin --no-ri --no-rdoc

 (三)目的:

  1. 我们想要在一个已有Rails项目(版本为2.0.2)上安装和使用Rails框架最新版本2.1 RC1,注意不改变系统上的Rails框架版本。

 (四)解决方案:

  1. 创建一个Rails项目:
    rails test_project && cd test_project
  2. 查看系统Rails框架版本,应该还是版本2.0.2。
    rails -v
  3. 查看该Rails项目的版本信息
    ruby script/about
    输出结果:
    About your application's environment
    Ruby version              1.8.6 (i386-mswin32)
    RubyGems version          1.1.1
    Rails version             2.0.2
    Active Record version     2.0.2
    Action Pack version       2.0.2
    Active Resource version   2.0.2
    Action Mailer version     2.0.2
    Active Support version    2.0.2
    Application root          E:/coding/work_rails2008/test_project
    Environment               development
    Database adapter          sqlite3
  4. 安装Rails框架2.1 RC1到该Rails项目上
    git clone git://github.com/rails/rails.git vendor/rails
  5. 再一次查看该Rails项目的版本信息
    ruby script/about
    输出结果:
    About your application's environment
    Ruby version              1.8.6 (i386-mswin32)
    RubyGems version          1.1.1
    Rails version             2.0.991
    Active Record version     2.0.991
    Action Pack version       2.0.991
    Active Resource version   2.0.991
    Action Mailer version     2.0.991
    Active Support version    2.0.991
    Edge Rails revision       4d248543429918bc5a63e109e6f2327ffab9848b
    Application root          E:/coding/work_rails2008/test_project
    Environment               development
    Database adapter          sqlite3
    Database schema version   0
  6. 查看该Rails项目目录script文件
    ls script
    输出结果:
    about  console  destroy  generate  performance  plugin  process  runner  server
  7. 更新该Rails项目相关到Rails2.1 RC1内容
    rake rails:update
  8. 查看该Rails项目目录script文件,发现多了一个文件dbconsole
    ls script
    输出结果:
    about    dbconsole  generate     plugin   runner console  destroy    performance  process  server
  9. 为了使用上面这个新文件dbconsole,可以使用如下命令。该命令简化和统一了打开数据库方法。
    ruby script/dbconsole
    >>.exit
  10. 再次,查看系统Rails框架版本,应该还是版本2.0.2。
    rails -v
  11. 修改该Rails的相关配置文件environment.rb
    vi config/environment.rb
    【代码开始】
    。。。
    RAILS_GEM_VERSION = '2.0.991'
    。。。
    【代码结束】
  12. 创建该Rails的相关配置文件new_defaults.rb
    vi config/initializers/new_defaults.rb
    【代码开始】
    # These settins change the behavior of Rails 2 apps and will be defaults
    # for Rails 3. You can remove this initializer when Rails 3 is released.
    # Only save the attributes that have changed since the record was loaded.
    ActiveRecord::Base.partial_updates = true
    # Include ActiveRecord class name as root for JSON serialized output.
    ActiveRecord::Base.include_root_in_json = true
    # Use ISO 8601 format for JSON serialized times and dates
    ActiveSupport.use_standard_json_time_format = true
    # Don't escape HTML entities in JSON, leave that for the #json_escape helper
    # if you're including raw json in an HTML page.
    ActiveSupport.escape_html_entities_in_json = false
    【代码结束】
  13. 启动网络服务器thin,或者使用Mongrel。
    thin start

 (五)视听教学:



  (六)必须注意的问题:


 (七)参考资料:

  1. Rails 2.1将会有什么

 (八)命令清单:

rails test_project && cd test_project
rails -v
ruby script/about
git clone git://github.com/rails/rails.git vendor/rails
ruby script/about
ls script
rake rails:update
ls script
ruby script/dbconsole
 .exit
rails -v
vi config/environment.rb
【代码开始】
。。。
RAILS_GEM_VERSION = '2.0.991'
。。。
【代码结束】
vi config/initializers/new_defaults.rb
【代码开始】
# These settins change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
# Only save the attributes that have changed since the record was loaded.
ActiveRecord::Base.partial_updates = true
# Include ActiveRecord class name as root for JSON serialized output.
ActiveRecord::Base.include_root_in_json = true
# Use ISO 8601 format for JSON serialized times and dates
ActiveSupport.use_standard_json_time_format = true
# Don't escape HTML entities in JSON, leave that for the #json_escape helper
# if you're including raw json in an HTML page.
ActiveSupport.escape_html_entities_in_json = false
【代码结束】
thin start



  (九)下载文件pdf:


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:49 Ajax Rating: 简易打分插件» LetRails
刚完成的一个小插件,比较粗糙,欢迎多提意见。 安装 $ ./script/plugin install http://svn.elctech.com/public/plugins/ajax_rating 使用 在你要评分的model中添加acts_as_ratable,比如post: class Post < ActiveRecord::Base ...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:39 Twitter Updates for 2008-05-28» halostatue
Are booq bags really that good? # The Booq bags look good; I’m just trying to figure out what I want and how much to spend. I need for laptop and camera + 2-3 lenses. # I’ve got a 15″ MBP now, but am leaning toward Air, especially if there’s a rev before I buy. I only [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Wed 28 May, 2008

Click here to bookmark this link.Channel Image23:58 睡眠不足,眼疼» Ruby 语言 思想驱动生活
每天1点多睡,16个小时都在看电脑。 jquery的$取得的原来不是dom对象,是jquery对象,要想调用dom的方法,先要转换为dom对象,比如$(”#divid”)[0] 另今天从他们网站下的ui的部分竟然很多不能用和例子里的文件名都不一样,不知道是不是我下的版本不同呢。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image15:43 Some Git links for Wednesday's Refactor Phoenix» James Britt - Code, Content, Caffiene

I posted some links to the Refactor Phoenix sub-topic on Reddit:

http://reddit.com/r/refactorphoenix/

There are also some links on the Refactor home page.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image15:43 Twitter Updates for 2008-05-27» halostatue
Just got back from watching Iron Man with my wife. We both really enjoyed it. # Really impressed with Milestone’s Restaurant tonight. They comped my dessert as a “moment” since it was my birthday. attention to detail. :) # debugging doxygen generation nonsense # figured out doxygen nonsense; it was actually latex nonsense. # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:44 网站推荐:天天有新闻A Fresh Cup» 天天红玉世界
天天有新闻网站A Fresh Cup
  • 箴言名句
    • 【原文】子贡问曰:“有一言而可以终身行之者乎?”子曰:“其乎!己所不欲勿施于人。” --《论语》
天天有新闻网站A Fresh Cup

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Tue 27 May, 2008

Click here to bookmark this link.Channel Image15:10 Twitter Updates for 2008-05-26» halostatue
@Ihnatko it’s not much different than spirit rover on LJ # @cburell check this out: http://tinyurl.com/28e4st # @twitterrific Double clicking on user avatars doesn’t go to “with_friends” anymore; it seems to be a broken interaction on Twitter itself. # making good progress on reading catchup # I’ll lose my catch-up-ness as soon as I start reading some of the [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:52 视频世界:版本控制系统Git视频教程» 天天红玉世界
Click here to bookmark this link.Channel Image03:08 Perhaps it’s only a t...» Projectionist
Perhaps it’s only a trampled package in the street—this life I pick up—and maybe my writing is its furtive unwrapping.

William Kohler in The Tunnel


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image03:01 pentimento: An underlying i...» Projectionist
pen•ti•men•to
[pen-tuh-men-toh]noun
An underlying image in a painting, as an earlier painting, part of a painting, or original draft, that shows through, usually when the top layer of paint has become transparent with age.

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Mon 26 May, 2008

Click here to bookmark this link.Channel Image23:59 职业的程序员» 梦想风暴
有人问我,在目前这个项目中,和外国同事一起工作的感觉如何,我答曰,他们更职业。

这里说的职业,并不是说他们写出的程序本身有多么神奇,恰恰相反,他们写出来的程序和我们写出来的程序,看上去并没有多大的差别。之所以,他们给我留下更职业的感觉,主要是日常工作的一些细节。

刚开始进入项目的时候,我们几个中国同事对项目完全是一头雾水,甚至Rails开发都很少,所以,在和他们一起工作的过程之中,就需要他们为我们做大量的解释,而这种时候,他们总是表现得非常耐心。有时候,语言上的障碍让我们不能一下子抓住他们说的重点,他们就会不厌其烦的一遍遍解释着,直到我们表示自己真正的理解了。

刚刚入门的人难免会问一些愚蠢的问题,他们并不会嘲笑,反而会认真的给你讲解,这会给人以极大的信心,不会因为问题的愚蠢而被打击了积极性。回顾自己之前在工作中的表现,在这一点上,我做得总是很不够,我愿意给人解释一些问题,但对于简单的问题,我有时会表现得不屑一顾。实际上,谁没有从笨笨的初学阶段走过来呢!对于初学者,鼓励的作用更大一些。最近一段时间,我会和几个新近加入项目的同事一起工作,自己刻意在这个方面注意了一下。

前些天,有一些来自产品环境的任务,要对产品数据做一些修改。这些外国同事对这种问题的想法是,写个脚本解决它,即便数量不是很大。所以,那几天几乎每天都是在写脚本。其实,对于数据量不大的一些修改,手工修改可能来更快,但是,每次都用脚本解决问题,一来可以锻炼一个用脚本解决问题的好习惯,二来可以避免做一些让自己头疼手工操作,将其转化为编程问题,解决起来更有乐趣,再有,以后遇到类似的问题,有之前的脚本可以参考。这里不得不说一下用Ruby写脚本还是很方便的,Rails项目的开发和维护都用Ruby,很大程度将二者统一起来。

项目进行性能测试,一个外国同事将测试结果放到了一个电子表格中,做成了动画效果,很高兴的给秀给我们看。因为在他看来,那是一件有乐趣的事,尤其是一群人乐呵呵的围绕在他身边看他的工作成果。

我们的开发平台是Mac,基本上就是一个Unix平台。所以,我们的外国同事经常会给我们展现他们良好的运用Unix命令的能力。他们经常将一些Unix命令组合起来,完成一些辅助开发的工作,很大程度的提高了工作效率。

在我们项目的Mingle里面,有一个Dev Standup的页面。在日常的开发中,一些解决起来会有些困难部分或者影响会比较大的部分,就会记录在这个页面里面。一方面,分布在中国和美国的同事都有机会知道对方做了些什么影响比较大的部分,另一方面,双方也可以协作解决一些对方觉得头疼的问题。

在ThoughtWorks做程序员,幽默感是不可缺少的一环。所以,经常会出现这样画面:“你能帮我一下吗?”,“不”,然后,一个人过去问什么事;“一个问题”,“一个答案”;两个人正在讨论,有一个人过来说“我觉得有道理”,另一个过来说“我不这样认为”……


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image17:06 JRuby语言:《JRuby语言实战技术》预计2008年6月出版» 道喜技术日记

《JRuby语言实战技术》预计2008年6月出版


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image15:08 Twitter Updates for 2008-05-25» halostatue
too tired # @binary42 I had to implement a system where we evaluated SOAP over XMPP. Completely unreliable because of the fact that most Jabber is… # @binary42 …is for chat and has rate limiters. XMPP made the SOAP messages much larger, too. We wrote our own messaging protocol instead. # @binary42 Jabber servers are optimized for communication: [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image12:27 I Keep Forgetting by Michae...» Projectionist

Sun 25 May, 2008

Click here to bookmark this link.Channel Image21:12 Rails框架插件系列:增加标记input的属性class» 天天红玉世界

增加标记input的属性class

  • 说明
    • 插件class_inputs的作用在于增加标记input的属性class,以便更好地显示页面。这里介绍这个插件的目的是让大家把它作为学习Rails插件的实例。
  • 安装方法
ruby script/plugin install http://svn.jcoglan.com/classyinputs/trunk/classy_inputs

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image12:07 Twitter Updates for 2008-05-24» halostatue
@danielpunkass thanks for the Olbermann link. # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image02:31 A design problem is not an ...» Projectionist
A design problem is not an optimization problem.

Christopher Alexander


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Sources