Saturday, December 27, 2014

Keys from PC to MAC


1. Force Quit
Command + Option + Esc 
2. Copy and paste
Command + C/V 
3. Right click
Hold down the Control key while clicking on something.
4. Take screen shots
Hit Command + Shift + 3. Command + Shift + 4 lets you choose a particular section of the screen to clip. 
5. Quit the application
Closing a window in OS X doesn't actually close the app. To do that, you must select Quit from its menu or hit Command + Q. 
6. Show Desktop
Command + F3
7. Restore
After upgrade from Mavericks to Yosemite for iMac, can restore to the factory mode (Yosemite) by pressing Power+ option at the same time.
8. Bootcamp
Install windows 7, has the error "setup was unable to create a new system partition ... ", after remove another external usb disk and move windows 7 usb to another usb port, issue fixed.
9.
Command + Option + D show or hide the Doc
10.
Command + Option +Escape to bring up "Force Quit Applications"
11.
ctrl-shift-右上角CD弹出键,按完屏幕就关了
12.
Make a MAC not hibernate
Disable the auto hibernation and set standbydelay to a bigger value (seconds)
sudo pmset -a hibernatemode 0
sudo pmset -a autopoweroff 0
sudo pmset standbydelay 10800000

Press Ctrl+Shit+Eject to turn off the screen
13.
Lock screen
a. Security & Privacy -> Require Password Immediately
b. Mission Control -> Hot Corners -> Start Screen Server

14.
Command + M: minimize the windows
Command + Delete: delete the file/folder
Option (when starting): select disk

Monday, December 22, 2014

告诉你外语学习的真实方法及误区分析 (note)

会用任何语言流利交流的前提是必须能用这种语言思考,做不到的就永远不能正常交流。
从说话的思维机制上讲,人在说话时,大脑是禁止思考语法规则的。一旦想规则,人就不能说话了。
那成年人在国外一般到底需要多长时间才能把外语说得比较流利呢?国外的语言专家有很深入的研究,
他们发现,前提是如果能维持外语环境(不能每天缩在本族人中),那么达到流利程度的时间需要年龄除以6。也就是说,如果三十岁到国外,
需要5年才会比较流利。所以很多出国读研究生和工作5年以上的中国同学,英语可能是非常流利的。
语言学家发现,婴儿是从六个月大时开始注意语言符号的,之前并不知道语言和其他声音的区别。六个月大的婴儿,每天一共24小时,
他先睡掉了十几个,剩下八小时左右,醒了就哭要吃,然后换尿布,洗澡等等,然后自己玩儿,并不是随时注意听大人的语言。统计发现婴儿注意语言的时间
每天一两个小时而已。但两年就会了。大家不要认为小孩子语言水平低,他们是知识能力低,语言是很流利的。
我们敬爱的俞敏洪老师到了国外曾无限慨叹,自己学和教了几十年英文,单词量十几万,比一般老外多了好几倍,但讲起英语来还不如自己在加拿大生的四岁的女儿流利。
对英语和其他各国语(有中文)的双语人士进行大脑扫描。在对从在小时后就学会了外语还是从成人后开始学习外语对他们大脑的不同影响的实验中发现,发现在小时后就学会双语的人,
两个语种语言区在大脑中是位于同一个区域,几乎重叠的;而在成年(十一二岁)以后才学会外语的人,两个语言区在大脑中是分开的,可明显分辨两个不同的语言区,而在使用其中一个语言时,
该种语种语言区是活跃的,而另一个语种语言区是关闭的,反之亦然。
大家都知道我们的大脑有左右两个脑半球,每个脑半球负责不同的功能。绝大部分的人,左脑负责的是:数字,逻辑,计算,推理还有语言。右脑负责的是:图像,色彩,音调,旋律还有浪漫。
有人简单总结为左脑是逻辑脑或理性脑,右脑是图像脑或感性脑。
婴儿大脑所具有的神经元突触数量大约是成人的两倍,负责左右脑的联系的神经也比成人丰富,所以小孩子在获得语言时,左右脑一起紧密配合使用。而到了大约六岁时,有人研究说如果这些神经元突触
还不使用就开始消退,有人研究说左右脑的神经链没有开始使用就开始萎缩(还有说断裂的),到了十二岁,这些神经元突触啊链啊就只有小时候的一半了。
在掌握语言时,是左右脑紧密配合的,更准确说,是用右脑帮助左脑实现建立语言区。大家还记得右脑是图像脑吧。儿童在最初听到任何语言的时候,一上来肯定是不懂的。但因为他们没有语言,
再给他们解释也是无用的。那怎么办?没人着急,人家自己有办法。他们通过在出现这些词句(一般先是简单词汇,更严格说是只这些词汇的语音)时的场景图像的观察(当然还包括触觉,嗅觉等其他辅助的感官刺激,
盲童甚至仅靠这些辅助感官刺激),而猜测这些词句大概代表的含义,并与图像进行“联系”。经过几次的重复刺激后,形成了对这一语音符号的“条件反射”,在大脑语言区的位置形成了脑神经的一个网络结构逐渐构造
该语言的语言区,最终实现了用这种语言的语音符号思维的能力。这个过程实现起来,既轻松,又快捷,成年人望尘莫及,而总是感到惊叹。
  
   总之,儿童的语言获取过程是:猜测——形成条件反射——建立语言区——实现语言.

说起语言是一种“条件反射”Conditional reflex,还真没太多人反对。大家在中学就学过,语言现象是“第二条件反射”,所以语言本身也叫做“第二信号系统”,使用工具和语言条件反射是人类特有的能力。
动物只有“第一条件反射。
儿童的语言获取过程:猜测——形成条件反射——建立语言区——实现语言思维。
成人学习语言的过程:学习——记忆——记忆区——知识
那语言是否在记忆区?原来语言本不是记忆。大家记得成龙演的“我是谁?”或Matt Damon演的“伯恩的身份”吧?两人都是连自己名字都不记得了,但说话甚至多种外语都会说。既然本不是记忆,
就谈不上真正意义的“会忘记”,当然也就知道语言不应该是靠记忆或“背诵”得来的了。
3岁时实际上长期记忆力几乎是零。三岁小孩给他换个妈他过几天就不记得了
大家也许听说过国外上小学上课尽是玩儿,很早就放学了,回了家哪有什么作业呀?还是玩儿。有作业也都是些小游戏,小实验项目等。到了中学还这样,
天天关心课外活动能力和交际能力,13岁没找对象老师还找去谈话问是否和异性相处有问题。
然后也没有什么高考,过SAT就成。SAT上那数学题让咱初中小孩做,全满分,这些小老外那叫觉得难。
英国的神经语言学家通过实验发现,会用两种语言的人(指有双语思维能力的人),他们的大脑聪明程度相对单一语言的人高,而且正是外语思维能力大幅度迅速地提高了他们的聪明度。
先听说,不读写
一、早期(Early Stage)
   如果单纯从零基础开始,早期(Early Stage)应该是一到两个月(由于英语与中文差异比与其他语言大,中国同学至少两个月,但也不应过长。我们的经验是一般中国同学会拖长时间。)具体实施方法建议如下:
  大量使用视觉辅助工具,直接建立“画面”与“声音”在大脑中的“联系”。最典型的手段有两个,一个是“看图识音”(不是看图识字,这是两个完全不同的概念)。在看图片的同时听与图片相关的英语声音;另一个是
我们以前谈到过的“全身肢体反应”(TPR)。在这一时期,有几个严格的要求:
  1. 避免使用中文翻译,充分建立条件反射;
  2. 不要试图说英语,只练听力;(还在沉默期内);
  3. 不要看任何拼写,把拼写的学习完全放弃;(不认识字母又和妨?)
  4. 如果有外教参与,外教可多用肢体语言或用手画图协助这一过程,不要教课;
  5. 不要怕听错,要放松和有信心;
  
   这一过程结束时,应该达到1000个左右的词汇+短语量。(没问题,这个量大多数人在这期间内都达的到)。顺便说一句,以前学过一种外语的同学,再尝试这种方法时会出奇的快,而且发现跟以前学的其他语言
一点不会混淆。

只给大家介绍使用原理和技巧,大家有兴趣的自己制作素材,嫌麻烦的去找这个软件“罗塞达石碑”。这个软件在中国没有销售公司,推荐它没有为商家宣传的嫌疑,(有同学有办法免费下载)
所以这是本人唯一的为大家直接推荐的“英语教学产品”。
这样几十小时一个级就能完。一共两个月,每天也就一小时吧,我们的(Early Stage)就成功了。(这要靠以前传统学法,非一年不可。)
TPR一般需要由有经验的教师辅导学生完成,特别是零基础者。但有一些基础的同学可以在学友之间甚至自己(先把指令录下)完成。

美国、加拿大有一电视节目“Yan Can Cook”,一个著名华裔电视厨师Yan教大家做中国菜。他一边幽默地叨唠一边切菜、炒菜,几乎把每个菜、原料,制作过程的每个动作等,全部同步地用英文仔细地叙述一遍,
当时惊叹为理想的“可理解性输入”体系!只是没好意思介绍给周围人,怕他们说我拿他们开逗。
每个画面最好是静止的。
画面要求简单,信息尽量少,相素要低。
故事情节应该是连续的,故事人物,背景,故事的发展要有很强的相关性。不必每个场景上述要素重新来过。连续的故事才有助于提高听者的“预测”能力。
根据情况,有的声音要稍先于画面出现,让听者先试听猜测,然后再用画面“证实”,有的情况需要声音后于画面出现,靠画面带动理解声音。
难度非常缓慢地逐渐加大。每个小段落完成后,有简单的重复练习和小测试。练习的方式最好是刚听过的内容稍变个形式再重复出现,别完全是原句子。
在这一阶段,应该使用标准发音,多种非标准音下一阶段才用。
不要阅读,但这阶段可以跟读每个句子,但不必尝试说。
+使用表意象形文字的中国人与使用拼音文字的西方人的大脑中,语言障碍区不在同一个地方,中国人有独特的语言区。研究发现,使用拼音文字的人,常用的是后脑的威尔尼克语言区;
但使用中文的人,此区几乎用不到,常用的是前脑的布鲁卡区。中文的语言区更接近于大脑运动功能区。由于中文语言功能区与运动区紧密相连,要想学好中文要多看、多写、多说,
靠 “运动”来记忆,而学习英文则应注重营造一个“语音环境”,注重多做听说的练习,因为英文的那一个语言功能区更靠近听力区。现在很多人学了多年英文却是 “哑巴英语”,
因为用学习中文的方法来学习英文是行不通的。该研究成果已在世界科技类最具权威的刊物美国《自然》杂志上发表公布。
英文到底有多少单词呀?韦氏字典上是四十五万个,牛津字典上五十万个,英国伯明汉大学曾编纂的单词集有两千万个。这就是英语的特点,单词量巨大。那一般 Native Speaker
掌握多少单词?有人认为是50000,这显然有问题。让一般Native Speaker考GRE单词,才20000以内,大部分人已经很困难了。一般认为Native Speaker应该在15000到30000
单词量之间。跨度如此之大,跟个人受教育程度十分有关联。这一点很有意思:在中国,尽管个人文化程度有差异,很少会出现在交流中听不懂对方词汇的现象(专业术语不算),
而这在英文中是常发生的事情。另外在中文中,谁要是使用了一个文雅的词汇或成语,听者大多都能懂,也没人会有意见。在英文中确不同,说一个“大词”,经常有人听不懂,
不是让别人感到惭愧,就是让人反感,有人还会不客气地说一句:“English please!”。另外我们看中文小说,很少有不认识的字或词,但Native Speaker看英文小说,碰到不懂的词是常事。
先成为一个会说话的文盲,再学习其他

1. Rosetta Stone
2. Cartoon TV/Movie
kid story
3. Yan Can Cook
美国、加拿大有一电视节目“Yan Can Cook”,一个著名华裔电视厨师Yan教大家做中国菜。他一边幽默地叨唠一边切菜、炒菜,几乎把每个菜、原料,制作过程的每个动作等,全部同步地用英文仔细地叙述一遍,

Friday, December 5, 2014

Reading Task

1. Enterprise integration patterns
2. Camel in action
3. Effective Java
4. Java Concurrency In Practice
5. Interview book

Tuesday, November 18, 2014

Reverse nearsightedness?

When I browsed yahoo news today, I saw the below link and clicked it based on the trust on Yahoo:


It stated that almost all people can get a 20/20 vision back without risk within less 2 weeks and I almost bought it. But it seems too good to be true so I searched Google and found the below link
http://www.sandiegocan.org/2014/05/12/alert-restore-my-vision-today-and-keep-your-money-in-your-wallet/
Shame on Yahoo to put this Ad on its homepage.

China did have a mandatory eye protective exercise but it's  not based on the Bates and the result is controversial. I don't believe the nearsightedness is reverse until my wife got a much better vision. And she claimed that it's the result ofthe eye protective exercise.

It might deserves a try to check
http://www.amazon.com/The-Secret-Perfect-Vision-Nearsightedness/product-reviews/1556436777


Wednesday, October 29, 2014

Spring Integration in Action

Spring Integration in Action
Source code: www.manning.com/SpringIntegrationinAction
A message is passed through a channel from one endpoint to another endpoint.
A message consists of a single payload and zero or more headers.
The channel implementation manages the details of how and where a message is delivered but
shouldn’t need to interact with the payload of a message.
Two endpoints can exchange messages only if they’re connected through a channel.
Channels can be categorized based on two dimensions: type of handoff and type of
delivery. The handoff can be either synchronous or asynchronous, and the delivery
can be either point-to-point or publish-subscribe.
Connections to the application or the outside world are also endpoints, and these connections take
the form of channel adapters, messaging gateways, or service activators.
A Channel Adapter connects an application to the messaging system.
In Spring Integration, a Messaging Gateway iss a connection that’s specific to bidirectional messaging.
A Service Activator is a component that invokes a service based on an
incoming message and sends an outbound message based on the return value of this service invocation.

The main idea behind IoC and the Spring Framework itself is that code should be
as simple as possible while still supporting all of the complex requirements of enterprise
applications. To accomplish that goal, the responsibility of controlling those complexities should be
inverted from the application code to a framework.

Tuesday, October 7, 2014

有道口语大师

-It's time to get off work.
-OK, let me grab my coat.

-what did you have in mind?
-I need to sleep on it.   --考虑一晚上再给你答案

-I'd like to make a reservation, please. The name is Anthony Cooper.

-Does the price include the breakfast?
-Yes Sir, We provide complimentary breakfast everyday.

-What else does the price include?

-Excuse me, could you tell me where can I get to the washroom?
-Hello, I'm looking for the new bookstore. Could you tell me how to get there?

-Is it far? Should I take a bus?
-Is it far? Can I get there on foot?
-Is it far? Should I take the metro?
-How long will it take if I walk?

-I'd like to book a table.

Sunday, September 28, 2014

行车记录仪优影U68说明书

优影U68说明书
1. 查看视频或图片
            连按两下O键,用上下键选择视频,按电源键最大化该视频,再按电源键播放。该视频最大化时按M键可删除或锁定该视频。
2. 锁定视频
            录像状态下按M键
3. 格式化
            格式化会删除所有文件,包括锁定文件

Friday, September 19, 2014

The performance improvement for P3

The performance improvement for P3
1 Used indexed collection to do the search and filter (cqengine)
2 Parallel processing (multi threading) for the dump file retrievement
3 Compress recon report and save blob into the database instead of clob and before show, unzip and show
4 Reduce the invocation and intercommuncation between the system and AC/DB
many times sql invocation against DB and the system to a few invocations on Oracle PL/SQL procedure/function
optimize the execution order (get batch result on AC/DB, collect the result in DB, and finally process them from Java)
Use the listagg instead of processing on Java side
getHolidayCount (currency,asofdate,maturityDate)
reduce the candidate size from SQL side instead of Java side (for FutureRollManager
5 Cache the query result from AC and database

Sunday, September 14, 2014

Computational Investing, Part I Week 1 note

Computational Investing, Part I Week 1 note

1. Portfolio manager: the constant management fee, less  than 1%, not related to the performance.
    Hedge fund: two and twenty. 2% of the total amount plus 20% of the return
2. Common metrics for the hedge fund performance:
annual return, risk: standard deviation of return, volatility
3. Return|Sharpe|STDEV|Draw-down|Co
4. short sell: borrow the stock and sell them immediately to the market, buy them back and return them in the near future.
standard deviation of the return is the most common measure of risk.

Monday, September 8, 2014

Pro Spring 3 note

Pro Spring 3
1. Using XML file can externalize all configuration from Java code, while annotations allow the
developer to define and view the DI setup from within the code. Spring also supports a mix of the two
approaches in a single ApplicationContext (the XML file configuration will override the annotation
ones).
One common approach nowadays is to define the application infrastructure (e.g., data source,
transaction manager, JMS connection factory, JMX, etc.) in XML file, while defining the DI configuration
(injectable beans and beans’ dependencies) in annotations.
2.
<context:annotation-config/>
<context:component-scan base-package="com.apress.prospring3.ch4.annotation" />
The <context:annotation-config> tag tells Spring to scan the codebase for dependency
requirements, while the <context:component-scan> tag tells Spring to scan the code for injectable beans
under the package (and all its subpackages) specified. In the <context:component-scan> tag, multiple
packages can be defined by using either a comma, a semicolon, or a space as the delimiter.
3.
you use Spring’s @Service annotation to specify that the bean
provides services that other beans may require, passing in the bean name as the parameter. When
bootstrapping Spring’s ApplicationContext with the XML configuration in Listing 4-15, Spring will seek
out those components and instantiate the beans with the specified names.
4.
Instead of the @Autowired, you can also use the @Resource(name="messageProvider") to achieve the
same result. The @Resource is one of the annotations in the JSR-250 standard that defines a common set of Java
annotations for use on both JSE and JEE platforms. Different from @Autowired, the @Resource annotation
supports the name parameter for more fine-grained DI requirements.
5.
Basically, using
@Component has the same effect as @Service. Both annotations were instructing Spring that the annotated
class is a candidate for autodetection using annotation-based configuration and classpath scanning.
However, since the InjectSimpleConfig class is storing the application configuration, rather than
providing a business service, using @Component makes more sense. Practically, @Service is a
specialization of @Component, which indicates that the annotated class is providing a business service to
other layers within the application.
6.
You may wonder why the annotation @Resource was used instead of @Autowired. It’s because the
@Autowired annotation is semantically defined in a way that it always treats arrays, collections, and maps as
sets of corresponding beans, with the target bean type derived from the declared collection value type. So, for
example, if a class has an attribute of type List<Oracle> and has the @Autowired annotation defined, Spring will
try to inject all beans of type Oracle within the current ApplicationContext into that attribute (instead of the
<util:list> declared in the configuration file), which will result in either the unexpected dependencies being
injected or Spring throwing an exception if no bean of type Oracle was defined. So, for collection type injection,
we have to explicitly instruct Spring to perform injection by specifying the bean name, which the @Resource
annotation supports.
7.
The following are the bean scopes that are supported as of version 3.1:
• Singleton: The default singleton scope.
• Prototype: A new instance will be created by Spring when requested by application.
• Request: For web application use. When using Spring MVC for web application,
beans with request scope will be instantiated for every HTTP request and then
destroyed when the request is completed.
• Session: For web application use. When using Spring MVC for web applications,
beans with session scope will be instantiated for every HTTP session and then
destroyed when the session is over.
8.
@PostConstruct/@PreDestroy. Starting from Spring 2.5, Spring also supports JSR-250 annotations to specify the
method that Spring should call if the corresponding annotation relating to the bean’s life cycle exists in
the class.
The easiest way to take advantage of this mechanism is to use the
AbstractApplicationContext’s registerShutdownHook() method. The method automatically instructs
Spring to register a shutdown hook of the underlying JVM runtime.

note on boating license

Please take note of the following age restrictions:
  • Children under 12 years of age may only operate a boat with a motor of up to 10 hp, unless accompanied and directly supervised by someone 16 years of age or older.
  • Persons 12 to 15 years of age may only operate a boat with a motor of up to 40 hp, unless accompanied and directly supervised by someone 16 years of age or older.
  • The minimum age for operating a personal watercraft (i.e., Sea-Doo®, Jet Ski®) is 16 years of ageTerms
Terms

All pleasure craft principally maintained or operated in Canada propelled by motors of 10 horsepower (7.5 kW) or greater must be licenced. 

According to the Canada Shipping Act 2001, all pleasure craft (with OR without a motor) manufactured in or imported into Canada after August 1, 1981, must be permanently marked with a Hull Identification Number (HIN).

If the ownership of a licensed pleasure craft is transferred, the former owner must sign the transfer form that is printed on the reverse side of the licence and deliver it to the new owner. The new owner will then be required to submit an application form along with the required documentation by mail to The Pleasure Craft Licensing Centre to transfer the pleasure craft licence. 

It is the responsibility of the boat operator to ensure that there are properly fitted PFDs onboard for all passengers.

For a personal flotation device to be approved in Canada, it must have a label stating that it has been approved by Transport Canada, the Canadian Coast Guard, Fisheries and Oceans Canada, or any combination of these three organizations.

PFDs differ from lifejackets in that they may not turn a wearer face-up when in the water. There is also no colour requirement for an approved PFD. in order for a lifejacket to be approved, it must be red, orange or yellow in colour, and be designed to turn the wearer face-up when in the water. 
  • Slowly lower the anchor from the bow, rather than the stern, to avoid capsizing or swamping.
  • Secure the line to a bow cleat. Never tie the line to the stern; the additional weight could bring on water.
Any anchored vessel of less than 50m (164 feet) in length must display an all-round white light where it can be best seen, between the hours of sunset and sunrise.

Boats no more than 6m in length:

  • Must carry a watertight flashlight; OR
  • Three Canadian-approved pyrotechnic distress signals (flares), other than smoke signals.
Visual signals are not required onboard any boat that is not motorized and 6m or less in length.  

Sailboards, Kiteboards, Paddleboats, Watercycles, and Sealed-Hull Sit-on-Top Kayaks:

If every person onboard the pleasure craft is wearing a properly fitted, approved PFD or lifejacket, the only required equipment is:
  • A sound signalling device; and
  • A watertight flashlight if operated at night or during periods of reduced visibility.

Human-powered vessels:

Must carry either a bailer; OR
A manual bilge pump; OR
Bilge-pumping arrangements


Thursday, September 4, 2014

Spring in action note

Spring In Action
1. In a Spring-based application, your application objects will live within the Spring con-
tainer. the container will create the objects, wire them
together, configure them, and manage their complete lifecycle from cradle to grave.
The container is at the core of the Spring Framework. Spring’s container uses
dependency injection (DI) to manage the components that make up an application.
This includes creating associations between collaborating components.
There’s no single Spring container. Spring comes with several container implementa-
tions that can be categorized into two distinct types. Bean factories (defined by the
org.springframework.beans.factory.BeanFactory interface) are the simplest of
containers, providing basic support for DI. Application contexts (defined by the
org.springframework.context.ApplicationContext interface) build on the notion
of a bean factory by providing application framework services, such as the ability to
resolve textual messages from a properties file and the ability to publish application
events to interested event listeners.
Although it’s possible to work with Spring using either bean factories or application
contexts, bean factories are often too low-level for most applications. Therefore, appli-
cation contexts are preferred over bean factories.
2.
Spring comes with several flavors of application context. The three that you’ll most
likely encounter are
 ClassPathXmlApplicationContext—Loads a context definition from an XML
file located in the classpath (including JAR files), treating context definition files as classpath
resources.
 FileSystemXmlApplicationContext—Loads a context definition from an XML
file in the file system.
 XmlWebApplicationContext—Loads context definitions from an XML file contained
within a web application.
4.
The picture on page 19

1 Spring instantiates the bean.
2 Spring injects values and bean references into the bean’s properties.
3 If the bean implements BeanNameAware, Spring passes the bean’s ID to the set-
BeanName() method.
4 If the bean implements BeanFactoryAware, Spring calls the setBeanFactory()
method, passing in the bean factory itself.
5 If the bean implements ApplicationContextAware, Spring will call the set-
ApplicationContext() method, passing in a reference to the enclosing appli-
cation context. 6 If any of the beans implement the BeanPostProcessor interface, Spring calls
their postProcessBeforeInitialization() method.
7 If any beans implement the InitializingBean interface, Spring calls their
afterPropertiesSet() method. Similarly, if the bean was declared with an
init-method, then the specified initialization method will be called.
8 If there are any beans that implement BeanPostProcessor, Spring will call their
postProcessAfterInitialization() method.
9 At this point, the bean is ready to be used by the application and will remain in
the application context until the application context is destroyed.
10 If any beans implement the DisposableBean interface, then Spring will call
their destroy() methods. Likewise, if any bean was declared with a destroy-
method, then the specified method will be called.


5.
the Spring Framework is focused on simplifying enterprise Java devel-
opment through dependency injection, aspect-oriented programming, and boiler-
plate reduction.
6.
the <bean> element has a factory-method attribute that lets you spec-
ify a static method to be invoked instead of the constructor to create an instance of a
class.
<bean id="theStage" class="com.springinaction.springidol.Stage" factory-method="getInstance" />
7.
By default, all Spring beans are singletons. When the container dispenses a bean
(either through wiring or as the result of a call to the container’s getBean() method)
it’ll always hand out the exact same instance of the bean. When declaring a <bean> in Spring, you have the option of declaring a scope for
that bean. To force Spring to produce a new bean instance each time one is needed,
you should declare the bean’s scope attribute to be prototype.
8.
Unlike true singletons, which guarantee only a single
instance of a class per classloader, Spring’s singleton beans only guarantee a single
instance of the bean definition per the application context—nothing is stopping you
from instantiating that same class in a more conventional way or even defining several
<bean> declarations that instantiate the same class.
9.
To define setup and teardown for a bean, simply declare the <bean> with init-
method and/or destroy-method parameters.
10.
<constructor-arg ref="quest"/>
<constructor-arg value="15"/>
<property name="song" value="JingleBells"/>
<property name="instrument" ref="saxophone"/>
<property name="instrument">
<bean class="org.springinaction.springidol.Saxophone"/>
</property>
list/set/map/props(both strings)
<property name="instruments">
<list>
<refbean="guitar"/>
<refbean="cymbal"/>
<refbean="harmonica"/>
</list>
</property>
<property name="instruments">
<map>
<entry key="GUITAR" value-ref="guitar"/>
<entry key="CYMBAL" value-ref="cymbal"/>
<entry key="HARMONICA value-ref="harmonica"/>
</map>
</property>
<property name="instruments">
<props>
<prop key="GUITAR">STRUMSTRUMSTRUM</prop>
<prop key="CYMBAL">CRASHCRASHCRASH</prop>
<prop key="HARMONICA">HUMHUMHUM</prop>
</props>
</property>
<propertyname="someNonNullProperty"><null/></property>
11. You’re probably rolling your eyes and thinking, “What’s this guy talking about?
What if, for some twisted reason, you want to force that property to be null?
12.
What if we want to wire properties with values that aren’t known until runtime?
<property name="count" value="#{5}"/>
The #{} markers are a clue to Spring that the content that they contain is a SpEL
expression. They could be mixed with non-SpEL values as well:
<property name="message" value="The value is #{5}"/>
Literal String values can also be expressed in SpEL with either single or double quote
marks. For example, to wire a literal String value into a bean property, we could
express it like this:
<property name="name" value="#{'Chuck'}"/>
Or if you were using single quote marks for XML attribute values, then you’d want to
use double quotes in the SpEL expression:
<property name='name' value='#{"Chuck"}'/>
you could use SpEL to wire one bean into another bean’s property by
using the bean ID as the SpEL expression:
<property name="instrument" value="#{saxophone}"/>
same as <property name="instrument" ref="saxophone"/>
<property name="song" value="#{kenny.song}"/>
Referencing a bean’s properties isn’t the
only thing you can do with a bean. You could also invoke a method.
<property name="song" value="#{songSelector.selectSong()?.toUpperCase()}"/>
<property name="multiplier" value="#{T(java.lang.Math).PI}"/>
here’s how to wire a random number (between 0 and 1) into a bean property:
<property name="randomNumber" value="#{T(java.lang.Math).random()}"/>
<property name="fullName" value="#{performer.firstName + ' ' + performer.lastName}"/>
to compare two numbers for equality, you can use the double-equal(==) operator:
<property name="equal" value="#{counter.total==100}"/>
Equals == eq
Less than < lt
Less than or equals <= le
Greater than > gt
Greater than or equals >= ge
<property name="song" value="#{kenny.song !=null?kenny.song:'Greensleeves'}"/>
<property name="validEmail" value="#{admin.email matches '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.com'}"/>

13.
 Autowiring helps reduce or even eliminate the need for <property> and
<constructor-arg> elements by letting Spring automatically figure out how
to wire bean dependencies.
 Autodiscovery takes autowiring a step further by letting Spring figure out
which classes should be configured as Spring beans, reducing the need for
the <bean> element.
14.
Spring provides four flavors of autowiring:
 byName—Attempts to match all properties of the autowired bean with beans
that have the same name (or ID) as the properties. Properties for which there’s
no matching bean will remain unwired.
 byType—Attempts to match all properties of the autowired bean with beans
whose types are assignable to the properties. Properties for which there’s no
matching bean will remain unwired.
 constructor—Tries to match up a constructor of the autowired bean with
beans whose types are assignable to the constructor arguments.
 autodetect—Attempts to apply constructor autowiring first. If that fails,
byType will be tried.
15.
<bean id="kenny"
class="com.springinaction.springidol.Instrumentalist"
autowire="byName">
<property name="song" value="JingleBells"/>
</bean>
What happens if Spring finds more
than one bean whose type is assignable to the autowired property? In such a case,
Spring isn’t going to guess which bean to autowire and will instead throw an exception.
To overcome ambiguities with autowiring by type, Spring offers two options: you
can either identify a primary candidate for autowiring or you can eliminate beans
from autowiring candidacy. But here’s the weird side of the primary attribute: it defaults to true. That means
that all autowire candidates will be primary (and thus none will be preferred). So, to
use primary, you’ll need to set it to false for all of the beans that are not the primary
choice.
default-autowire attribute to the root <beans> element
16.
Annotation wiring isn’t turned on in the Spring container by default.
The simplest way to do that is with the <context:annotation-config> element
from Spring’s context configuration namespace. <context:annotation-config> tells Spring that you intend to use annotation-based
wiring in Spring.
Spring 3 supports a few different annotations for autowiring:
 Spring’s own @Autowired annotation
 The @Inject annotation from JSR-330
 The @Resource annotation from JSR-250
Just like @Autowired, @Inject can be used to autowire properties, methods, and con-
structors. Unlike @Autowired, @Inject doesn’t have a required attribute. Therefore,
@Inject-annotated dependencies are expected to be fulfilled, failing with an excep-
tion if they’re not.
@Inject’s answer to
the @Qualifier annotation is the @Named annotation.
@Inject
@Named("guitar")
private Instrumentinstrument;
17.
When you added <context:annotation-config> to your Spring configuration, you
told Spring that you wanted it to honor a certain set of annotations in the beans that
you declared and to use those beans to guide bean wiring. Even though <context:
annotation-config> can go a long way toward eliminating most uses of <property>
and <constructor-arg> elements from your Spring configuration, you still must
explicitly declare beans using <bean>.
But Spring has another trick up its sleeve. The <context:component-scan> element
does everything that <context:annotation-config> does, plus it configures
Spring to automatically discover beans and declare them for you.
<context:component-scan
base-package="com.springinaction.springidol">
</context:component-scan>
The <context:component-scan> element works by scanning a package and all of its
subpackages, looking for classes that could be automatically registered as beans in the
Spring container. The base-package attribute tells <context:component-scan> the
package to start its scan from.
By default, <context:component-scan> looks for classes that are annotated with one
of a handful of special stereotype annotations:
 @Component—A general-purpose stereotype annotation indicating that the class
is a Spring component
 @Controller—Indicates that the class defines a Spring MVC controller
 @Repository—Indicates that the class defines a data repository
 @Service—Indicates that the class defines a service
 Any custom annotation that is itself annotated with @Component
As it turns out, <context:component-scan> is flexible with regard to how it scans for
bean candidates. By adding <context:include-filter> and/or <context:exclude-
filter> subelements to <context:component-scan>, you can tweak component-
scanning behavior to your heart’s content.
The @Configuration annotation serves as a clue to Spring that this class will contain
one or more Spring bean declarations.
18.
Because it’s based on dynamic proxies, Spring only supports
method join points. This is in contrast to some other AOP frameworks, such as AspectJ
and JBoss, which provide field and constructor join points in addition to method
pointcuts.
19.
And as of Spring 3.0, support for older versions of Java (prior to Java 5)
has been dropped—so there’s almost no reason to choose the plain JdbcTemplate
over SimpleJdbcTemplate. In light of these changes, we’ll focus solely on Simple-
JdbcTemplate in this chapter.

Thursday, August 28, 2014

Spring integration upload file

The framework is sometimes stupid.
For example, for Spring integration ftp upload, it rename the files after the upload is completed to avoid the partially written files.
The problem is that on our FTP server, we only have the permission to upload, no permission to rename on ftp server.
Under such case, it just cannot upload, it should have a mode to
String remoteFilePath = remoteDirectory + file.getName() + FileWritingMessageHandler.TEMPORARY_FILE_SUFFIX;
// write remote file first with .writing extension
session.write(fileInputStream, remoteFilePath);
fileInputStream.close();
// then rename it to its final name
session.rename(remoteFilePath, pathTo);

After some investigation, it's fixed after version 2.2.6 with use-temporary-file-name="false"

Monday, August 25, 2014

Oracle SQL*Loader does not support the sequence generation for direct loading.

Oracle SQL*Loader does not support the sequence generation for direct loading.
Under such case, the id could be added firstly on the file:
grep -n '^' file1.csv > file2.csv
sed "s/:/,/g" file2.csv > file3.csv
Then use direct load, should get the best performance.

Or use SEQUENCE(MAX,1)

If the direct load is false, then expression "seq_....nextval" could be used

Wednesday, August 20, 2014

Spring Batch in Action

1. based on Spring Batch 2.1
2. source code http://code.google.com/p/springbatch-in-action/
3. Spring Batch processes items in chunks.Chunk processing
allows streaming data instead of loading all the data in memory. By default, chunk
processing is single threaded and usually performs well.
4. If you return null from the ItemProcessor method process, processing for
that item stops and Spring Batch won’t insert the item in the database. (Filter)
5. First, the size of a chunk and the commit interval are the same thing! Second, there’s
no definitive value to choose. Our recommendation is a value between 10 and 200.
6. Spring Batch needs two infrastructure components:
■ Job repository—To store the state of jobs (finished or currently running)
■ Job launcher—To create the state of a job before launching it
7. the job repository stores job execution metadata in a database
to provide Spring Batch reliable monitoring and restart features.

Friday, August 15, 2014

Use Spring batch to load csv files into Oracle database

Use Spring batch to load csv files into Oracle database:
1. Need set the below for oracle database (to create the tables job repository needs, may check the contents in core spring batch jar)
    <jdbc:initialize-database data-source="dataSource">
 <jdbc:script location="org/springframework/batch/core/schema-drop-oracle10g.sql" />
 <jdbc:script location="org/springframework/batch/core/schema-oracle10g.sql" />
    </jdbc:initialize-database>
2. Need set <property name="isolationLevelForCreate" value="ISOLATION_READ_COMMITTED" /> so that there's no below error:
Spring Batch ORA-08177: can't serialize access for this transaction when running single job, SERIALIZED isolation level
3. May set the skip lines for csv files:
<property name="linesToSkip" value="1"/>
4. csv file location could be specified by classpath or file way:
<property name="resource" value="classpath:...">
<property name="resource" value="file:c:/...">
5. Load 2G csv files with 41 million lines, it took 221 minutes. Much slower than SQL*Loader but should be good enough for most projects

The performance for Spring Batch is about 2700/s while Oracle SQL*Loader is above 100k/s. Oracle SQL*Loader (direct path) is 40 time faster than Spring Batch.

Thursday, August 14, 2014

Integer.parseInt difference between JDK6 and JDK8

Today QA reported a bug which is actually a NumberFormatException.forInputString exception for "+2"
But when I tested it, it works perfect and when I checked the document, it stated that - and + is supported for Integer.parseInt.
After further investigation, it shows its JDK difference. My test uses JDK8 while the QA test environment is JDK6.
JDK6 does not support plus sign

Tuesday, July 22, 2014

Friends S1E2

Friends Season1_episode02 - The One with the Sonogram at the End

- For us, kissing is as important as any part.

- He's out while she's home getting the mastodon smell out of the carpet.

- I just don't wanna give them any more ammunition.

- You got a lasagna here that looks good enough..to avoid touching.

- Monica, you're scaring me. I mean, you're all chaotic and twirly, you know?

- Like I wasn't dreading tomorrow

- When did you have it last?
- Doy, right before she lost it.

- They want me to go down to this sonogram thing..

- Ross, help me with the spaghetti.

- This will sound unbelievably selfish..but did you plan to bring up the baby/lesbian thing?
It might take the heat off of me.

- Even when you were a chubby kid..

- So, Ross, what's going on with you? Any stories? No news, no little anecdotes to share with the folks?

- Well, you know, these people are pros. They know what they do.

- Must pee.

- And you can go with Carol and Susan to the ob-gyn.

- When did it get so complicated?
- Got me.

- Sorry I'm late. I got stuck at work.

- Is she familiar with our special situation?
- Yes, and she's very supportive.

- That opens my cervix.

- We agreed on Minnie.
- We agreed we'd spend our lives together. Things change. Roll with the punches.

- My maid of honor, Mindy?
- Yeah, we're kind of a thing now.

- I hope they have his hairline and your nose! That was a cheap shot, but I feel so much better now!

Friends S1E1

- There's nothing to tell. It's just some guy I work with.
- You're going out with the guy. There has to be something wrong with him.

- I don't want her to go through what I did with Carl.
Carl and Carol

- Fine, be murky.

- Why does everyone keep fixating on that?

- Did I say that out loud?

- I told Mom and Dad last night. They took it pretty well.

- and I started wondering.."Why am I doing this," and "Who am I doing it for?"

- I didn't know where to go, and I know we've drifted apart..but you're the only person I know here.
- Who wasn't invited to the wedding.
- I hoped that wouldn't be an issue.

whiskers on kittens

- Me and Chandler live across the hall. He's away a lot.

- Ross, are you okay? Do you want me to stay?
- That'd be good.
- Really?
- Go on! It's Paul, the wine guy!

- Hey, Paul, here's a tip. She really likes it when you rub her neck in the same spot..until it starts to get red.

- But I'm just going to hang out here.

- What's this?
- I would have to say that is an L-shaped bracket.
- Which goes where?
- I have no idea.
- Done with the bookcase.
- All finished.

- This was Carol's favorite beer. She always drank it out of the can. I should have known.
it isn't very hygenic.

- Know what's scary? What if there's only one woman for everybody?

- in the bonds of holy matrimony.

- If I can make coffee, there isn't anything I can't do.

- There's lots of flavors out there. Rocky road and cookie dough and bing cherry vanilla.
  You can get them with jimmies or nuts or whipped cream.
 
- I'm so sorry. Being spit on is probably not what you need right now.

- How are you doing today?
- Sleep okay?

- I take credit for Paul. Before me, there was no snap in his turtle for two years.

- I was laughed out of 12 interviews.<br>
- You're surprisingly upbeat.
- You'd be too, if you found these boots on sale 50% off.
- How well you know me.

- You can't live off your parents.
- I know that. That's why I was getting married.

I ended up living with this albino guy who was cleaning windshields. And then he killed himself. Then I found aromatherapy.

Just put it back where you found it.

I figured you thought I was Monica's geeky brother.

- Would anybody like more coffee?
- You made it, or you're serving it?
- I'm just serving it.
- I'll have a cup of coffee.

Saturday, July 19, 2014

Maven note

mvn -?
mvn -X to check the details for example which settings.xml is used
               the default user setting in Eclipse maybe wrong, check C:\Users\pengp2\.m2\settings.xml
mvn package -pl %groupId%:%artifactId% to package only one sub project
mvn archetype:generate -DinteractiveMode=true

Friday, July 11, 2014

autoit chinese encoding gbk gb2312 clipboard

Sometimes AutoIT has encode problem. For example, for the stock trade software, after open and Send("^c")
ÓªÒµ²¿¹«¸æ is returned.

Below auotit script will return the correct display even on English OS
$sCodePage=54936 ;936 GB2312
$sData = ClipGet()
MsgBox(4096, "String() representation" , _EncodingToUnicode_API($sData,$sCodePage))


Func _EncodingToUnicode_API($sString,$sCodePage_Identifier)
Local $BufferSize = StringLen($sString) * 2
Local $Buffer = DllStructCreate("byte[" & $BufferSize & "]")

Local $Return = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", _
"int", $sCodePage_Identifier, _
"int", 0, _
"str", $sString, _
"int", StringLen($sString), _
"ptr", DllStructGetPtr($Buffer), _
"int", $BufferSize)

Local $UnicodeBinary = DllStructGetData($Buffer, 1)
Local $UnicodeHex1 = StringReplace($UnicodeBinary, "0x", "")
Local $StrLen = StringLen($UnicodeHex1)
Local $UnicodeString, $UnicodeHex2, $UnicodeHex3

For $i = 1 To $StrLen Step 4
$UnicodeHex2 = StringMid($UnicodeHex1, $i, 4)
$UnicodeHex3 = StringMid($UnicodeHex2, 3, 2) & StringMid($UnicodeHex2, 1, 2)
$UnicodeString &= ChrW(Dec($UnicodeHex3))
Next
$Buffer = 0
Return $UnicodeString
EndFunc

Sunday, July 6, 2014

怀念妈妈

      已是午夜,我又想起妈妈。这些天来,恍惚中妈妈似乎从来没有离开我。跟妈妈的最后一次电话正巧录音了,一个多小时的电话里,妈妈牵挂着哥哥姐姐和我的身体,妈妈欣慰我在加拿大买房子了。妈妈说,她要从襄樊回去弄红薯苗、西红柿苗......始终难以接受,妈妈永远的走了。我永远失去了最爱我、最关心我、给了我一切的妈妈。

      多希望时光倒流,能多陪些妈妈。接到哥姐电话急匆匆赶回去的路上,我一再祈祷,祈祷上帝能再给妈妈10年的寿命,我希望能用自己10年、20年的寿命换回妈妈的寿命。赶到医院后,我见到了妈妈最后一面,但妈妈没能苏醒过来,妈妈自从上救护车后,就再也没苏醒过来。以后送妈妈去火葬场、,捧着妈妈的骨灰回家、晚上给妈妈守灵,好像躯壳已经麻木了,只想追随妈妈。也许,妈妈突然离去,对一生饱受病痛,没有享受太多生活乐趣的妈妈而言,真的是一种解脱。听村里人说,妈妈之前念叨,希望像村人一样,突然间就没了,不给子女累赘,不给自己痛苦。

      妈妈袁桂芝,生于1947年农历8月27日,逝于2014年阳历4月24日。妈妈年轻时很美丽,眉心正中还有一颗红色的痣,一直到老,妈妈的头发都乌黑发亮。妈妈曾提起,记得以前在杨集合作社买东西的时候,一个小孩看到妈妈,一边指一边喊“观音菩萨!观音菩萨!”。妈妈很小的时候就经常头痛,容易晕车,年纪大了之后,又落下腰痛、胃痛的毛病。妈妈走之前,最关心的也是哥哥、姐姐和我的身体。假如我当初学医,该有多好,说不定能治好妈妈和姐姐的头痛。

      妈妈与人无争,不管是和邻居,还是和陌生人,都是随和大度。在山里承包水库养鱼塘多年,妈妈对南来北往的熟人也好,陌生人也好,过来讨水喝的都热情接待。和邻居家的地界有纠纷了,妈妈也主动退让。和亲家母相处,连保姆都伸大拇指。妈妈到北京,虽然不会说普通话,但很快和小区的人打成一片,后来经常有人过来邀请打牌。妈妈打牌其实只是凑份子,有人在旁边观看时,妈妈往往会让给别人打一会儿。妈妈喜欢和人聊天,因为身体不好,不能起早熬夜。但这些年来跟着爸爸承包养鱼塘,经常一个人窝在山沟里,缺朋少友,担惊受怕。时不时得洗一大堆的衣服,做一大群人的饭菜,而且弄鱼的衣服往往分外脏,还得忍着头晕给爸爸找东西。妈妈做的菜很好吃,去我们家做过客的都印象深刻。syh过来看望时,还提起syp来我家做客后一直说,从来没吃过这么好吃的鱼。,妈妈做的花生米、炒仔鸡也是一绝,可惜我再也吃不到妈妈炒的菜了。之前学了几个菜,一直想赶春节回家,让妈妈也尝尝我炒的菜,妈妈你为何不等等呢?妈妈始终以最深厚的母爱关心爱护她的子女,没有丝毫的私心,全然不图分毫的回报。

      奶奶这些年来,由于眼睛看不见,年龄又大,人人嫌弃和厌烦。但妈妈对奶奶嘘寒问暖,照顾备至。妈妈说,是奶奶给了她幸福的时光,一直到30多岁分家前,妈妈都不会做饭,奶奶始终照顾多病的妈妈。妈妈说,奶奶不能动了,是自己回报奶奶的时候了。妈妈受病痛折磨,希望像村人一样突然离去的时候,最放不下心的就是奶奶。妈妈你放心,就算所有人都不照顾奶奶了,我会照顾奶奶的。虽然我不能陪在奶奶身边,但我会找人伺候奶奶的。

        爸妈经常吵架,爸爸经常喝酒,每次都喝醉,醉了就耍酒疯,赶全家人滚。有一年都快腊月三十了,爸爸又醉了发酒疯,赶全家人滚,可怜妈妈冒着漫山大雪,领着我和姐姐去山下借宿。甚至到一年前,妈妈还因为护着姐姐被爸爸赶的半夜离开家门。妈妈为了子女,为了家,受尽委屈和艰辛,妈妈始终苦苦撑着这个家。妈妈走了,那个家就散了,我的魂也没了,我的根也没了,我的依托没了。

      也许我,哥哥和姐姐希望妈妈别离开,是我们太自私了。妈妈在,大家都感觉在一起,我时时想着回家。妈妈在的时候,我们没有能给予妈妈什么,一直是妈妈无私的爱护帮助我们。妈妈以自己希望的方式走了,希望天堂里没有病痛折磨,愿妈妈永安。

Wednesday, June 25, 2014

Make the table smaller for test and restore it back

Scenario:
There's a huge table with 40 million records or more and now for test purpose need limit the records to the latest 5 days records. After the test, need
restore the table.
Resolution:
Delete would be very, very slow. It may need 24 hours or even longer. The best way is to rename the table and create the new table.

Thursday, June 12, 2014

gradle note

1.
The left shift operator << is a shortcut for the action doLast.
task helloWorld {
doLast {
println 'Hello world!'
}
}
equals to
task helloWorld << {
println 'Hello world!'
}

2.
gradle -q tasks
gradle -q tasks --all
gradle -q helloWorld -> gradle -q hW
gradle -b ... Use this option to execute a build script with a different name other then build.gradle

3.
http://www.gradle.org/docs/current/dsl/index.html
jar{
exclude('**/*.properties')
}

4.
mavenLocal()
mavenCentral()
From http://www.gradle.org/docs/current/javadoc/index.html
DependencyHandler
   //declaring arbitrary files as dependencies
   compile files('hibernate.jar', 'libs/spring.jar')

   //putting all jars from 'libs' onto compile classpath
   compile fileTree('libs')
maven { url "http://cptrasv01:8081/nexus/content/groups/public/" }
    compile group: 'com.tdsecurities.stars.mdm', name: 'midas_common', version:'1.0.1-SNAPSHOT'

5. gradle plugin application does not work for inteactive console application even the below is added into the build.gradle
run{
    standardInput = System.in
}

6. Changing the project default layout
sourceSets {
main {
java {
srcDirs = ['src']
}
}
test {
java {
srcDirs = ['test']
}
}
}
buildDir = 'out'

7.
Using the wrapper is considered best practice and should be mandatory for every Gradle
project. Gradle scripts backed by the wrapper are perfectly prepared to run as part of
automated release processes like continuous integration and delivery.

drop table

default drop table does not free the table space, while truncate table will free the table space.
The fastest way to unload and load data from/to oracle is to use some pro*c to "flatten out" the data to a flat file and sqlldr
with direct path mode to reload it. (By Tom)
My test shows that it needs 5 minutes to unload 50 millions data from the database (4G csv file)

Monday, June 2, 2014

SLF4J, logback and groovy

logback.groovy does not support
<configuration debug="true"> in logback.xml.
statusListener(OnConsoleStatusListener) may help.
Or add the below to the source:
LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);

HelloWorld.java
package log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;

public class HelloWorld {
public static void main(String[] args) {
LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);
Logger logger = LoggerFactory.getLogger(HelloWorld.class);
logger.info("Hello World!");
}
}


logback.xml

<configuration debug="true">

  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>myApp.log</file>
    <encoder>
      <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
    </encoder>
  </appender>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{yyyyMMdd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <root level="debug">
    <appender-ref ref="FILE" />
    <appender-ref ref="STDOUT" />
  </root>
  
</configuration>

logback.groovy

statusListener(OnConsoleStatusListener)

appender("FILE", FileAppender) {
  file = "myApp.log"
  encoder(PatternLayoutEncoder) {
    pattern = "%date %level [%thread] %logger{10} [%file:%line] %msg%n"
  }
}

appender("STDOUT", ConsoleAppender) {
  encoder(PatternLayoutEncoder) {
    pattern = "%d{yyyyMMdd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
  }
}

root(DEBUG, ["FILE","STDOUT"])

Sunday, June 1, 2014

The elephant and the ant

http://books.google.ca/books?id=sNF5PxD0SV4C&printsec=frontcover&dq=the+ant+and+the+elephant&hl=en&sa=X&ei=n9uLU6_wKoKe8gHZuYDwDQ&ved=0CDoQ6AEwAA#v=onepage&q=the%20ant%20and%20the%20elephant&f=false
1. Just when it seemed he would be swept downstream and gone forever, the ant grabbed onto a snag and scrambled to safety.
2. The ant remained stranded wondering what he would do, ...
3. called the ant in his wee, small voice.
4. I've had my swim for today, and besides, if I went racing about helping everyone who was in trouble I'd have no time left to relax.
5. Then the turtle tottered on his way to ...
6. Suddenly he went toppling backward and landed upside down.
7. "Blast it all, " he muttered. "Dad blame it! " And he began thrashing out with his legs.
8. As he stretched his stringy neck looking about for help, the turtle spied a hornhill roosting on her nest high on a tree limb.
9. As she leaned down to say more, the hornbill tipped the nest and her one big egg rolled out to go tumbling all the way to the ground. Luckily it landed in a clump of fluff-twuff weeds without so much as a crack.
10. Still she kept on furiously thrashing the air until her wings worn to a frazzle.
11. a giraffe came striding along
12. He flopped down with such a whump! it upset a huge boulder which was all set to topple. 
13. With a furious roar he leaped to his feet, tugging frantically to free himself.
14. he went lumbering off the trees
15. "Out of my way, you stupid stump!" He snorted. And with a furious lunge he tried to knock over the stump. This drove the horn still deeper. Then with a mighty tug he tried pulling himself free, but the stump refused to let go. At last the rhino realized he was hopelessly stuck.
16. That would have been that if a jolly big somebody hadn't decided to take a stroll through the jungle that day.
17. Then without a word of thanks the old codger went tottering away down the bank to disappear in the river.
18. The elephant didn't suspect there was a deep ravine just ahead. It was too well hidden by scatter-flat ferns.
19. He waited for hours, staring up at the sky until it faded into evening and a deep stillness settled over the jungle.

Tuesday, May 27, 2014

Java remote debug to linux

1. On linux side, no need to configure anything (For JConsole, need config iptables)
2. Compile the application with the debug options, for gradle, add the below (may use javap to verify)
compileJava.options.debugOptions.debugLevel = "source,lines,vars"
3. add -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=y to start the Java application
4. From Eclipse, create a new remote Java application in the debug configuration for the app
5. When the Java application suspends on linux (the message would like "Listening for transport dt_socket at address: 4000"), run the debug from PC eclipse
~~~ enjoy

For maven:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<debug>true</debug>
                                       <debuglevel>lines,vars,source</debuglevel>
</configuration>
</plugin>

Monday, April 14, 2014

Financial Markets with Professor Robert Shiller by YaleCourses

Return is between minus 100% to positive infinity and gross return equals 1 + return. (cannot be negative)
numerator/denominator
geometric mean and arithmetic mean (if the return is 100%, no meaning for arithmetic average)
the expected value for continuous x
variance and deviation
covariance (individual stock and index movement relationship for example)
correlation
variance of sum: var(x+y) = = var(x) + var(y) + 2cov(x,y)

We had a big financial crisis in the United States in 1987, when there was a stock market crash that was bigger than any before in one day. We will be
talking about that. But after the 1987 crash, companies started to compute a measure of the risk to their company, which is called Value at Risk.
VaR, V and R are capitalized so that to differentiate the variance.
The calculation (e.g): 5% probability to lose $10 million dollars in a year. Need the model to calculate the probability.

To do: 3. Technology and Invention in Finance

Tuesday, April 8, 2014

英语学习:Complete与finish的区別

2012年,在伦敦举行的语言大赛中,圭亚那选手Samsunder Balgobin 在回答比赛中最后一道问题"你如何用一种容易让人理解的方式解释 complete与finished 的区別"时,给出了他的答案: When you marry the right woman, you are COMPLETE. (娶对老婆,你这一生就完整了。) When you marry the wrong woman, you are FINISHED. (娶错老婆,你这一生就完蛋了。) And when the right one catches you with the wrong one, you are COMPLETELY FINISHED. (让大老婆逮到你跟小三,你就彻底地完蛋了。) 担任比赛的全世界一流的语言学家将桂冠戴在了这位选手的头上,奖品是环球游和一箱25年窖龄的朗姆酒,全场观众和评委为他起立鼓掌长达五分钟。 

From http://www.rolia.net/f/post.php?f=0&p=8693836

Sunday, April 6, 2014

Java Optimization Experience

To enable more than 1000 filter on more than 60k records with a lot of business rules, it can be spent only 2 seconds on my PC.
Use cqengine (with RadixTreeIndex and ReversedRadixTreeIndex) instead of looping collection.
For collections.removeAll, HashSet is much faster than ArrayList since HashSet contains implementation is map.containsKey(o); while ArrayList is:
    public boolean contains(Object o) {
return indexOf(o) >= 0;
    }

    /**
     * Returns the index of the first occurrence of the specified element
     * in this list, or -1 if this list does not contain the element.
     * More formally, returns the lowest index <tt>i</tt> such that
     * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
     * or -1 if there is no such index.
     */
    public int indexOf(Object o) {
if (o == null) {
   for (int i = 0; i < size; i++)
if (elementData[i]==null)
   return i;
} else {
   for (int i = 0; i < size; i++)
if (o.equals(elementData[i]))
   return i;
}
return -1;
    }

Saturday, April 5, 2014

Get the difference between two double string

import java.math.BigDecimal;
import java.math.RoundingMode;


public class DoubleDiff {

public static void main(String[] args) {
System.out.println(getDiff("3.1E-4","0.0032"));
System.out.println(getDiff("0.0031","0.0032"));
System.out.println(getDiff("0.0031","0.003"));
System.out.println(getDiff("0.0031","0.00319"));
System.out.println(getDiff("1","1.9"));
System.out.println(getDiff("2","2.1"));
System.out.println(getDiff("1","2.1"));
System.out.println(getDiff("NA","2.1"));
System.out.println(getDiff("0","Str"));
}

//may contains E/e
public static String getDiff(String acClose,String ssClose){
String result = "";
try {
BigDecimal acCloseDouble = new BigDecimal(acClose);
BigDecimal ssCloseDouble = new BigDecimal(ssClose);
if(acCloseDouble.compareTo(ssCloseDouble)==0){
result = "0";
}
else{
if(acCloseDouble.scale()==ssCloseDouble.scale()){
result = acCloseDouble.subtract(ssCloseDouble).stripTrailingZeros().toPlainString();
}
else{
int minScale = Math.min(acCloseDouble.scale(), ssCloseDouble.scale());
acCloseDouble = acCloseDouble.setScale(minScale, RoundingMode.DOWN);
ssCloseDouble = ssCloseDouble.setScale(minScale, RoundingMode.DOWN);
result = acCloseDouble.subtract(ssCloseDouble).stripTrailingZeros().toPlainString();
}
}
//stripTrailingZeros may has no impact for 0.000 because of the scale
if(result.matches("0\\.0*")){
result = "0";
}
} catch (Exception e) {
result = acClose+"-"+ssClose;
// e.printStackTrace();
}
return result;
}

}

Monday, March 31, 2014

optimization on Java application

I wrote an application to compare the instruments across many different systems. It needed 6 to 7 minutes to run at the beginning.
After the optimazation, the runtime is cut to 22 seconds. There are three methods used to optimize the application:
1. Use indexed collection (google cqengine) instead of looping the collection
It needs more than 30 seconds for 30 million loops, after the update, it only needs 1 or 2 seconds.
2. Set -Xms -Xmx to allocate more memory for this Java application.
3. At the beginning, the csv report file is saved to clob directly. Now since it's more than 10 megabytes, it needs 6 to 8 seconds to insert.
After zip/save to blob, it's less than 1 seconds including the zip time.

Wednesday, March 26, 2014

Spring in Action Third Edition

Spring in Action Third Edition
1. Source code
 www.manning.com/SpringinActionThirdEdition
2.
The act of creating associations between application components is commonly referred to as wiring.
In a Spring application, an application contextloads bean definitions and wires them
together. The Spring application context is fully responsible for the creation of and
wiring of the objects that make up the application.
In a Spring application, an application contextloads bean definitions and wires them
together. The Spring application context is fully responsible for the creation of and
wiring of the objects that make up the application.
ClassPathXmlApplicationContext.
Applying aspects
3.
Spring rich client
4.
By default, all Spring beans are singletons. When the container dispenses a bean
(either through wiring or as the result of a call to the container’s getBean()method)
it’ll always hand out the exact same instance of the bean.
<bean id="poeticDuke"
class="com.springinaction.springidol.PoeticJuggler">
<constructor-arg value="15" />
<constructor-arg ref="sonnet29" />
</bean>
<bean id="theStage"
class="com.springinaction.springidol.Stage"
factory-method="getInstance" />
<bean id="kenny"
class="com.springinaction.springidol.Instrumentalist">
<property name="song" value="Jingle Bells" />
<property name="age" value="37" />
<property name="instrument" ref="saxophone" />
</bean>
inner bean:'
<bean id="kenny"
class="com.springinaction.springidol.Instrumentalist">
<property name="song" value="Jingle Bells" />
<property name="instrument">
<bean class="org.springinaction.springidol.Saxophone" />
</property>
</bean>
To set a property to null, you simply use the <null/>element.
To force Spring to produce a new bean instance each time one is needed,
you should declare the bean’s scopeattribute to be prototype.
<bean id="ticket"
class="com.springinaction.springidol.Ticket" scope="prototype" />
The astute reader will recognize that Spring’s notion of singletons is limited to the
scope of the Spring context. Unlike true singletons, which guarantee only a single
instance of a class per classloader, Spring’s singleton beans only guarantee a single
instance of the bean definition per the application context
5.
To define setup and teardown for a bean, simply declare the <bean>with initmethodand/or destroy-methodparameters.
If many of the beans in a context definitionfile will have initialization or destroy
methods with the same name, you don’t have to declare init-methodor destroymethodon each individual bean. Instead you can take advantage of the
defaultinit-methodand default-destroy-methodattributes on the <beans>element.
6. wiring collection
<bean id="hank"
 class="com.springinaction.springidol.OneManBand"> <property name="instruments">
<list>
<ref bean="guitar" />
<ref bean="cymbal" />
<ref bean="harmonica" />
</list>
</property>
</bean>
//map
<bean id="hank" class="com.springinaction.springidol.OneManBand">
<property name="instruments">
<map>
<entry key="GUITAR" value-ref="guitar" />
<entry key="CYMBAL" value-ref="cymbal" />
<entry key="HARMONICA" value-ref="harmonica" />
</map>
</property>
</bean>
7. SpEL
<property name="song" value="#{songSelector.selectSong()?.toUpperCase()}"/>
<property name="multiplier" value="#{T(java.lang.Math).PI}"/>
<property name="validEmail" value=
"#{admin.email matches '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.com'}"/>
8.
Autowiring helps reduce or even eliminate the need for <property>and
<constructor-arg>elements by letting Spring automatically figure out how
to wire bean dependencies.
 Autodiscovery takes autowiring a step further by letting Spring figure out
which classes should be configured as Spring beans, reducing the need for
the <bean>element.
When a bean has been configured to autowire by autodetect, Spring will attempt to
autowire by constructorfirst. If a suitable constructor-to-bean match can’t be found,
then Spring will attempt to autowire by type.
9.
Annotation wiring isn’t turned on in the Spring container by default. <context:annotation-config>tells Spring that you intend to use annotation-based
wiring in Spring
10.
The <context:component-scan>element does everything that <context:annotation-config>does, plus it configures
Spring to automatically discover beans and declare them for you.
<context:component-scan
base-package="com.springinaction.springidol">
</context:component-scan>


Todo: Aspect-oriented Spring

Saturday, March 22, 2014

Oracle SQL Developer Debug



SQL> grant debug connect session to hr;

授权成功。

SQL> grant debug any procedure to hr;

授权成功。

SQL>

Sunday, March 16, 2014

Big Bang Season 1 E1

photon
integral:
differential:
renegate:
I've never renegated on a proffer of sperm before.
clavicle
transvestite
battlestar galactica
I know that moving can be stressful, and I find when I'm undergoing stress that good food and company can have a comforting effect. Also, curry is a natural laxative and I don't have to tell you that a clean colon is one less thing to worry about.
I'm no expert, but I believe in the context of a luncheon invitation, you might want to skip the reference to bowel movements.
Today we tried masturbating for money.
Well, make yourself at home.
spoof
You can find scribbled on the wall of any men's room at mit.
In the winter this seat is close enough to the radiator to remain warm, and yet not so close to cause perspiration. In the summer, it's directly in the path of a cross-breeze created by opening windows here and there.It faces the television at an angle that is neither direct, thus discouraging conversation. Not so far wide as to create a parallex distortation. I could go on, but I think I've made my point.

Saturday, March 8, 2014

一天一句话 地道美语表达 (P80 - 101)

http://forum.iask.info/showthread.php?t=339102&page=81
you and I loved to zing each other. 喜欢互相吐槽对方。
I lost you你把我弄糊涂了。
I lost you.Please start over你把我弄糊涂了。重新说一下吧。

My time is your time全听你的。也可以翻译成请你吩咐男人!学会这句!
May I have the check, please? 我能看看帐单吗

吃完饭别忘了给钱喔! check 就是账单的意思, 另外也可以说 buy the bill(买单), 就跟中文里说的买单是一样的。

切记千万不要以 penny(硬币)付小费。如果你把 penny 丢在桌上,尽管你付小费很多,很可能会被服务生误解为不满其服务,是一种羞辱的举止。除非服务实在是太差了,否则绝不可在小费中放置任何 penny。
如果你忘记看天气预报,你想知道今天多少度,该怎么问呢?
What's the temperature today? 

--- Would you prefer a window or an aisle seat? 你想要靠窗还是靠走道的座位?
----I’d like a window seat. 我想要靠窗的座位。

I’d like an aisle seat. 我想要靠走道的座位。

Could you give me a better price?
你可以给我一个实在价吗?

it's an orgasm.那是性高潮。
What does that supposed to mean?你这话是什么意思?
I can't keep it up. I'm exhausted我不能再这么下去。我累了。
I've been acting like I'm okay, but I'm not.我一直假装没事,其实不是。
You're not wearing long johns?你还没穿秋裤呢?
口语里long johns就是秋衣秋裤的意思,动词用wear

What are you!你算什么东西!
大家记住!Who are you是你是谁的意思。
What are you是
你算什么东西!意思相差很远!不要说错!

I'm zone out 我走神了
及时行乐则是to eat, drink and be merry
Your delivery 有你快递
I got a delivery this morning我今天早上收到了个快递
yucky school dinners 学校饭很难吃
Why are you still up 你怎么还没睡 我妈经常跟我说这句话!!
We had a bit of a row.我们吵架了。
have a row: 吵架 row: 大声争吵

You are enigmatic 装神弄鬼的!
enigmatic: 神秘的

I'm sleep-deprived: 睡眠不足
This is karma报应呀,这就是报应!
Everyone has a little dirty laundry每个人都有一些脏衣服的含意是每个人都有不可告人的秘密
相当于“Everyone has a skeleton in his closet”。

You rock 你真牛b或You're really something!你真牛b
Prices are running wild all over the country.全国的物价都在暴涨
Electricity has gone up 电费也涨了

She is a carbon copy of her sister.她跟她姐姐长得一模一样carbon copy以表示“极相像的人;极类似的事”
You're blowing this out of proportion.你小题大作了。
roll right off one's tongue 舌头上滚下来-----顺口
trip over one's own tongue 打磕巴,trip除了“旅行”还有“绊倒”的意思
拗口的东西则是“a tongue twister”(不仅仅是绕口令啊~)

大众情人是“Lady killer” (女性杀手啊~~~)
Every girl dreamt of dating him in college. He's such a lady killer!
有些大众情人仗着自己长得帅,脾气古怪,很难伺候,那么难伺候怎么说呢?
High maintenance 就是难伺候的意思
比如说 My boss is a high-maintenance guy! He's constantly complaining.


菜鸟的英语是newbie/ˈnubi/
菜鸟通常需要别人的指点,别人的指点比较地道的说法是:pointers
例如,I need someone to give me a few pointers on how to find the coolest iPhone apps.
而对于要提供帮助的人来说,可以这么回答: I can show you the ropes.
为什么用"rope"这个词呢?因为在很久以前,新水手必须掌握的技能就是如何操控绳子,这个词用法渐渐被扩大了,show sb. the ropes就是教导新手做某件事情的意思。


夜猫子是“night owl”,owl是猫头鹰的意思
既然提到了夜猫子,不如把和睡觉有关的词都告诉大家吧~~
睡觉这个词,其实也是有口语表达的,叫“hit the hay”,“hay“是“稻草、干草”的意思
light sleeper是睡觉轻的人,与之相反,睡觉比较“死”的人是sound sleeper


awesome adj. 令人敬畏的; 使人畏惧的; 可怕的; 极好的
这个词可以用来表达“牛”的意思,You're awesome就是“你太牛了”
另外,你还可以说"you rule" or "you rock",表达的意思相同,只不过"rule"和"rock"是动词。
如果形容“牛气哄哄”的人(贬义),可以用cocky


国外一般将大龄女青年称为3S lady,也就是Single(单身)、Seventies (大多数生于上世纪七十年代)、Stuck(被卡住了,即在寻找伴侣的路上被卡住了)。也有人用SAS来形容“黄金剩女”,即single(单身)、attractive(迷人),successful(成功)。
除此之外,on the shelf这个短语也可以表示女子过了适婚年龄依然未能嫁出去的状态。
例如:Why is the hello girl still on the shelf? (为什么这个女接线员还没嫁出去?)
即将被“剩”下的男女,也有一个称号---doomed single必剩客)


如果你打算和朋友去旅游,把东西都打包装好后,可以说“Everything is in the bag.Let's set off!"意思是一切都搞定了,我们出发吧!

Let's play it by ear! 意思是看情况而定。
play it by ear原指人不用乐谱,仅凭记忆就可弹奏乐曲,引申为“没有计划,依据当时的情况而定。


"真笨!"英文怎么说 
Bill: I ran into a glass door yesterday.
比尔 :我昨天撞到玻璃门上了。
Mary : What a bone head! Be careful next time.
玛丽 :真笨,下次小心点。
"What a bone head’‘ 就是形容某人真笨的意思,bone head字面 为“骨头脑袋“,引申为”没有脑筋的人,笨蛋”,例如:She is a bone head.她是个笨蛋。


跟某人一般见识就是 stoop down to one's level.
stoop n. 门廊,游廊; 自贬; 弯腰
vt.& vi. 屈服,忍辱; 弯腰; 倾斜; 自贬
给大家举个例子:We would only be stooping down to his level if we returned the insult.
如果我们用粗鲁的语言回敬他的话,那么我们把自己降低到和他一样的水平了。


It takes two people.一个巴掌拍不响。

Don’t chicken out! 别做胆小鬼!
chicken除了“鸡”的意思,也指“胆小如鼠的人”,chicken out指“因为胆小而落跑”。以后遇到这样的胆小鬼,记得对他说:“Don’t chicken out!”

Lunch is on me. 
午饭我请客。


小心眼儿可以用petty adj. 不重要的; 卑鄙的,小气的;
比如说这句话:you don't know how petty she is!
就是 “你都不知道她是有多小心眼!”的意思。
hold a grudge against sb.是记仇的意思,
Get over it 就是“不再计较”的意思。


He is an alpha male.他是男人中的男人。
alpha male:alpha是希腊字母的第一个字母,即居统治地位的,占主导地位的男性。He is an alpha mal也就是 纯爷们


电灯泡是the third wheel,可别直译成light bulb啊!
说完了电灯泡,就不得不说这个词组了:love birds.指的是那些特别爱在大众面前秀恩爱的情侣(本人表示很反感~~)
例如,I don't want to be the third wheel and bother the love birds!


I'm about to burst!: 我快憋不住了!
这句话用憋不住尿或屎上


That's a girl/boy: 真乖。 对对方亲昵的称呼。

到现在,美国仍十分流行一种表示“上厕所”的说法,那就是to answer the call of nature
所以I need to answer the call of nature.就是“我想去厕所”的意思,我们还可以简短地说nature calls
nature这个单词用来隐喻不便直言的身体功能或部位


I‘m starving! 我饿死了!
Tummy is grumbling 肚子饿的咕咕叫
Grab a bite 随便吃点东西
I’ll go to the mall and grab a bite.


AA制 Go Dutch
a:How about we just go Dutch? 我们AA制好吗?
b:It's settled. 就这么说定了.
a:That makes so much more sense.这还差不多!


Pro 高手, 牛人, 行家
Jonathan makes these wonderful pancakes . He is such a pro at cooking.(pancake是煎饼的意思~)
Hotshot 既有胆量又有能力的人
Jeremy Lin is definitely a hotshot basketball player!
Big deal 大人物
Big leagues 某领域的最高级别
My friend David is kind of a big deal now.He recently got accepted to Harvard .He is going to the big leagues now.


Lucy : Waiter, come here please. Could we have a doggie bag?
露西:服务员,过来一下,请问我们可以将这些剩菜打包吗? 

Waiter : Sure. Wait a moment.
服务员 ::当然可以,等一下

doggie bag和小狗有什么关系呢?
在西方国家,人们去饭店总会有饭菜吃不完的时候,扔了觉得浪费,想打包回家又有些碍于面子,所以人们常会说:“把菜装起来,我拿回家给小狗吃”。实际上小狗是享受不到美味的,久而久之,这种装剩菜的袋子就被称为doggie bag。


She sulked again. 她又在生闷气了

眼屎:sleepies ; eye gunk
I always have sleepies in the corner of my eye when I wake up in the morning.
耳屎:earwax
I use Q-tips to get the earwax out of my ears.(PS:Q-tips是棉签)
鼻屎:Booger
如果某个人很烦人,你也可以说“You are such a booger ”


I have a weakness for sth.” 这句话很容易引起歧义。
它的不是说“不喜欢某物”,而是“对什么东西抵抗力弱”,也就是表示“十分喜爱,禁不住诱惑”的意思。
因此,“I have a weakness for coffee.” 不是说不喜欢咖啡,而是说我抵挡不住咖啡的诱惑,表明“我酷爱咖啡”。


今天冷死啦!
It's freaking cold today!


1)I've missed my period.我大姨妈没来。

  2)I’m having my period./I'm on my period. 我现在是月经期。

  3)My period is over.我月经期结束了。

  4)I just had my period yesterday.我昨天刚来月经。

  5)My aunt Flo is visiting. 我的大姨妈来了。

  6)My period was 2 days late/early. 我大姨妈推迟(提前)了两天。

  Gentlemen, please do not piss your women off during their period. It's quite dangerous!


喝汤是“Eat soup”,而不是“Drink soup”
汉语的“喝稀饭”也不要译成drink porridge,应译成eat porridge(吃稀饭)。小孩“吃奶”不能译成eat milk,而应译为suck the breast(吸乳)。“喝奶”可以译成drink milk。

I was twice married 我结过两次婚

I fed up with learning English 英语我是学腻了
Fed up with 极厌恶 后面可以加人或者事情 对什么人或者事情很厌恶的时候,就可以这么说


My stomach is growing.我肚子开始咕咕叫了.

What a bummer 杯具了
A bummer就是坏消息的意思~ 


中国国航的表达是 Air China,可不要说成 china airlines,后者是台湾的中华航空

It was a wildgoose chase.白费了半天劲
a wildgoose chase:野鹅性野, 行踪不定, 人们很难捕获, 故wildgoose chase 指“徒劳之举”, “白费力气的追逐”。


强迫症; 有强迫症的人 OCD=obsessive-conpulsive disorder
例如:
David Backham is an OCD.If he has 3 sodas, he has to throw one away.Because the number of sodas must be even. So OCD!
小贝有强迫症。如果他有三罐饮料,他就必须扔掉一罐,因为饮料必须是双数才可以。真是有强迫症啊