Javascript call a function after page loaded

This article shows how to call a function after a page is loaded in Javascript. Table of contents: 1. Document: DOMContentLoaded event 2. Window: load event 3. Javascript calls a function after the page loaded 4. References 1. Document: DOMContentLoaded event In modern JavaScript, the most common way to run code after loading the page …

Read more

Java decompiler plugin for Eclipse IDE

In Eclipse IDE, we can use Enhanced Class Decompiler plugin to decompile Java class files without source code directly. After installing and configuring the Enhanced Class Decompiler plugin, click on the class or methods, press F3, and the plugin will automatically decompile the Java class. Table of contents 1. What is Enhanced Class Decompiler plugin? …

Read more

How to copy Entire Directory in Linux

Command is simple, here i provide two samples to show how to copy entire directory in linux. cp -r sourcedir targetdir for instance, 1) Copy anything from current directory to /usr/local/download cp -r * /usr/local/download 2) Copy whole directory (include content) /usr/local/fromdownload to target /usr/local/download cp -r /usr/local/fromdownload /usr/local/download

How to building PostgreSQL libpq Programs

Create and compile a program with PostgreSQL libpq is not so straightforward. I created a sample program like “testlibpq.c” in PostgreSQL documentation to test it. When i compile it, i hit following error libpq-fe.h: No such file or directory PGconn’ undeclared (first use in this function) mkyong@mkyong-desktop:~/Desktop/index$ gcc -o test.o test.c test.c:8:22: error: libpq-fe.h: No …

Read more

Calculate program execute time / time elapsed in C

Here i shared a simple method to calculate program execute time or time elapsed in C /*calculate program execute time */ #include #include int main(int argc, char *argv[]) { time_t start, stop; clock_t ticks; long count; time(&start); // Do stuff int i=0; while(i

Open Browser in Java windows or Linux

A very useful Java code, to open a web browser from Java application in windows or Linux. package com.mkyong; public class StartBrowser { public static void main(String args[]) { String url = "http://www.google.com"; String os = System.getProperty("os.name").toLowerCase(); Runtime rt = Runtime.getRuntime(); try{ if (os.indexOf( "win" ) >= 0) { // this doesn’t support showing urls …

Read more

How to handle unknow size user input in C

Here are two examples to handle user input in C. 1. scanf This method is easy get attack by buffer overflow, try input some characters which are more than what you declare to experience about what is buffer overflow. #include #include int main() { char bStr[80]; printf(“\nEnter a very very very long String value:”); scanf(“%s”, …

Read more

Backup & Restore Database in PostgreSQL (pg_dump,pg_restore)

Here i demostrate how to backup and restore dabatase in PostgreSQL 1)Backup data with pg_dump pg_dump -i -h localhost -p 5432 -U postgres -F c -b -v -f "/usr/local/backup/10.70.0.61.backup" old_db To list all of the available options of pg_dump , please issue following command. pg_dump -? -p, –port=PORT database server port number -i, –ignore-version proceed …

Read more

Fedora Password is Strong !!!

Fedora you are strong !!! Here i share a bit funny stuff, regarding when i reset my postgres user password in fedora core 8. Please view below picture. Actually i just want to set a easy remember password for user postgres. However i unable to do it. First i enter password as “password” Fedora : …

Read more

ClassNotFoundException: org.apache.commons.logging.LogFactory

Starting a web application, but hits the following error messages : … Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory … 1. Normal Case 1.1 Obviously, the Apache Commons logging is missing – commons-logging-xxx.jar. To fix it, get it from Maven central repository. pom.xml <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.2</version> </dependency> 2. Spring Case 2.1 For Spring application, developers always excluded …

Read more

How to set environment variable on Ubuntu

On Ubuntu, there are two system-wide environment variables, both files need admin or sudo to modify it. /etc/environment – It is not a script file, purely assignment expressions, one per line. /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" JAVA_HOME=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64 LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/postgresql/8.3/lib /etc/profile.d/*.sh – Files with .sh extension in the /etc/profile.d/ folder. /etc/profile.d/myenv.sh export JAVA_HOME=JAVA_HOME=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64 export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/postgresql/8.3/lib export PATH=$PATH:$JAVA_HOME/bin Further Reading: Ubuntu …

Read more

PostgreSQL – ERROR: operator does not exist: smallint = character varying (Solution)

Today i hit a weird error, actually my company is plan to migrate existing j2ee web application from PostgreSQL 8.2 to latest PostgreSQL 8.3. But after i set up PostgreSQL 8.3 properly, and start web application, i keep hiting following error org.postgresql.util.PSQLException: ERROR: operator does not exist: smallint = character varying It’s seem like data …

Read more

Performance Testing on Partition Table In PostgreSQL – Part 3

I will make a performance test between partition table and non partition table. Here are two tables both contains 200 millions of data. 1) hashvalue_pt (Partiton tables In Month) 2) hashvalue (Non Partiton tables) P.S Please visit Partition Table In PostgreSQL (Create Partition) – Part 1 If you do not know how to do table …

Read more

Install Perl in PostgreSQL, The specified module could not be found.

Here i provide few steps to guide how to install Perl in windows PostgreSQL 1) Install ActivePerl to make your windows support Perl script. 2) Set Perl bin folder to windows environment variable 3) Restart PostgreSQL 4) Issue Createlang command C:\>createlang -U postgres plperl DB_NAME If you hit “The specified module could not be found” …

Read more

Partition Table In PostgreSQL (Simulate Millions Data) – Part 2

If you do not know how to do table partition in PostgreSQL, please study Partition Table In PostgreSQL (Create Partition) – Part 1 Here i will provide a simple function to demonstrate how to insert million of data into partition table. –create sequence for testing CREATE SEQUENCE hashvalue_PT_serial START 1; –Generate Dynamic data for testing …

Read more

Partition Table In PostgreSQL (Create Partition) – Part 1

Partition table in PostgreSQL is very easy to do, It involve inheritance concept and trigger of PostgreSQL. Here i provide a sample to demonstrate how to partition table in PostgreSQL. Before proceed, please understand some basic concept like,er… better i provide a concept of partition “time” in a table. “Mother” — (Child1, Child2, Child3,Child4, Child5) …

Read more

How to find large file size on linux

Often time, you may need to know which file contains large file size, and delete it to save space. Here’s a code pattern to show you how to find large file size on Linux : find {directory} -type f -size +100000k -exec ls -lh {} \; | awk ‘{ print $9 ": " $5 }’ …

Read more

PostgreSQL Network Access – (Solution)

After we installed and configure PostgreSQL properly, it is no problem to access locally, however when we access through the network , we hit following error message. could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host “10.0.0.6” and accepting TCP/IP connections on port 5432? It is because PostgreSQL disable network …

Read more

How to install postgresql in fedora core

Here i share how i install postgresql in fedora core. I spent full day to find out a solution. Hope this help 1) First please get a PostgeSQL source code n compile it for installation or using yum command in fedora core. a) Regarding PostgeSQL source code Compilation, please visit here https://mkyong.com/database/how-to-compile-postgresql-database-source-code-in-linux/ b) Regarding Yum …

Read more

How to install java jdk on fedora core (linux)

How to install java jdk on fedora core? here i provide few steps to demonstrate how it’s work. Installation Setup 1 ) Please visit sun java website to download any java jdk version you like. http://java.sun.com/javase/downloads/index.jsp 2 ) Click download, select Linux platform, language and accept license and continue. 3 ) Select “Linux RPM in …

Read more

PostgreSQL – Create table from existing table

PostgreSQL support function like create a new table(with data) from an existing table. It can be achieved with following two syntax. 1) CREATE TABLE ‘NEW_TABLE_NAME’ AS SELECT * FROM ‘TABLE_NAME_YOU_WANT_COPY’; 2) SELECT * INTO ‘NEW_TABLE_NAME’ FROM ‘TABLE_NAME_YOU_WANT_COPY’ ; Sometime i also use this method to temporary backup table :), according to PostgresSQL ‘CREATE TABLE AS’ …

Read more

Java – Check if array contains duplicated value

This article shows a few ways to detect if an array contains a duplicated value. Java 8 Stream, compare the array size. TreeSet, compare the array size. Two for loops, classic algorithm, 0(n^2). Set, 0(n). Bitmap, boolean[] 0(n). All the above solutions are tested with the below program and generate the same output. (except 5. …

Read more

Html Tutorial Hello World

In this tutorial, you will learn how to create a simple hello world page with HTML. Firstly, let explains some of the HTML basics. HTML is stands for Hyper Text Markup Language HTML is a text file which consists a set of markup tags like (<html><body></html></body>). Almost all of the markup tag has start tag …

Read more