Sunday, July 21, 2019

IPTV for apple TV (and others)

apple TV has an app iPlayTV which costs C$3.99, it's worth to buy but you have to find your own high quality IPTV sources.

Github has an open source project https://github.com/freearhey/iptv , also there's a nice Fluxus.tv (https://fluxustv.blogspot.com/p/iptv.html)

After I clone Github and run "npm run test --country=uk " I got an error complaining module "playlist-parser" missed and the error log is:
11 silly lifecycle iptv@~test: Returned: code: 1  signal: null
12 info lifecycle iptv@~test: Failed to exec test script
13 verbose stack Error: iptv@ test: `node test/index.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:189:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:189:13)
13 verbose stack     at maybeClose (internal/child_process.js:970:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid iptv@

After checking package.json, and issue the below:
        npm install playlist-parser --save-dev

I'm able to run "npm run test --country=uk" successfully.


Friday, June 14, 2019

What did Kawhi Leonard say after Raptors victory?

“Just last year, a lot of people were doubting me, thought that I was either faking an injury or didn’t wanna play for a team,” he said. “That was disappointing to me.”
Leonard added: “I just knew that I had to make myself happy and no one else. I have to trust myself... I know who I am as a person.”
“上赛季,很多人质疑我,认为我是诈伤,不想(为马刺队)出场比赛,”卡哇伊表示,“老实说,那些话令人失望,因为我如此热爱篮球。”
“正如我一直所说,如果我不打比赛,那说明我受伤了,打不了,”卡哇伊继续说道,“我经历了那些事情,我知道,我只需要让自己开心,而不是让其他人开心。我必须要信任自己,别人说什么都无关紧要。我知道自己是怎样的人,我清楚自己的感受,我总是会信任自己。”

Wednesday, May 1, 2019

Angular notes

1. Install Node.js
node -v
npm -v
2. Install Angular
npm install -g @angular/cli
ng --version
ng new hello-world

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