#English Club#第八期——Daily Life in US: Use the ATM

A funny story....

Finally you arrived in US after a long trip. But you found you didn’t have any cash, fortunately you saw an ATM……

长途跋涉终于到了米国,可是却发现自己没带现金,好在附近有个ATM机。。。。。。

 

Dialogue---Using the ATM

A: Stupid girl, making me spend so much money, now I have to get it from the ATM...

B: Hello, welcome to Universal Bank. Please insert your card into the slot.

A: I know where to put my card! Stupid machine, talking to me like I’m an idiot...

B: Please input your 6 digit PIN code followed by the pound key. Thank you. Please select an option. Thank you. You have selected withdrawal.

A: Yeah, yeah, I know what I selected. Just gimme my money!

B: Please type the amount you would like to withdraw. Thank you, you want to transfer 10000 USD to the World Wildlife Foundation. If this is correct please press 1.

A: No, no! Stupid machine, what are you doing! No!

B: Confirmed. Thank you for using our bank! Please remove your card from the slot. Goodbye!

C: Danger, danger! The exits have been sealed and the doors will remain locked in until the local authorities arrive. Thank you for using our bank. Have a nice day.

A: No!

Vocabulary Preview

ATM=Automatic teller machine, it also can be called money machine/bank machine/cash machine;

local authorities   一般指警察;

gimme=give it to me; 类似的词有lemme=let me  这些是口语中连读的书写形式。

Language take-away

1. slot 方形的卡槽,信箱口等等, a slot 肯定不是圆形的;

2. PIN code 数字类型的密码, password 一般指字母类型的密码;

3. the pound key  井号键; the star key星号键

4. to withdraw 取款     withdraw 是动词,名词形式是 withdrawal ; a withdrawal ;

5. transfer 转账    动词名词都是这个形式

6. use our bank 文中是说“谢谢使用”  如果要表达自己所持的是中国银行的卡时,可说I use China Bank.

Posted in 英语学习 | Comments Off

Java为何要用多线程?

多线程在Java中是非常基本的一个特性,没有哪个Java程序员会不知道多线程,但当我们被问到“为什么要用多线程?”、“多线程的有什么好处?”之类的问题时,其中我们很多都会犯错,简短的回答"提高性能",这显然不能让提问者满意。虽然只是一个基本常识,总结一下还是很有必要的。在别人问起的时候,我们也能交上相对满意的答案。

使用Java Thread有两个原因:

  1. 提高程序的性能,充分的利用计算机的处理能力,因为一个任务由很多步骤组成的,数据的读取,数据的运算,数据写入,涉及到磁盘或者网络的I\O,CPU的运算等等,若是串行,只有等一个完成之后才能进行下一个,读取数据的时候,CPU是空闲着的,数据运算的时,磁盘I\O又会闲着。多线程序就是为了充分利用硬件的处理能力,尽量让硬件不闲着。第一个线程已经加载完数据在运算的时,第二个线程可以预先加载数据,待第一个线程运算完之后,第二线程就立即投入运算。现在多处理器的计算机已经普及,单一线程无法得到多处理器的好处。
  2. 异步的需要,更好的用户体验。GUI应用中非常广泛,比如加载一张高像素的图片需要一定的时间,通常的做法都是加载图片的时候,显示一张正在loading的图标。若是单线程串行处理,用户点击加载图片的button之后,界面一直的定在那里,用户肯定会误以为系统已经死了。

Note:可能还有其他的原因,暂时就想到两个

Posted in Java Thread, 编程开发 | Comments Off

#JSF#JSF页面传参数到后台bean的四种方式

据我所知,总共有四种方法可以把JSF页面的参数传到后台Bean:

  • Method expression (JSF 2.0)
  • f:param
  • f:attribute
  • f:setPropertyActionListener
我们一个一个的来看例子

1. Method expression

JSF 2.0后的版本允许你通过方法表达式(Method expression)的方式来传参数,像这样{bean.method(param)}.

JSF page…

<h:commandButton action="#{user.editAction(delete)}" />

Backing bean…

@ManagedBean(name="user")
@SessionScoped
public class UserBean{

	public String editAction(String id) {
	  //id = "delete"
	}

}

2. f:param

用f:param标签传参数,backing bean通过request parameter获取传过来的参数。

JSF page…

<h:commandButton action="#{user.editAction}">
	<f:param name="action" value="delete" />
</h:commandButton>

Backing bean…

@ManagedBean(name="user")
@SessionScoped
public class UserBean{

	public String editAction() {

	  Map<String,String> params =
                FacesContext.getExternalContext().getRequestParameterMap();
	  String action = params.get("action");
          //...

	}

}

 

3. f:atribute

用f:atribute标签,后台通过action listener获取.

JSF page…

<h:commandButton action="#{user.editAction}" actionListener="#{user.attrListener}">
	<f:attribute name="action" value="delete" />
</h:commandButton>

Backing bean…

@ManagedBean(name="user")
@SessionScoped
public class UserBean{

  String action;

  //action listener event
  public void attrListener(ActionEvent event){

	action = (String)event.getComponent().getAttributes().get("action");

  }

  public String editAction() {
	//...
  }	

}

4. f:setPropertyActionListener

 

通过f:setPropertyActionListener标签传参数,它会直接把参数值设置到backing bean对应的属性。

JSF page…

<h:commandButton action="#{user.editAction}" >
    <f:setPropertyActionListener target="#{user.action}" value="delete" />
</h:commandButton>

Backing bean…

@ManagedBean(name="user")
@SessionScoped
public class UserBean{

	public String action;

	public void setAction(String action) {
		this.action = action;
	}

	public String editAction() {
	   //now action property contains "delete"
	}	

}
Posted in 编程开发 | Comments Off

#Mercurial#Mercurial里的术语

Revision

在使用 Mercurial 的系统中每个改动隔离在各自的 repository 里,既避免把不相关的代码混杂起来, 又便于一个接一个的测试每一部分工作,用户做的每个改动称为一个 revision。一般会有一个所有用户都可以访问得到的 repository 保存了项目的“主要”版本,工作repository 是用户自己做事情的地方,实现新的特性,修改漏洞,重构,实验等,当完成改变后,你可以 push 到共用的 repositor y中,即完成了一个 revision。

Changeset

一个或多个文件的改变集合在一起形成一个逻辑单元,称为 changeset。每一个 changeset由两部分内容描述,版本号和 changeset 标识,例如:

	changeset:   207:58e4906e69e3

 

冒号前面的数字代表版本号,它用来标识本地 changeset。这个版本号只有在用户的本地repository 中才有意义。冒号后面的那个很长的十六进制串是 changeset标识, 它是确定changeset的全局唯一标识符, 在所有包含这个 changese 的 repository 中都相同。多个用户之间讨论changeset,一般使用这个 changeset 标识,而不是上面说的版本号,因为完全有可能每个用户的 repository 中同样的 changeset 版本号不同。

Head

Head 表示 repository 中每个分支最新的 revision,通常在合并几个分支时会用到这个概念。

Tip

Tip 是最新的一个 changeset 的版本号的一个别名。在命令中任何使用版本号的地方都可以使用 tip 来代替最新的 changeset的版本号。Tip在各个repository中是不同的,同时一个repository 中只有一个 tip。

Log

Log 命令按时间顺序从近到远的记录着在 repository 中发生的每一次事件。可以通过指定-v诊断输出选项来获得更多更详细的历史信息,或者指定—debug选项来获得历史信息中的一切细节。

 

参考网站:http://www.ibm.com/developerworks/cn/opensource/os-cn-mercurial/

Posted in 编程开发 | Comments Off

#Mercurial#Mercurial简介

Mercurial是一个免费的,分布式的源代码控制管理工具,它提供了直观的界面使你能有效地处理任何规模的项目,易于使用,健壮性好,是版本控制工具的理想选择。

分布式架构

传统的版本控制系统,如SVN就是典型的client-server架构,只有一个中心版本库存储项目的版本历史。相比而言,Mercurial是完全分布式的,每一位开发者都有一份完整的包含所有版本历史的本地副本。这种方式使你的工作跟中心版本库独立开来,甚至可以离线进行管理,只需在有网络连接时同步。提交,打分支和合并都变得快速和廉价。

快速的

Mercurial的实现方式和数据结构的设计都融合了轻便,快速的理念。几秒之内生成两个版本之间的差异信息,或者回归到一个指定的历史版本。 故此,Mercurial非常适合大型项目,如OpenJDK,NetBeans。

平台独立

Mercurial的开发者编写代码的时候至始至终都考虑到平台的独立性。Mercurial的绝大部分功能都是用Python语言实现的,为了更好的性能,一小部分功能是用可移植的C语言编写。所以Mercurial的二进制发布版本在主流的平台上都能使用。

可扩展的

Mercurial支持通过扩展来新增功能,激活Mercurial已经绑带的扩展功能,或者从wiki上下载扩展包或者自己编写新功能。扩展功能是用Python语言编写,可以改变Mercurial原有命令的功能,新增新的命令,或者调用它的核心模块里的功能。

易于使用

Mercurial的命名集跟其他版本控制软件基本一致,若熟悉其他版本控制,就能轻易的上手Mercurial。一些危险,较复杂的功能是扩展包里实现的,默认是关闭着的,需要你手动打开。但Mercurial基本功能易于学习。 官方Quick Start 让你几分钟就能上手.

开源的

Mercurial是免费软件, 许可遵照GNU General Public License Version 2协议.

 类似的工具

Mercurial用于管理文件的版本历史。相似的软件有Git and Bazaar。 非分布式的版本控制工具有 SubversionCVS.

 

原文地址:http://mercurial.selenic.com/about/

Posted in 开源软件, 编程开发 | Comments Off

#小技巧#MySql命令行导入sql

先创建database:create database lportal

C:\Users\administrator>mysql -uroot -proot lportal < C:\Users\administrator\Desktop\lportal.sql

其中lportal是database name;
C:\Users\administrator\Desktop\lportal.sql是要导入的Sql,文件路径无须手输,选中sql文件用鼠标拖到命令行窗口。

Posted in 编程开发 | Comments Off

#agile#敏捷修炼之道

下面一句话是对敏捷的精辟概况。

敏捷开发就是在一个高度协作的环境中,不断的使用反馈进行自我调整和完整。

 
首先,它要整个团队一起努力。敏捷团队往往是一个小型团队,或者是大团队分成若干小团队(10人左右)。团队所有成员都在一起工作,如果可能,最好有独立的工作空间,一起共享代码和必要的开发任务,而且大部分时间都在一起工作。同时和客户或者软件的用户紧密工作在一起,并且尽可能频繁地给他们演示最新的系统。

你要不断从自己写的代码中得到反馈,并且使用自动化工具不断的构建(持续集成)和测试系统。在前进的过程中,你都会有意识地修改一些代码:在功能不变的情况下,重新设计部分代码,改善代码的质量。这就是所谓的Refactor,它是软件开发中不可或缺的一部分--编码永远没有真正意义的上的“结束”。

要以迭代的方式进行工作:确定一小块时间(一周左右)的计划,然后按时完成它们。给客户演示每个迭代的工作成果,及时得到它们的反馈(这样可保证方向正确),并且根据实际情况尽可能频繁的发布新系统版本让用户使用。

Posted in agile, 编程开发 | Comments Off

#Agile#敏捷开发宣言

我们正通过亲身实践和帮助他人实践,揭示了一些更好的软件开发方法,通过这项工作我们认为:

  • 个体和交互胜过过程和工具。
  • 可工作的软件胜过面面俱到的文档。
  • 客户协作胜过合同谈判。
  • 响应变化胜过遵循计划。

虽然右项也有价值,但我们认为左项具有更大的价值。

更多详细信息可以访问agilemanifesto.org

Posted in agile, 编程开发 | Comments Off

#English Club#第四期——At the airport

大家经常在机场出入,行李的重量,能带什么不能带什么应该是大家考虑的最多的问题。今天我们来看看机场发生了什么事。
Dialogue----At the airport
A: Next please! Hello sir, may I see your passport please?

B: Yes, here you go.

A: Will you be checking any bags.

B: Yes, I’d like to check three pieces.

A: I’m sorry, sir. Airline policy allows only two pieces of checked luggage, at twenty kilograms each, plus one piece of carry-on luggage. I will have to charge you extra for the additional suitcase.

B: What? Why! I am taking an intercontinental flight! I’m flying sixteen thousand KMs! How am I supposed to only take two, twenty kilo bags? That’s absurd!

A: I am sorry, sir, there’s nothing I can do. You cannot board the flight with that large bag either. Carry-on bags must fit in the over-head compartment or under your seat. That bag is clearly too big.

B: Now I see. You charge next to nothing for an international ticket, but when it comes to charging for any other small thing, you charge an arm and a leg! So tell me, miss, how much will I have to pay for all of this.

A: Let’s see... six hundred and twenty-five US dollars.

B: That’s more than my round-trip ticket!

Language take-away
1. 3 pieces of luggage, luggage(non-countable), so “2 luggages” is wrong ;

2. Carry-on luggage 可以带上飞机的行李

3. board the ship/train/flight, but “board a car” is wrong

4. intercontinental 洲际的

5. over-head compartment 座位上方放行李的地方

Put it together
1. How am I supposed to do……. = How can I do……. = How was it possible for me to do …… 是一种不太礼貌的表达方式,当有人让你做一些不太靠谱的事情时,可以用这个句式来表达抱怨或反驳。

2. There’s nothing I can do 当有人要求你用一种违反规定的solution来解决问题时,可以用, 同样也是一种不太友好的表达方式。一般前面会加“I’m really sorry, but……”

3. You charge next to nothing /It cost(s) next to nothing 东西很便宜(一般现在时要加S,过去时不用)。 例:这些苹果很便宜 These apples cost next to nothing.

4. You charge an arm and a leg/It cost(s) an arm and a leg 东西很贵(一般现在时要加S,过去时不用)。 例:这些苹果很贵 These apples cost an arm and a leg.
Next to nothing 和an arm and a leg 这两个词组在句子中当做一个整体。

5. Round-trip tickets 双程机票

6. Here you go. 给你。 在表达“给你”这个意思时, 第一反应我们会说 “Here you are”. 这里Here you go 是同义的。

Posted in 英语学习 | 2 Comments

#English Club#Proper sentences for E-mail Writing Part I

1. Initiate a meeting 发起会议I would like to hold a meeting in the afternoon about our development planning for the project A。

今天下午我建议我们就A项目的发展计划开会讨论一下。

I suggest we have a call tonight at 9:30pm (China Time) with you and Brown. Please let me know if the time is okay for you and Ben。

我建议我们今晚九点半和Brown小聚一下,你和Ben有没有空?

We’d like to have the meeting on Thu Oct 30. Same time。

十月三十号(周四),老时间,开会。

Let’s make a meeting next Monday at 5:30 PM SLC time。

下周一盐湖城时区下午五点半开会。

I want to talk to you over the phone regarding issues about report development and the XX project。

我想跟你电话讨论下报告进展和XXX项目的情况。

 

 
2. Seeking for more information/feedbacks/suggestions 咨询信息/反馈/建议Shall you have any problem accessing the folders, please let me know。

如果存取文件有任何问题请和我联系。

Thank you and look forward to having your opinion on the estimation and schedule。

谢谢你,希望能听到更多你对评估和日程计划的建议。

Look forward to your feedbacks and suggestions soon。 期待您的反馈建议!

What is your opinion on the schedule and next steps we proposed?

你对计划方面有什么想法?下一步我们应该怎么做?

What do you think about this? 这个你怎么想?

Feel free to give your comments。 请随意提出您的建议。

Any question, please don’t hesitate to let me know。 有任何问题,欢迎和我们联系。

Any question, please let me know。 有任何问题,欢迎和我们联系。

Please contact me if you have any questions。 有任何问题,欢迎和我们联系。

Your comments and suggestions are welcome! 欢迎您的评论和建议!

Please let me know what you think? 欢迎您的评论和建议!

Do you have any idea about this? 对于这个您有什么建议吗?

It would be nice if you could provide a bit more information on the user’s behavior。

您若是能够就用户行为方面提供更多的信息就太感激了!

At your convenience, I would really appreciate you looking into this matter/issue。

如果可以,我希望你能负责这件事情。

 

 
3. Give feedback 意见反馈Please see comments below。 请看下面的评论。

My answers are in blue below。 我的回答已标蓝。

I add some comments to the document for your reference。

我就文档添加了一些备注,仅供参考。

 

 
4. Attachment 附件I enclose the evaluation report for your reference。我附加了评估报告供您阅读。

Please check the attached file for today’s meeting notes。 今天的会议记录在附件里查收。

The attachment is the design document, please review it。 设计文档在附件里,请评阅。

For other known issues related to individual features, please see attached release notes。

其他个人特征方面的信息请见附件。

 

 
5. Point listing 列表Today we would like to finish following tasks by the end of today: 1…….2……。

今天我们要完成的任务:1…….2……。

Some known issues in this release: 1…….2……。

声明中涉及的一些问题:1…….2……。

Our team here reviewed the newest SCM policy and has following concerns: 1…….2……。

我们阅读了最新的供应链管理政策,做出如下考虑:1…….2……。

Here are some more questions/issues for your team: 1…….2……。

以下是对你们团队的一些问题:1…….2……。

The current status is as following: 1……2……

目前数据如下:1……2……

Some items need your attention: 1…….2……。

以下方面需提请注意:1…….2……。

 

Posted in 英语学习 | Comments Off