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.