Monday, April 29, 2019

好的句子

1.
我生命里最大的突破之一,就是我不再为别人对我的看法而担忧。此后,我真的能自由地去做我认为对自己最好的事。只有在我们不需要外来的赞许时,才会变得自由。—— 罗伊·马丁纳
2.
“今天不想跑,所以才去跑,这才是长距离跑者的思维方式。”——村上春树
3.
我们的眼睛就是我们的监狱,我们的眼光所到之处就是我们监狱的围墙。——尼采
Our eyes are our prisons, and the sight of our eyes is the wall of the prison.
4.
“我所有的自负都来自我的自卑,所有的英雄气概都来自于我内心的软弱,所有的振振有词都因为心中满是怀疑。我假装无情,其实是痛恨自己的深情。我以为人生的意义在于四处游荡流亡,其实只是掩饰至今没有找到愿意驻足的地方。”----卡尔维诺《看不见的城市》
5.
我慢慢明白了我为什么不快乐,因为我总是期待一个结果。看一本书期待它让我变深刻,吃饭游泳期待它让我一斤斤瘦下来,发一条短信期待它被回复,对人好期待它回应也好,写一个故事说一个心情期待它被关注被安慰,参加一个活动期待换来充实丰富的经历。这些预设的期待如果实现了,长舒一口气。如果没实现呢?自怨自艾。可是小时候也是同一个我,用一个下午的时间看蚂蚁搬家,等石头开花,小时候不期待结果,小时候哭笑都不打折。
———马德《允许自己虚度时光》
6.
之前看《挪威的森林》,里面绿子对男主说的一句话至今令我印象深刻。她说:有钱最大好处就是可以说自己没钱
7.
我渴望能见你一面,但请你记得,我不会开口要求见你。这不是因为骄傲,你知道我在你面前毫无骄傲可言,而是因为,唯有你也想见我的时候,我们见面才有意义。——西蒙娜·德·波伏娃《越洋情书》
8.
服饰对许多女人之所以如此重要,是因为它们可以使女人凭借幻觉,同时重塑外部世界和她们的内在自我。——西蒙娜·德·波伏娃《第二性》
9.
真正的男子渴求着不同的两件事:危险和游戏。
The real man craving for two different things: danger and game.
test

Friday, April 12, 2019

angularjs note

angularjs note
1. Install git
2. git clone --depth=16 https://github.com/angular/angular-phonecat.git
Cloning into 'angular-phonecat'...
fatal: unable to access 'https://github.com/angular/angular-phonecat.git/': SSL
certificate problem: self signed certificate in certificate chain
Need run "git config --global http.sslVerify false" to fix and then run git clone
3. cd angular-phonecat


1. Install Git and register on bitbucket
https://bitbucket.org
2.
It's important to understand that branches are just pointers to commits. When you create a branch, all Git needs to do is create a
new pointer—it doesn’t create a whole new set of files or folders.

Friday, March 15, 2019

An interesting issue about "SQLRecoverableException: I/O Exception: Connection reset"

I developed a Java application (Spring boot) to pump the data from Oracle database to Mongo DB, to improve the performance, I use 8 processes to pump at the same time.
It works perfect on my local (Windows 10), it only takes 2.5 mins to pump 1 million records from remote Oracle to my local mongo. However, when I tried to run the application from the Linux box, it becomes very slow and after several minutes, I can see the exception "SQLRecoverableException: I/O Exception: Connection reset".

Oracle JDBC driver/JDK1.8 has a bug to generate the random number on some Linux (say Redhat), if the below command cannot return immediately then the issue will happen:
                 head -n 1 /dev/random
The fix is to set the property or
  1. Open the $JAVA_HOME/jre/lib/security/java.security file in a text editor.
  2. Change the line:
  3. securerandom.source=file:/dev/random
    to read:
    securerandom.source=file:/dev/urandom


http://www.usn-it.de/index.php/2009/02/20/oracle-11g-jdbc-driver-hangs-blocked-by-devrandom-entropy-pool-empty/
https://docs.oracle.com/cd/E13209_01/wlcp/wlss30/configwlss/jvmrand.html
https://stackoverflow.com/questions/6110395/sqlrecoverableexception-i-o-exception-connection-reset
https://community.oracle.com/thread/943911


Thursday, March 7, 2019

Spring boot note

1. Log
The default log messages will print to the console window. By default, “INFO”, “ERROR” and “WARN” log messages will print in the log file.
If you have to enable the debug level log, add the debug flag on starting your application using the command shown below −
java –jar demo.jar --debug
You can also add the debug mode to your application.properties file as shown here −
debug = true

By default, all logs will print on the console window and not in the files. 
You can specify the own log file name using the property shown below −
logging.file = /var/tmp/mylog.log

The code given below shows how to add the slf4j logger in Spring Boot main class file.
private static final Logger logger = LoggerFactory.getLogger(DemoApplication.class);
logger.info("this is a info message");
2. Exceptions
he @ControllerAdvice is an annotation, to handle the exceptions globally.
@ControllerAdvice
public class ProductExceptionController {
   @ExceptionHandler(value = ProductNotfoundException.class)
   public ResponseEntity<Object> exception(ProductNotfoundException exception) {
      return new ResponseEntity<>("Product not found", HttpStatus.NOT_FOUND);
   }
}
3. Rest Template
Rest Template is used to create applications that consume RESTful Web Services. You can use the exchange() method to consume the web services for all HTTP methods.

4. Scheduling
The @EnableScheduling annotation is used to enable the scheduler for your application. 
The @Scheduled annotation is used to trigger the scheduler for a specific time period.
@Scheduled(cron = "0 * 9 * * ?")
The following is a sample code that shows how to execute the task every minute starting at 9:00 AM and ending at 9:59 AM, every day
package com.tutorialspoint.demo.scheduler;

import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class Scheduler {
   @Scheduled(cron = "0 * 9 * * ?")
   public void cronJobSch() {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
      Date now = new Date();
      String strDate = sdf.format(now);
      System.out.println("Java cron job expression:: " + strDate);
   }
}
5. Actuator
Spring Boot Actuator provides secured endpoints for monitoring and managing your Spring Boot application. 
In the application.properties file, we need to disable the security for actuator endpoints.
management.security.enabled = false

/metricsTo view the application metrics such as memory used, memory free, threads, classes, system uptime etc.
6. Oauth2 with JWT

Tuesday, February 26, 2019

ORA-01031: insufficient privileges

Got the error "ORA-01031: insufficient privileges" when running "sqlplus / as sysdba" from Windows.
Run "sqlplus sys/password as sysdba" instead

Thursday, February 21, 2019

Cloud VM comparison


I tried Amazon EC2, google compute engine, Windows Azure, Oracle Cloud, Alicloud

The best is Amazon EC2, it has excellent performance with even a free tier, google compute engine is not that smooth. However, Amazon EC2 keeps crashing when I tried to import VM into Virtualbox or tried to install Windows from Virtualbox. And there's some hyper-v prompt for VMWare.

Google compute engine is able to support Virtualbox, however, the performance is not good. Say in my iMac (2.7G i5, 16G memory, SSD) and my Windows (2011 Asus N53 i7, 16G memory, SSD), the windows XP start time is around 7 seconds. In google Virtualbox, it takes 1mins and 40 seconds. And the function for huatai "detecting site speed" is not available. BTW, need remove intelppm.sys or update the registry value to run Virtualbox VM on google compute engine. Google compute engine provides $300 credit.

I don't really use Windows Azure, the design and interface looks not friendly.

For Oracle Cloud, it provides huge disk (at least 256G), and the performance is not bad. And it supports Virtualbox as expected. However, the VM performance within Virtualbox is even worse than google compute engine. Oracle Cloud is not fast or friendly in the management GUI as Amazon or Google, say, you need manually perform some actions to allow remote desktop access. The region can only be north america or euro.

Alicloud sucks, it asked me to have some money firstly in my account, and it deducts my money directly even after I shutdown the VM. It's free trial doesn't support Windows host.

Will try tscon on Amazon EC2, maytry Windows Azure

https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/keeping-computer-unlocked.html
http://blogs.microsoft.co.il/arnona/2016/01/03/keeping-an-active-desktop-session/

AutoIt autoit winwaitactive remote desktop doesn't work well.


http://www.brianlinkletter.com/network-labs-using-nested-virtualization-in-the-cloud/

Cloud service providers support for nested virtualization

Cloud providerNested virtualizationLevel of support
for Linux VMs
Free trial periodFree trial limits
Amazon EC2NoN/A1 year8,760 CPU-hours
Oracle CloudYesFull support30 days$300 worth of services.
8 vCPU
Google Compute EngineYesIn Beta1 year$300 worth of services.
8 vCPU
Microsoft Azure IaaSYesUnofficial,
but it works
30 days$250 worth of services.
4 vCPU

Friday, February 15, 2019

JMS Specification note

1. A connection’s delivery of incoming messages can be temporarily stopped
using its stop() method. It can be restarted using its start() method. When the
connection is stopped, delivery to all the connection’s MessageConsumers is
inhibited: synchronous receives block, and messages are not delivered to
MessageListeners.
If MessageListeners are running when stop is invoked, stop must wait until all
of them have returned before it may return. While these MessageListeners are
completing, they must have the full services of the connection available to
them.
When connection close is invoked it should not return until message
processing has been shut down in an orderly fashion. This means that all
message listeners that may have been running have returned, and that all
pending receives have returned.
If a connection is closed, there is no need to close its constituent objects. The
connection close is sufficient to signal the JMS provider that all resources for
the connection should be released.
Closing a connection does NOT force an
acknowledgement of client-acknowledged sessions.
2.
If a session is transacted, message acknowledgment is handled automatically
by commit, and recovery is handled automatically by rollback.
If a session is not transacted, there are three acknowledgment options, and
recovery is handled manually:
DUPS_OK_ACKNOWLEDGE
AUTO_ACKNOWLEDGE
CLIENT_ACKNOWLEDGE
3.
JMS providers must never produce duplicate messages. This means that a
client that produces a message can rely on its JMS provider to insure that
consumers of the message will receive it only once. No client error can cause a
provider to duplicate a message.