Mock SMTP server / email service

November 1st, 2012 by admin No comments »

SubEtha SMTP is a Java library which allows your application to receive SMTP mail with a simple, easy-to-understand API. I use it as Mock SMTP server for CI (Continuous Integration) in a Spring project.

This is applicationContext-email.xml:

<!-- In order to not port clash set port 0 so JVM will bind to any free port then refer to the resolver port -->
<bean id="mockSMTPServer" class="org.subethamail.wiser.Wiser" init-method="start" destroy-method="stop">
    <property name="port" value="0" />
</bean>

<bean id="mailSender" class="org.springframework.beans.factory.config.BeanReferenceFactoryBean">
    <property name="targetBeanName" value="mailSender${mail.smtp.service}" />
</bean>

<bean id="mailSenderImpl" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="${mail.host}" />
</bean>

<bean id="mailSenderMock" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="#{mockSMTPServer.server.hostName}" />
    <property name="port" value="#{mockSMTPServer.server.port}" />
</bean>

In applicationContext.xml set to Impl (Spring email service implementation) or Mock (mocked email service):

mail.smtp.service=[Impl|Mock]

» Read more: Mock SMTP server / email service

A Really Simple Explanation of What QE (Quantitative easing) Is

October 29th, 2012 by Terrence Miao No comments »

An American borrowed one million U.S. dollars from bank to build a house. After all the borrowed money spent and house finished then this American found he couldn't repay the loan. He run away to Bahamas and left the newly built house to the bank.

The bank had the repossessed house which didn't want. The bank wanted one million dollars back. Writing off one million dollars from the book made hard for the bank to make more loans. Money market became frozen.

Now U.S. Federal Reserve came to help.

Fed Reserve started printer machine, printed one million dollars and gave newly printed money to the bank. So the bank could lend again. Frozen currency market got easing.

Fed Reseve added one million dollars liability because new money, to balance this Fed Reserve sold one million dollars mortgage backed security as low yield sovereign debt to government bond investors.

The result was one million dollars asset added into American property market; the bank had the loan paid back and could continue lending; Fed Reserve provided urgently necessary liquidity to the market; and bond investors got screwed …
 

Google+: View post on Google+

The origin of money

October 28th, 2012 by Terrence Miao 1 comment »

Money fulfills three main functions. First, it must be a medium of exchange, easily traded for goods and services. Second, it must be a store of value, so that it can be saved and used for consumption in the future. Third, it must be a unit of account, a useful measuring-stick.

Some argue that money has its roots in the power of the state. Others claim the origin of money is a purely private matter: it would exist even if governments did not. And It was state intervention, not the private market, that made precious metals work as money.

Read more: http://www.economist.com/node/21560554

Google+: View post on Google+

Most Sacred Heart of Uncle Bob help me to trust you

October 28th, 2012 by Terrence Miao 3 comments »

 More today than I did yesterday.

Originally shared by Deano +Dean Budd 

Read more: http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html

Google+: View post on Google+

Computer controlled high frequency trading (HFT) Down Under

October 28th, 2012 by Terrence Miao 6 comments »

HFT may be behind a spike in the price of major stocks including ANZ Bank when the Australian Securities Exchange opened on Oct 18, 2012

ANZ, Ansell, Aristocrat and AGL were among stocks that leapt in value in the first minute of trading before settling back nearer to last trading day's closing prices.

ANZ jumped $1.67, or 6.5 per cent, to $27.63, when the market opened before falling back to around $26.15.

Patersons Securities Lew Fellowes said the anomaly was likely due to a "black box trading program" – a high-frequency, algorithmic trading system that had gone awry.

Reflecting the US stock market flash crash on May 6 2010 and recent India stock exchange flash crash briefly erases US$58-billion on Oct 5 2012 that in 15 minutes after the 50-stock gauge tumbled as much as 16%.

Question is asked whether HFT is saint or devil?

Read more: http://www.theage.com.au/business/highfrequency-trading-rewriting-the-rule-book-20121026-28azm.html

» Read more: Computer controlled high frequency trading (HFT) Down Under

Small invention in your daily life (you don't have to patent everything like…

October 27th, 2012 by Terrence Miao No comments »

Small invention in your daily life (you don't have to patent everything like Apple did) but full of creativeness.

Shout out original shared by Mr. Pie. +Michael Poloni  

Read more: http://shialabeowulf.tumblr.com/post/33670447154/99-life-hacks-to-make-your-life-easier

» Read more: Small invention in your daily life (you don't have to patent everything like…

Spring MVC thread safe distilled

October 26th, 2012 by Terrence Miao 10 comments »

I come across this question when a controller in Spring MVC which scope is Singleton, is it thread safe?

The answer is NO.

According to java concurrency thread safety is that the shared data, like instance variables and can be modified, then the Singleton Spring MVC controller has the instance variables, or injected autowired Spring bean isn't 100% thread safe. But when member variables, inside the method body, then they are thread safe and no need for synchronised.

Now come along some goodies of the best practice of playing thread safety in Spring by following these simple rules:

1. Don’t use states on Controllers, Service Layer Objects and DAOs
2. If you can’t avoid, first rethink your design, unless you have to use synchronized
3. If you want to use prototype scoped beans, be aware of instance explosion

Google+: View post on Google+

General Melchett: "Performance isn't a dirty word, Blackadder

October 26th, 2012 by Terrence Miao 5 comments »

Accountability is a dirty word, but performance isn't."

If you have never experienced performance tuning and testing, you should quit your I.T. job and work in a pet shop instead. If you know how to run LoadRunner (not Lode Runner, not the game), you are definitely a "qualified" and over-rated consultant who could demand big money but only make mealy mouthful work. If you know something beyond like JMeter and Grinder but not everything else, you are either too old or already out of fashion.

Introduce Gatling, a new stress testing tool with a different dimension.

• It uses concise and elegant script language to write BDD style testing scenarios, actually it's Scala.
• It uses actors and async IO patterns, asynchronous parallel computing, far more efficience than one-thread-per-user design.
• It gives more accurate results with far less memory and CPU usage.

Embedded Link

Gatling Project – Stress Tool
About. Gatling is an Open Source Stress Tool with: High performances · Simple concepts · A DSL to describe scenarios · HTTP support · A scenario recorder · Meaningful reports. Download. 10/15/2012: Ga…
» Read more: General Melchett: "Performance isn't a dirty word, Blackadder