Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

I try to add an Export button in ExtJS, it should do URL encoding for the search parameters and pass the generated query string to the export URL.

When testing above code in Chrome, following error happened:

Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

The reason is let keyword is not allowed in non-strict mode for this version of Chrome.

One solution is to change let to var. (But it isn’t good)
The better solution is to add “use strict” statement.

So the final code should be

keras-vggface deploy model file locally

keras-vggface is a face detection library based on keras.

Running above code will load vgg16 model. if models is not downloaded before, it will try to fetch the model file from web.

What if you want to deploy the model locally, pack it with your application distribution, so the user don’t need to download model file when using your application first time?


The answer is to put the model file under ~/.keras/models/vggface

The ~ is your home path. If you’re using Linux, just copy the path as it is, supported on Linux by default.
But if you are using Windows, the ~ should be replaced with C:/Users/Administrator
(assume system path is C: and current logged in username is Administrator)

Note that the model file name cannot be changed, e.g. for vgg16 model the filename should be rcmalli_vggface_tf_vgg16.h5

SFTP ls command returns no files

I created a new user called phone for the client, and created a new directory /home/phone as his home directory. Next create some files for testing purpose.

Then modify /etc/ssh/sshd_config to set chroot configuration

But logging in with this new user and run ls command, no files are listed, it returns nothing.. But if I run ls in ssh, the files are shown.

After trying lots of time, the reason is found: It’s because there is no “x” permission for /home/phone directory..

What is “x” permission?

The “x” permission for directory is used to traverse directory. And the “x” permission for file is for file execution.

Then run following command to add “x” permission for /home/phone

And try running ls command in sftp again, the issue is fixed now, we can see files are listed now.

mvn add jar file to local repository

Did you ever want to put a local jar library file into your deployment jar file, but the library file is not available on public repository (or you don’t want to put it on public repository?)

One possible method is to add maven dependency with scope and systemPath property


But using scope and systemPath has a problem, that is when I run mvn package to build a package, the dependency will not be included, so running the application on another machine will always complain NoClassDefFoundError or ClassNotFoundException

So a better method is to use mvn install:install-file plugin

This will add AesZip.jar to your local maven repository. When running mvn package to create package, the dependent libraries will be included into the generated package

Python No module named feedparser

I want to use following tool to download paper from arxiv


I installed it by pip

When trying to run python arXiv, following error happened.

Install feedparser using pip

Run python arXiv again, the issue is fixed

OpenCV findContours with RETR_EXTERNAL not working

Following code is trying to extracting bounding rectangles from contours and merge rectangles which is contained in other rectangles


In above found contours, one inner contour is contained within an outer contour, but is not merged with outer contour. the inner one’s border is 2 pixel away from outer one’s border.

I checked the code multiple times, and not found something wrong.


Then I tried changed the drawing rectangle border thickness to 2, and it works..



Checking it in PyCharm SciView Data View I found their border is connected. So I’m not sure why it’s working is caused by increased border width or connected shapes. (But in the past cv2.findContours with RETR_EXTERNAL will work for inner contours, so it’s likely caused by thin border)





My cloud server moved to VPC from classic network just now, and connecting to it via SSH got following error



It seems the server host key is changed, one way to solve this prolem is to remove the line containing server IP address from /root/.ssh/known_hosts . Then connect to it by SSH again, it will ask you whether trust this new host key, like following message

Type yes and press Enter key, this new host key is added to .ssh/known_hosts  then.


Also you can obtain the host key from the remote server, and add it to .ssh/known_hosts  manually , but we won’t cover this method in detail.

Spring disable transaction for method in transactional class


In Spring @Transactional  annotation can be used to indicate method should be run in transaction.

When @Transactional  is placed on method, this method will be run with transaction. And if it’s placed on a class, all methods of this class will run within transaction.


In MVC style application, we usually wrap business logic into a separate service class annotated with @Service  and @Transactional , so every method in this class will run within transaction. But how to disable transaction management for a specific single method in class which is annotated with @Transactional ?



Add following code before the method which you want to disable transaction management for.

Above code will tell Spring PlatformTransactionManager that transaction is not supported for this method, and transaction manager won’t create a new transaction if no transaction is existed.

And if a current transaction existed, exception will be thrown (An IllegalTransactionStateException with message “Existing transaction found for transaction marked with propagation ‘never'”).


java.lang.NoClassDefFoundError: java/util/Base64


In the following code, Base64 is used to encode AES encrypted data bytes to plain text for transfering via URL query parameter.


But when running this code on my coworker’s machine, following exception is thrown


It’s because that my execution environment is Java 8, but my coworker is using Java 7, and java.util.Base64 is introduced in Java 8.



To fix this issue, we can use Base64 class from Apache Commons Codec.

First add commons codec dependency to maven pom.xml file.

Next import Base64 class from commons-codec


Finally replace  Base64.getUrlEncoder().encodeToString to Base64.encodeBase64URLSafeString .

So the code will become like following