Posts

Showing posts from 2021

Add weather and time zone information to your website from free API

Image
Today I will introduce to you how to get weather information and display it on your website, get information by available address or by your location. We will be using a free account from https://home.openweathermap.org, you sign up with an email account and after confirming, you will receive the API from the incoming email. Of course you can create many APIs after logged in. API key from the incoming email   Create API key name with name MyApiKey on home.openweathermap.org page   To display a select list of locations for information, you need latitude and longidute addresses. I assume you have list of coordinates of locations as below: Note:  Also you can refer to how to get the coordinates of other locations here  Getting Latitude and Longitude from a Click Event Once you have the information about the API key, the coordinates are needed. We proceed to get data combining Laravel and VueJS as follows: Of course you only need to use Javascript is also completely appl...

NodeJS Express SocketIO – Chat message and send image

Image
When it comes to NodeJS, Realtime must be thought of. Realtime here is to process the communication from client to server in real time. NodeJS is an open source code widely used by thousands of programmers around the world. NodeJS can run on many different operating systems from Windows to Linux, OS X so that is also an advantage. NodeJS provides rich libraries in different form of Javascript Module which simplify programming and minimize time. Here I will introduce the structure of realtime chat message application using  NodeJS combined Express, Socket IO  consists of two parts: server side, client side. 1. First, create a folder containing your source code and install modules. – Create a folder containing your source code. mkdir NodeJs-Express-SocketIO-SendImage – Run [npm init] to initialize the source file, package.json. Select the js code file is index.js cd NodeJs-Express-SocketIO-SendImage npm init – Install the module for use in NodeJS, it is: express ejs socketio npm...

NodeJS – Simple CRUD APIs with MySQL

Image
  In this article, I will do a simple CRUD APIs in NodeJS, Express and  MySQL . We learn how to create restful (create, read, update, delete) api in NodeJS.   API End Points, test on Postman: GET /learns: Give all learns stored in database GET /learns/{id}: Give a specific user with id. POST /learns : Create a record PUT /learns/{id}: Update a record DELETE /learns/{id}: Delete a record   Modules to install and use in this example: express.js: Web framework express. mysql: Node.js driver for MySQL. body-parser: Converting the POST data into the request body. nodemon: Automatically restart the server whenever the code changes.   1. Install the modules to use in NodeJS Run [npm init] to initialize the source file, package.json. Select the js code file is index.js npm init Install these packages, type in the following command on Git Bash or your favorite cmd: npm i –s express express-handlebars mysql body-parser Installing nodemon with the global command: npm i -g ...

Move large mysql database to new server

Image
  We all know the importance of a database in every system, in this article we ask you to back up,  move database to another server . This will be easily handled if your db has a small number of records. And if the number of records is too large (a few million records or more) then exporting on the current machine and importing to another server will take a lot of time, not feasible. You can use one of two ways: Method 1: mysql -u root -p your_db_name < your_path/../database.sql Example: C:/Users/admin/dumps/backup-2020.sql   Method 2:  login with root: mysql -u root -p –binary-mode=1 use your_db_name source your_path/../database.sql (C:/Users/admin/dumps/backup-2020.sql)   However, in many cases there will be a dump error, because of the data type, it is not possible to import all the records into the new database. I assume you are using mysql with Xampp server service, the data when running is saved with the folder name as the database name located C:\xampp...

Optimize your MySQL Database Performance

Image
MySQL is a free database management system widely used in  PHP . When creating tables in MySQL there are many types of Storage Engine to choose from. MyIsam & Innodb & Memory are three popular types. Choosing a store tool is extremely important before you design the database, helping to improve query performance. If the store engine changes later, it will take a long time if the data on the table is large. Let’s talk about it.     I.  MySQL storage engines   1. MyISAM This Storage Engine allows full-text search indexes. Therefore, this Storage Engine gives speed read and search quickly. The downside of MyISAM is that it uses table-level locking mechanism, so when adding, editing or deleting a certain record in the same table, that table will be locked, not allowed until the previous operation done.   2. InnoDB Currently InnoDB is set by default when creating DB, it supports Foreign key foreign key and since version 5.6, InnoDB also supports Full-tex...

Setup project running PHP, Laravel with Docker

Image
After learning about Docker convenience and  some of the most commonly used concepts of Docker,  let’s do an example of setting up a project to run Laravel on Docker, with services like php, mysql, server nginx. What we will do: – Install nginx, mysql, php -> Test run in browser with php web server nginx – Install laravel on a directory with Docker   1. Create file and folder on your soure path: – Folder: mysql, nginx, nginx_log, php-fpm – File: Dockerfile, docker-compose.yml Source folder   2. Dockerfile – Get the nginx, php-fpm installer from docker-hub (from wyveo) – Create a  Dockerfile  file with the following content: FROM wyveo/nginx-php-fpm:php73 LABEL maintainer=”your favorite title”   3. docker-compose.yml – Create docker-compose with following content: mydocker_server:                         // name of server build: .       ...