December 13 2016

How the get total file inside the folder

Tagged Under :

Linux
On Linux without the GUI (Gnome or KDE) if you want to know how many files inside folder, you are unable to right click and select the properties to get the number of files inside the folder.

You can use below command to get number of files inside the folder

October 23 2016

Firebird log execute SQL query

Tagged Under :

On Firebird it have a function to let you log the SQL Query where the system call. How to the log the Firebird SQL query?

First, you need install Firebird 2.5 or 3.0 server on your PC. After that, go to the Firebird folder find a file name call fbtrace.conf and then open the file with notepad.

August 29 2016

Yii2 number compare validation rules

Tagged Under :

Yii
In Yii2 compare two numbers attributes in operator function. you will found that it not working properly. This is because the wrongly “type” in compare validation rules.

You may need to set the type to number as below:
'type' => 'number'
Example:
['min_price', 'compare', 'compareAttribute' => 'max_price', 'operator' => '<', 'type' => 'number'],

August 29 2016

Jquery find the specific Id if exists

Tagged Under :

javascript
If want to check the specific Id already exists inside the site. you may using “length” to do it.

For Example:
if( $('#selector').length) {
     // it exists
}
if the length more then 0, that’s mean the following Id already exists inside the site.

if you are using class to check
if( $('.selector').length) {
     // it exists
}

August 29 2016

check if a string is JSON in Javascript

Tagged Under :

javascript
In javascript it don’t have function to check if the string is JSON. So we may need to write a function to check the string if is JSON.

The below function is to check the string and it will return true if the string is JSON else it will return false.

July 27 2016

Yii2 ActiveRecord model use MySQL function

Tagged Under : ,

Yii
To use the MySQL function on Yii2 ActiveRecord Model you to add “\yii\db\Expression” on your script instead of you direct use the “DATE_ADD” function.

Example:
$model->date = new \yii\db\Expression('DATE_ADD(CURRENT_DATE, INTERVAL - 7 DAY)')

July 27 2016

Yii2 an absolute url image src

Tagged Under :

Yii
If you want to set full url or absolute url on Yii2 Html img, you may need to use “Url” helper this class on your page.

use yii\helpers\Url;
The way to use:
Html::img(Url::to('@web/images/logo.png', true));

July 27 2016

Bootstrap glyphicons checkbox

Tagged Under : ,

Because the default HTML chekcbox look not nice, So i decided use Boostrap Glyphicons as the checkbox and also it got provide checked and uncheck glyphicons.

Glyphicons check and uncheck icon:

June 19 2016

Javascript convert MSAccess color code to Hex color code

Tagged Under : ,

javascript
Because CSS not support MSAccess color code. If want use the MSAccess color code as color display on web. We need change the code to Hexadecimal Code.

May 16 2016

MySQL week of the month

Tagged Under : ,

MySQL
Normally if want display week of certain of the month, we can using WEEK() function. But WEEK() function only return you week of the year.

But now, we want display WEEK of the month no week of the year. that means first, second, third, fourth and fifth week of the month.

Below example is the SQL to display the week number of the month:
SELECT (WEEK(created_date,5) - WEEK(DATE_SUB(created_date, INTERVAL DAYOFMONTH(created_date)-1 DAY),5)+1) as week
The created_date column must be DATE or DATETIME type.