词汇:do

n. 要求;规定;C大调音阶中的第一音

相关场景

Do you know how acupuncture works?
你知道针灸是如何起作用的吗?
>> 26. Traditional Chinese Medicine
Some people argue that Chinese medicine is not a science. Do you agree with them? Why or why not?
有些人认为中医不是一门科学。你同意他们的观点吗?为什么或为什么不呢?
>> 26. Traditional Chinese Medicine
Do you know the difference between porcelain and pottery?
你知道瓷器和陶器的区别吗?
>> 25. Chinese Art
Do you like watching Chinese opera? Why or why not?
你喜欢看中国戏曲吗?为什么或为什么不呢?
>> 25. Chinese Art
Do you think computers would lead to the disappearance of Chinese calligraphy in the future? Why or why not?
你认为电脑会导致中国书法在未来消失吗?为什么或为什么不呢?
>> 25. Chinese Art
Why do Chinese cuisines differ from region to region?
>> 24.Chinese Cuisine
What kinds of activities do Chinese people usually do on the day of the Lantern Festival?
中国人通常在元宵节做什么活动?
>> 23. Traditional Chinese Festivals
Why do Chinese people celebrate the Spring Festival?
中国人为什么庆祝春节?
>> 23. Traditional Chinese Festivals
It's also renowned for attracting buyers, so along with trade visitors, senior decision-makers to do business with.
它也以吸引买家而闻名,因此与贸易访客、高级决策者一起做生意。
>> 14. Trade Fairs
The department demands a well-organized and well-trained staff who can do a great deal to assure a high business repeat and occupancy rate, not only through the efficiency in their jobs but also through their heart-felt warmth in serving the guests. So the qualities of housekeeping department staff - enthusiasm, patience, politeness and professional spirits - can ensure that the staff fulfill their tasks.
该部门需要一个组织良好、训练有素的员工,他们可以做很多事情来确保高的业务重复率和入住率,不仅通过他们的工作效率,还通过他们为客人服务时的内心温暖。因此,客房部员工的素质——热情、耐心、礼貌和专业精神——可以确保员工完成任务。
>> 8. The Housekeeping Department
If a guest's passport is lost, a tour guide should do the following:
>> 6.Dealing with Emergencies
e:
If it takes a long time to arrive at the place of interest, the tour guide can do something to keep the guests from getting bored. For instance, the tour guide can tell some interesting Chinese stories or sing some songs to the guests.
如果到达景点需要很长时间,导游可以做点什么来让客人不无聊。例如,导游可以给客人讲一些有趣的中国故事或唱一些歌。
>> 4. On the way to the Scenery
In the coach, on the way to the scenic areas, the local tour guide should do the following.
>> 4. On the way to the Scenery
b:
Remind the driver of the car or coach to do full preparations for his driving in advance;
提醒汽车或长途汽车驾驶员提前做好驾驶准备;
>> 4. On the way to the Scenery
43. Gem:
Gem::Specification.new do |gem\ gem.add_dependency('money', '>=4.2.0', '<5.2.0') ;悲观版本操作符;
>> Effective Ruby
39.测试的重要性; fuzzbert and mrproper属性测试;SimpleCov 测试覆盖率 ZenTest监测代码:
尽可能的自动化测试;运行代码才知道代码在干啥;测试又happy path and exception path; fuzz testing and property testing; require('fuzzbert') require('uri') fuzz('URI::HTTP:build') do data("random server names") do FuzzBert::Generators.random end deploy do |data| URI::HTTP.build(host: data, path: '/') end 会持续运行,手动停止。 MrProper; properties("Version") do data([Integer, Integer, Integer]); property("new(str).to_s == str") do |data| str= data.join('.'); assert_equal(str, Version.new(str).to_s); 测试驱动开发里面的测试并不好写,
>> Effective Ruby
38. Mock模拟对象 define一个method,并模仿mock需要调用的特定对象;:
def alive? echo = Time.now.to_f.to_s response = get(echo) response.success? && response.body ==echo end; private get(echo) url=RUI::HTTP.build(host:@server, path: "/echo/#{echo}") HTTP.get(url.to_s) end
monitor = Monitor.new("example.com"); response = MiniTest::Mock.new ; monitor.define_singleton_method(:get) do |echo| response.expect(:success? , true); response.expect(body, echo); response end assert(monitor.alive?, "should be alive") response.verify end; 用Mock格里外部系统不稳定因素;Mock#verify
>> Effective Ruby
37. MiniTest的测试需求:
unit testing or spec testing= behavioral specification; 在单元测试基础上封装而来。
describe("when comparing") do ... end before do ...end it("orders correctly") do ..end; before == setup; after = teardown; 如果喜欢需求测试风格,参考RSpec cucumber等。 MiniTest::Expectations
>> Effective Ruby
31. eval; instance_eval定义的是单例方法;:
def glass_case_of_emotion x="I'm in a " + __method__.to_s.tr('_',' ') binding; binding 可以获得当前的临时域并把这个临时域封装到Binding对象中作为返回结果。这个指定的上下文是eval方法的第二个参数; eval("x", glass_case_of_emotion); class_eval很像是重新打开类,实际上是被定义在Module里面,only被模块和类使用。= moudle_eval; instance_eval访问实例变量;class_eval定义实例方法。 class Widget attr_accessor(:name, :quantity) def initialize(&block) instance_eval(&block) if block end ;;; w= Widget.new do |widget| widget.name= "Elbow Grease" ; @quantity = 0; end ; instance_exec, class_exec, moudle_exec; only accept 代码块, no string; object.instance_eval("@#{name} = DEFAULT")
module Reset def self.reset_var (object, name) object.instance_exec("@#{name}.to_sym") do |var| const = self.class.const_get(:DEFAULT); instance_variable_set(var, const) end ...
>> Effective Ruby
30.define_method or method_missing:
如果没有找到任何方法,method_missing就会被执行;但是因为又super的原因,这里会有迷惑。def method_missing(name, *args, &block) if @hash.respond_to?(name) @hash.send(name, *args, &block) else super end end; Hash.public_instance_methods(false).each do |name| define_method(name) do |*args, &block| @hash.send(name, *args, &block) end; h.public_methods(false).sort.take(5); 实现了Hash的方法。
AuditDecorator @logger = Logger.new($stdout); private def method_messing(name, *arg, &block) @logger.info("calling '#{name}' on #{@object.inspect}"); @object.send(name, *args, &block); define_method更加适合做这个了。 mod=Module.new do object.public_methods.each do |name| define_method(name) do |*args, &block| @logger.info("") @object.send(name, *args, &block) end end end extend(mod) ; 创建了一个匿名的模块。 —— define_method恢复了内省方法。。 respond_to? and respond_to_missing?
>> Effective Ruby
27. throw is better than raise to jump out 作用域:
loop do {... raise(..) if ...}; throw(:jump, [character, color]) 传参数到上层,catch处理。简单方法控制程序结果。return, catch和throw;
>> Effective Ruby
24. block and ensure:
分配-使用-释放;file = File.open(file_name, 'w'_...file.close;因为又垃圾回收的原因,中途发生异常也会被回收资源,但是你不确定什么时候会被回收,所以你如果能及时处理,那更好。那么就算需要begin。。。ensure file.close if file end;也可以通过 File.open(file_name, 'w') do |file| ...end,这种block的方式。块执行晚后文件会被关闭。将资源管理简单化。 简单化的资源管理,也衍生出一个 传block给方法的问题,可以用class Lock def self.acquire ; lock =new ; lock.exclusive_lock!; if block_given? yield(lock) else lock # Act more like Lock::new. end ensure if block_given? # ...end end end; 没有绑定块时候,Lock::acquire 。。。; 类方法上使用块和ensure语句将资源管理的逻辑抽离出来。
>> Effective Ruby
17.数组参数:
initialize(toppings) {Array(toppings}.each do |topping| ...} 转换为Array让代码更加健康。
>> Effective Ruby
He who wants to do good knocks at the gate; he who loves finds the gate open.
>> Stray Birds
Sit still, my heart, do not raise your dust. Let the world find its way to you.
>> Stray Birds