Thursday, June 23, 2011

停车技巧

停车技巧:

非字形停车位:右侧车身 距离车位线1.5m,向后倒车; 在驾驶位位于隔一个停车位正中央时,向内侧打满轮,至车正,回正。

一字形停车: 右侧车身 距离车位线0.5m,向后倒车;在后视镜和前车B柱平行时,向内侧打满轮,继续倒车,至车呈45度角,反向打满轮,至车正,回正。

斜线停车位:后视镜对停车位近端边线时,向外侧打满轮,至车身和车位平行,回正,入车位。

自动档驾驶学习

N档的作用:
转自http://club.autohome.com.cn/bbs/thread-c-413-824998-1.html

1、被拖车时用: (拖行距离不超过50公里)。

2、长时间(超过1分钟至数分钟内)等红灯时用: (在我们这里,红绿灯都有数字递减显示。就可以根据上述原则,采取“①挂N,拉手闸。②保持D档,拉手闸。”)

3、汽车启动、熄火时: (所有汽车说明书都是讲点火要挂在P档,但问题在于: 当在P档点火后,要挂入D档前,是一定要经过R(倒车档)档,当经过R档时,车辆会自然震动一下,这是挂R档的缘故,从P档到D档过程中,等于先入了R档再入D档,无形中多了一次入R档的组合和磨擦,

我的做法是:踩着刹车打开钥匙第一级--挂N档--打火--挂D档--松手刹、放脚刹起步。
自动档熄车也有讲究,我是这样操作的: 熄火前踩着刹车挂N档--拉手刹--放开脚刹--关钥匙第一级--入P档--关钥匙第二级并取出钥匙。 其道理是:停车时,当踩着刹车入P档,拉手刹放开脚刹时,车辆会惯性地向前或向后移动一点位置,这是因为停车场不平整或有少许斜坡而造成的,不要小看这一点点移动,它会对自动变速箱中的锁止栓有一定的冲击,日积月累会对锁止栓有损害,就会出现过锁止栓断开的故障)。

Sunday, June 12, 2011

cache - set associative

Cache Associative:

Full-Associative
If the replacement policy is free to choose any entry in the cache to hold the copy, the cache is called fully associative.
Direct-Mapped
At the other extreme, if each entry in main memory can go in just one place in the cache, the cache is direct mapped.
N-Way-Associative
Many caches implement a compromise in which each entry in main memory can go to any one of N places in the cache, and are described as N-way set associative.

If there are N places to which the replacement policy could have mapped a memory location, then to check if that location is in the cache, N cache entries must be searched. Checking more places takes
*PROs: caches with more associativity suffer fewer misses
*CONs: more power, chip area, and potentially time.


From direct mapped to 2-way, or from 2-way to 4-way, has about the same effect on hit rate as doubling the cache size.
Associativity increases beyond 4-way have much less effect on the hit rate


Example:
An 4K cache is often organized as a set of 256 lines(slots) of 16 bytes each.
Accordingly, a 4-way associative 4K cache has 64 sets, each set having 4 lines mapped.

A 32b address is divided into
[31:10] [9:4] [3:0]
tag set offset

For a given physical addr, first find the set with A[9:4] in cache.
Then search in all 4 slots to see if the tag A[31-10] matches the tag in the slot.

Wednesday, May 25, 2011

cshell redirection

Character Action

>
Redirect standard output

>&
Redirect standard output and standard error

<
Redirect standard input

>!
Redirect standard output; overwrite file if it exists

>&!
Redirect standard output and standard error; overwrite file if it exists

|
Redirect standard output to another command (pipe)

>>
Append standard output

>>&
Append standard output and standard error

Tuesday, May 10, 2011

[python] Parameters: pass by value or ref?

C is pass-by-value.
Java is pass-by-value.
Python passes references-to-objects by value (like Java), and everything in Python is an object.

Some objects, like strings, tuples, and numbers, are immutable. Altering them inside a function/method will create a new instance and the original instance outside the function/method is not changed.

Other objects, like lists and dictionaries are mutable, which means you can change the object in-place. Therefore, altering an object inside a function/method will also change the original object outside. Assigning a separate object (e.g. creating a new instance) to the input parameter will also not change the original instance.


   def  no_change0(val)
          val *= 2   #original val is not changed.
         
    def  no_change1(inst)
          inst = {}
          inst['anything'] = 'something'  #original inst is not changed!!!


   def  change1(inst)
          inst['anything'] = 'something'  #original inst is changed this time.

[python] How to iterate through a list

  • basic iteration 
Iterating through a list in Python is simple using a for in loop.
colours = ["red","green","blue"]

for colour in colours:
    print colour
  • enumerate 
To iterate through the same list using an index we can apply the enumerate() function.
colours = ["red","green","blue"]

for i, colour in enumerate(colours):
    print i, colour

  • Remove elements as you traverse a list
iterate over a copy of the list:
for c in colors[:]:
    if c == 'green':
        colors.remove(c)
Hereby colors[:] is a copy (a weird but, sigh, idiomatic way to spell list(colors)) so it doesn't get affected by the .remove calls

Saturday, April 30, 2011

制作面包

溶解酵母

正确地溶解酵母是成功制作发酵面包最重要的步骤。

  1. 将酵母和少量糖溶解在40到46摄氏度左右的温水。这个温度和糖能使酵母迅速膨胀。可以使用温度计来检查液体的温度。
  2. 大约5分钟后,酵母将开始起泡。如果不起泡,请倒掉酵母混合物,然后重新操作。
     

切勿使用过期的酵母。酵母的效用会随时间降低。

和面
和面的时候将酵母水分次倒入面粉中,不要一次倒入,最好分次按量调节加入水分。
和面的目标是一定要把面团揉出筋。面筋是小麦粉中的蛋白质,它决定了面包的结构。面筋在面团中形成柔韧的长丝,这些长丝会拦住酵母产生的二氧化碳气体。拦住的气体会让面包发面。
用面包机揉面可以选发面团模式揉20分钟停下后再打开发面团模式再揉20分钟基本就可以出筋。
  1. 在面板上撒一层薄面,然后揉面。
  2. 揉面时,一定要使用手腕的力量,而不是手指的力量。
  3. 手腕用力将面团向外侧推开,然后将外侧的面放在下面,反复重复以上操作。
  4. 揉按面团,直到用手指按压时感觉到光滑、柔软、富有弹性(需8到10分钟)。气泡或水泡就会出现在面团表层下。
  5. 揉好面团后要对面团进行进一步的揉和摔打,直到揉出面筋,拉开面团有撑不破的膜为止,大概需要一小时左右的时间。
     
发面
  1. 用湿纱布将盆盖上,并将其放在温暖(21到24摄氏度)无风的地方。
  2. 让面团发面,直到体积增大一倍,这大概需要1小时。
发好的面团用手按下,按下的洞不回缩,为发酵完成。


塑形和二次发面

  1. 面团体积增大一倍后,用拳头进行挤压。这样可以去除大气泡,让面包的质地更细腻均匀。
  2. 将面团的各边向中间折,形成球形。
  3. 根据食谱说明对面团进行塑形,并将其放在涂好油的烤箱油纸或抹好油的面包盘中。
  4. 将塑形的面包盖上,然后将它们放在一个暖和的地方再次发面,直到体积增大一倍,这大概需要40分钟。
烘焙
  1. 将面包放在已经预热的烤箱中间的架子上。
  2. 如果面包变成金褐色,形状是圆圆的,轻拍时听起来是中空的,那么说明面包已经做好了。
  3. 若要使面包皮松脆,请在烘焙的过程中,在烤箱的底部放盘水,或者在面包表面刷层水。
    若要使面包皮松软,烘焙完后,立即在面包表面刷层软化黄油。

冷却和储藏
  1. 立即将面包从面包盘或烤箱油纸中取出,然后将面包放在铁架上冷却。
  2. 面包完全冷却后,用塑料包装袋将其包起来,或者将其放入密封的塑料袋或容器中。
  3. 在室温下储藏面包;将面包放在冰箱中会让面包更快变味。
  4. 将未包装的发酵面包放在室温下2到3小时进行解冻;您也可以将它们部分包起来放在温度190摄氏度左右的烤箱中加热20分钟。
  5. 在冷冻之前,需要将新出炉的面包放在铁架上至少冷却3小时。将面包在冰箱中的平面上放2小时,或者直到它已经冻硬。用塑料包装袋包好冷冻的面包,然后将面包放在铝箔中。标上面包的制作日期及面包的种类,然后将其放回冰箱。
  6. 面包最多可以冷冻6个月。将冷冻的面包连同包装放在室温下解冻2到3小时。将面包放在温度为150摄氏度左右的烤箱上加热20分钟,使其恢复新鲜。