How to handle resize event in Nuxt JS


Loading Web Fonts with the Web Font Loader in Nuxt.JS


Several years ago the consensus on font loading in the community was that, as a website loads, all fonts should be hidden until the correct resources have.

Now, let ‘s do it for Nuxt.JS. This is steps to configure:

  • Include webfontloader via npm install webfontloader --save
  • Add webFontLoader.js file to /plugins folder:
import WebFont from 'webfontloader';

google: {
families: ['Fira Sans:400,500,600,700:latin,vietnamese']
  • Adjust nuxt.config.js:
plugins: [
{src: '~/plugins/webFontLoader.js', ssr: false}

Reference resources:

How to solve ‘ReferenceError: window is not defined’ when importing Vue plugin in Nuxt.JS


I need to use Vue plugin named vue-flash-message in Nuxt.JS. I installed it via NPM and created file vue-flash-message.js in folder plugins.

import Vue from 'vue';
import VueFlashMessage from 'vue-flash-message';


Then I tried to run `npm run dev` to test whether the plugin works. But it doesn’t work.

The reason is the default mode of Nuxt is SSR. The variable window is only available in the browser, not on the server.

And I found the solution, I just change the file content like below:

import Vue from 'vue';

if (process.browser) {
window.onNuxtReady(() => {
const VueFlashMessage = require('vue-flash-message');

After that, it should work fine. You also apply the idea for other Vue plugins.

Vue.js 2 Cookbook

VueJS 2 Cookbook Cover

Vue.js is an open source JavaScript library for building modern, interactive web applications. With a rapidly growing community and a strong ecosystem, Vue.js makes developing complex single page applications a breeze. Its component-based approach, intuitive API, blazing fast core, and compact size make Vue.js a great solution to craft your next front-end application.

From basic to advanced recipes, this book arms you with practical solutions to common tasks when building an application using Vue. We start off by exploring the fundamentals of Vue.js: its reactivity system, data-binding syntax, and component-based architecture through practical examples.

After that, we delve into integrating Webpack and Babel to enhance your development workflow using single file components. Finally, we take an in-depth look at Vuex for state management and Vue Router to route in your single page applications, and integrate a variety of technologies ranging from Node.js to Electron, and to Firebase and HorizonDB.

This book will provide you with the best practices as determined by the Vue.js community.

Download link for ebook:

Please send a request and I will share it with you with sample code files (~300MB zipped)

How to remove “Remaining deprecation notices” while running Symfony test cases

Symfony Test

Sometime, when you run some Symfony tests, there is a lot of deprecation warning like this:

Symfony Test

Solution: Just add below code

<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />

to your phpunit.xml (or phpunit.xml.dist)

How to use jQuery in NuxtJS


Today, I will guide you how to use jquery with NuxtJS project.

  1. npm install --save jquery.
  2. Open nuxt.config.js and add:

That’s all! Hope this helpful for you!

Generate JPA Entity Script

IntelliJ IDEA Logo

I am using IntelliJ IDEA to write Java code.

It has built in script to generate POJOs class, but I want to generate JPA Entity classes. So today, I wrote a Groovy script to do it.

It saved my time and I hope it helpful to you!

Ten ways to become a better developer

  1. Read other people’s code. ☑
  2. Get someone to read your code. ☑
  3. Fix bugs before writing new code. ☑
  4. Learn a new technology. ☑
  5. Keep it stupid simple (KISS). ☑
  6. Write a blog post about your code. ☑
  7. Contribute to open source. ☑
  8. Fix it, don’t hack it. ☑
  9. Increase code coverage by 1%. ☑
  10. Leave your desk every hour.


Note on migrating Spring Boot 1.5 to 2.0

Spring Framework Logo

1. Useful links
First of all, you should read recommended links:

2. Tips and solution for problems

  • Table ‘hibernate_sequence’ doesn’t exist

Solution: Add config

  • Spring Boot 2.0 use HikariCP by default, so you should add config for HikariCP


Add config


– Value for config must be in millisecond.
– spring.datasource.hikari.idle-timeout < spring.datasource.hikari.max-lifetime < database wait_timeout
– For MySQL/MariaDB, use query SHOW GLOBAL VARIABLES LIKE 'wait_timeout'; to get wait_timeout, this value is in second
– For example, database wait_timeout = 600 second, so I can assign value as below:

  • Use MariaDB driver for MariaDB instead of MySQL Driver

Step 1: Remove MySQL Driver:
Step 2: Add MariaDB Driver:
Step 3: Change database connection URL: change from jdbc:mysql://... to jdbc:mariadb://...

Fix error when install npm package as global package


Today, I will guide you to fix error when install npm package as global package.
I ran below command to install npm package as global package but installation was failed.
Command: sudo npm install -g electron
Error will look like:
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/electron/.electron'
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2018-03-18T10_25_47_793Z-debug.log

And this option saved my time:
--unsafe-perm=true --allow-root

I hope this post is helpful.

Keep database connection on connecting to MySQL/MariaDB using SQLAlchemy

Python 3

You want the database connection will be keep on connect to MySQL/MariaDB, just use pool_recycle parameter in method create_engine().
create_engine(db_url, pool_recycle=1)


this setting causes the pool to recycle connections after the given number of seconds has passed. It defaults to -1, or no timeout. For example, setting to 3600 means connections will be recycled after one hour. Note that MySQL in particular will disconnect automatically if no activity is detected on a connection for eight hours (although this is configurable with the MySQLDB connection itself and the server configuration as well).


During handling of the above exception, another exception occurred

Python 3

Old code:

New code:

%d bloggers like this: