- 浏览: 246498 次
- 性别:
- 来自: 杭州
-
最新评论
-
zhangyou1010:
回去倒立去,哈哈。
作为一个程序员,身体很重要! -
Hooopo:
Ruby MetaProgramming is all abo ...
Metaprogramming Ruby -
orcl_zhang:
yiqi1943 写道LZ现在上学还是工作呢工作好多年了。不过 ...
2011年 -
yiqi1943:
LZ现在上学还是工作呢
2011年 -
tjcjc:
query cache
就是一个简单的hash
key就是sq ...
Rails sql延迟加载和自带缓存
文章列表
ubuntu升级到9.10后,今天更新了下系统。结果导致,fcitx和java程序冲突。
只要启动netbeans或者qq等java程序,fcitx占用cpu就会到100%,只有重启才能解决。
暂时先用ibus,等这个问题解决后,在用fcitx
2010年的计划:
1,生活方面
b,还是坚持积累英文单词。保证英文文档更快更好的阅读。
c,继续坚持打球。跑步一周两次(不能懈怠)
想读的书很多,分个计划,可以更合理的安排时间,以便督促自己更好的完成。
2,读书计划
rails recipes(正在读。3月15号读完)
硝烟中的xp和scrm(3月15到3月30)
the-rspec-book(4月30到5月15)
活法(4月25到5月10)
program ruby再读。
Ruby for Rails中文版(5月5到5月20)
rails源码学习。(5月20到6月20)
Everyday Scripting with Ruby中文版(6.1 ...
检查是否具有实例变量
class Object
def must_have_instance_variables(*args)
vars = instance_variables.inject({}) { |h,var| h[var] = true; h }
args.each do |var|
unless vars[var]
raise ArgumentError, %{Instance variable "@#{var} not defined"}
end
end
...
当增加新方法,类方法删除和取消定义的现有方法
class Tracker
def important
"This is an important method!"
end
def self.method_added(sym)
if sym == :important
raise 'The "important" method has been redefined!'
else
puts %{Method "#{sym}" was (re)d ...
A Method object can be stored in a variable and passed as an argument to other methods. This is useful for passing preexisting methods into callbacks and listeners:
一个Method对象可以存储到变量中并作为参数传递给其他方法。这对于回调和监听器传递先前存在的方法非常有用。
class EventSpawner
def initialize
@listeners = []
@state = 0
...
在软件开发过程中,我们经常会指派问题给他人或者对开发人员提出bug。但是,更多的时候,提出的问题会带来各种其他麻烦。为了尽量减少各种麻烦,以及问题或者bug的解决,需要注意几个问题。
首先是一个问题提出到解决的流程。
1,发现问题,提交问题到bug系统。状态为新建。
2,指派给开发人员。状态为指派。
3,开发人员解决。状态为解决。
4,经测试人员测试后,发现依然存在问题,进行反馈并反指派给开发人员;如果没有问题,修改状态为关闭。
怎样记录问题呢?
一个问题 ...
WBS,不止是工作分解结构,也能更好的管理个人时间,是一个很好的工作和做事的思路和习惯。
先看下WBS的官方定义吧,工作分解结构(WorkBreakdownStructureWBS):以可交付成果为导向对项目要素进行的分组, ...
Now that you have that working, you can’t help but ask yourself what
other elements you constantly find yourself putting into forms. How
about alternate the color of each row in a form? Here’s a form builder
that does that:
Download CustomFormBuilder/app/helpers/application_helper.rb
class Tab ...
#.irbrc
require 'rubygems'
require 'hirb'
require 'wirble'
require 'irb/completion'
Wirble.init
Wirble.colorize
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end
IRB.conf[:PROMP ...
#使分配程序能够使用注册回调的返回值
A simple change to the EventDispatcher class makes it possible for the dispatcher to use the return values of the registered callbacks. The original implementation of EventDispatcher#notify called the registered code blocks, but ignored their return value. This version of EvenTD ...
7.11 使用回掉的松偶合系统
Coupling Systems Loosely with Callbacks
Here's a mixin module that gives each instance of a class its own hash of "listener" callback blocks. An outside object can listen for a particular event by calling subscribe with the name of the event and a code block. The dispatcher ...
Recipe 7.9. Looping Through Multiple Iterables in Parallel
Any object that implements the each method can be wrapped in a Generator object. If you've used Java, think of a Generator as being like a Java Iterator object. It keeps track of where you are in a particular iteration over a data structure. ...
ruby操作文件,使用find,来查找匹配的文件
6.20
Use the Find.find method to walk the directory structure and accumulate a list of matching files.
Pass in a block to the following method and it'll walk a directory tree, testing each file against the code block you provide. It returns an array of all files for which t ...
Similarly, File and String both include the Enumerable mixin, so in a lot of cases you can read from an object without caring what type it is. This is a good example of Ruby's duck typing.
#Here's a string:
poem = %{The boy stood on the burning deck
Whence all but he had fled
He'd stayed above ...
6.14备份至带版本号的文件名。
Problem
You want to copy a file to a numbered backup before overwriting the original file. More generally: rather than overwriting an existing file, you want to use a new file whose name is based on the original filename.
Solution
Use String#succ to generate versioned suffixes for ...