Tuesday, November 19, 2019

Dokumen perpanjang STNK

Dokumen yang diperlukan untuk perpanjang STNK Samsat Jakarta:

  1. Ktp - asli
  2. Tanda lunas thn sebelum - asli
  3. Stnk - asli
  4. Cp ktp
  5. Cp stnk
  6. Cp bpkb
  7. Formulir yang telah diisi
Drive thru Samsat Jakarta:
  1. KTP asli
  2. STNK dan bukti bayar Asli
  3. BPKB asli
  4. Pemilik kendaraan
  5. Kendaraan
Perpanjangan STNK online install aplikasi SIGNAL–SAMSAT DIGITAL NASIONAL

Sunday, November 10, 2019

Debian Buster: install and configure phpmyadmin

Required Apache2, Mysql/MariaDB,  and PHP 7.x

There is no phpmyadmin package in Debian 10 Buster Repository. You need to install it manually.

  1. Create folder /usr/share/phpmyadmin/
  2. Download phpmyadmin from https://www.phpmyadmin.net/downloads/ and extract into  /usr/share/phpmyadmin/. Note: phpMyAdmin version 4.9.1.
  3. Create folder /etc/phpmyadmin/
  4. Create a new config file from configuration using file config.sample.inc.php
    # cp /usr/share/phpmyadmin/config.sample.inc.php /etc/phpmyadmin/config.inc.php
  5. Create folder /var/lib/phpmyadmin/tmp
    # mkdir /var/lib/phpmyadmin/tmp
  6. Edit /etc/phpmyadmin/config.inc.php
    $cfg['blowfish_secret'] = 'ABCDEabcde1234567890ABCDEfghij12'; // random 32 characters
    ...
    /**
     * Directories for saving/loading files from server
     */
    $cfg['UploadDir'] = '/var/lib/phpmyadmin/tmp';
    $cfg['SaveDir'] = '/var/lib/phpmyadmin/tmp';
  7. Create apache configuration file for phpmyadmin
    # touch /etc/apache2/conf-available/phpmyadmin.conf
  8. Edit /etc/apache2/conf-available/phpmyadmin.conf, copy paste these lines.
    Alias /phpmyadmin /usr/share/phpmyadmin

    <Directory /usr/share/phpmyadmin>
        Options SymLinksIfOwnerMatch
        DirectoryIndex index.php

        <IfModule mod_php5.c>
            <IfModule mod_mime.c>
                AddType application/x-httpd-php .php
            </IfModule>
            <FilesMatch ".+\.php$">
                SetHandler application/x-httpd-php
            </FilesMatch>

            php_value include_path .
            php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
            php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
            php_admin_value mbstring.func_overload 0
        </IfModule>
        <IfModule mod_php.c>
            <IfModule mod_mime.c>
                AddType application/x-httpd-php .php
            </IfModule>
            <FilesMatch ".+\.php$">
                SetHandler application/x-httpd-php
            </FilesMatch>

            php_value include_path .
            php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
            php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
            php_admin_value mbstring.func_overload 0
        </IfModule>

    </Directory>

    # Authorize for setup
    <Directory /usr/share/phpmyadmin/setup>
        <IfModule mod_authz_core.c>
            <IfModule mod_authn_file.c>
                AuthType Basic
                AuthName "phpMyAdmin Setup"
                AuthUserFile /etc/phpmyadmin/htpasswd.setup
            </IfModule>
            Require valid-user
        </IfModule>
    </Directory>

    # Disallow web access to directories that don't need it
    <Directory /usr/share/phpmyadmin/templates>
        Require all denied
    </Directory>
    <Directory /usr/share/phpmyadmin/libraries>
        Require all denied
    </Directory>
    <Directory /usr/share/phpmyadmin/setup/lib>
        Require all denied
    </Directory>
  9. Enabling your phpmyadmin config in apache2
    # a2enconf phpmyadmin
    Note to disable # a2disconf phpmyadmin
  10. Reload/restart your apache2
    # systemctl reload apache2

Remove folder /usr/share/phpmyadmin/test/ and /usr/share/phpmyadmin/setup/. You can access your phpmyadmin using http://localhost/phpmyadmin.

If your mysql root (with password) can not login with error:
mysqli_real_connect(): (HY000/1698): Access denied for user 'root'@'localhost', do these:

  1. using cli connect to mysql
    # mysql -u root -p
    Enter password:
  2. Select mysql database
     > use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
  3. Change root plugin from unix_socket to mysql_native_password
    > update user set plugin='mysql_native_password' where user='root';
    Query OK, 1 row affected (1.372 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
  4. restart your mysql
    # systemctl restart mysql

If something goes wrong after you change unix_socket to mysql_native_password, revert it back.

Stop mysql server

# systemctl stop mysql

Start your mysql using mysqld_safe

# mysqld_safe --skip-grant-tables

In other terminal connect to mysql using root user

# mysql -u root
MariaDB [(none)]> user mysql;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'user mysql' at line 1
MariaDB [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> update user set plugin='unix_socket' where user='root';
\q

Now, You may kill your terminal where mysqld_safe running and start your mysql service normally.

References:

  1. https://docs.phpmyadmin.net/en/latest/setup.html
  2. https://salsa.debian.org/phpmyadmin-team/phpmyadmin/blob/master/debian/README.Debian
  3. https://computingforgeeks.com/install-phpmyadmin-with-apache-on-debian-10-buster/
  4. https://docs.phpmyadmin.net/en/latest/config.html#config
  5. https://askubuntu.com/questions/998920/1698-access-denied-for-user-rootlocalhost-mysql-5-7-and-ubuntu-16-04

Friday, September 20, 2019

Update date time using batch file

For dual OS, sometimes windows show date incorrect. You need to go setting and force windows to synchronize its date time.
The easy way and fast is using batch files. Using text editor, create batch files for example datesync.bat in your desktop. Write or copy/paste this code:

Echo off
Echo Starting Windows Time Service
net start w32time


Echo Syncronizing Date Time
w32tm /resync
pause

Everytime your date show incorrect, run this script as administrator. It will start windows time service (should not be disable on services.msc) and syncronize date time from internet.

Android Studio 3.5: Clone android project into new android project with diferent name

Requirement and test on Android Studio 3.5

Make sure your old project working properly with your existing android studio library.

1. Copy project directory and rename folder for new project name e.g. Bramara
2. Open your existing new project using Android Studio 3.5. After opening project complete,  Navigate to 1: Project -> Project. You may seen your project only has two directory pointing to new project folder and old project folder. Close your project.
3. Edit appl.iml on directory new project -> app -> appl.iml using text editor. Replace all old project name into new Project Name.
4. Reopen your exising new project. Navigate to 1: Project -> Project. You may seen your project only has one directory.
5. Navigate to 1: Project -> Packages. right click on your component -> Refactor -> Rename.
6. A Warning message will pop up. Make sure all change will apply to new project folder! After that choose Rename packages e.g. com.dedetok.bramara.
7. Navigate to 1: Project -> Android. Open app -> manifests -> AndroidManifest.xml. Fix Application Activity to new pakage name. Change your Application Name to a new one.
8. Open Gradle Scripts -> build.gradle (Module: app), change your applicationId to new project, e.g com.dedetok.bramara and sync project.
9. Clean and rebuild your new project.
10. Your new project to edited/change.

Note: if adb run showing activity not found, edit your Run/Debug Configuration. Module should point to module application e.g. app

Wednesday, September 4, 2019

Android Studio 3.5.0 and Migrate to AndroidX

System requirement:

Android Studio requirement 3.5 or above

At the end of "Project -> Gradle Scripts -> gradle.properties(Project Properties)" add these lines:

    android.useAndroidX=true
    android.enableJetifier=true

At the end of "Project -> Gradle Scripts -> build.gradle(Project:)" add these lines:

...
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {

    repositories {
        jcenter()
        google()
    }
}

Change "Project -> Gradle Scripts -> build.gradle(Module:)" these lines:

androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' -> androidx.test.espresso:espresso-core:3.2.0

implementation 'com.android.support:appcompat-v7:28.0.0' -> androidx.appcompat:appcompat:1.1.0

implementation 'com.android.support.constraint:constraint-layout:1.1.3' -> androidx.constraintlayout:constraintlayout:1.1.3

androidTestImplementation 'com.android.support.test:runner:1.0.2' -> androidx.test:runner:1.2.0

implementation 'com.google.android.gms:play-services-ads:17.2.1' -> com.google.android.gms:play-services-ads:18.2.0

For Example:

...
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    implementation 'com.google.android.gms:play-services-ads:18.2.0'
  
In Java code, change import android.support.v7.app.AppCompatActivity; to import androidx.appcompat.app.AppCompatActivity;

In activity xml, change android.support.v7.widget.Toolbar to androidx.appcompat.widget.Toolbar

References:

Thursday, August 1, 2019

Debian Stretch: Distribution Upgrade to Debian Buster (10)

Prepare apt /etc/apt/sources.list, change stretch to buster
my apt source list:

# Debian 10

# SECURITY
deb http://security.debian.org/ buster/updates main

# Main
deb http://kartolo.sby.datautama.net.id/debian/ buster main

# NON FREE
deb http://httpredir.debian.org/debian buster main contrib non-free

# BACKPORT
deb http://ftp.debian.org/debian buster-backports main

Note on error when running apt-get update:
E: Release file for http://kambing.ui.ac.id/debian/dists/buster/InRelease is expired (invalid since 265d 4h 18min 17s). Updates for this repository will not be applied.
use other sources e.q change "deb http://kambing.ui.ac.id/debian/ buster main contrib
" to "deb http://mirrors.kernel.org/debian buster main contrib"
If you used oracle mysql or oracle virtualbox, you need to modify to "buster" these files:
/etc/apt/sources.list.d/mysql.list
/etc/apt/sources.list.d/virtualbox.list

Running upgrade process
# apt-get update

# apt-get upgrade
...
Fetched 238 MB in 14min 50s (268 kB/s)   
...

#  apt-get dist-upgrade
...
Fetched 969 MB in 45min 30s (355 kB/s)
...

Restart your computer

# cat /etc/debian_version
10.0
# uname -an
Linux fujitsu01 4.19.0-5-amd64 #1 SMP Debian 4.19.37-5 (2019-06-19) x86_64 GNU/Linux

You can clean and remove unused temporary to make your system "tidy"
# apt-get autoclean && apt-get autoremove

By default, Debian 10 use kernel 4.19, you mau remove your old kernel.
# apt-get remove linux-image-4.9.0-9-amd64

Note:
DO NOT DELETE linux-image-4.19!

Reference:
https://www.debian.org/releases/stable/amd64/release-notes/ch-upgrading.en.html
https://garasiku.web.id/web/joomla/index.php/tips/debian/14-debian-jessie-upgrade-to-debian-9-codename-stretch

Intel(R) Atom(TM) CPU N455   @ 1.66GHz (Fujitsu) takes 3 hours to completed. Don't worry, It's much faster then windows 10 update or windows update clean up LOL.

Tuesday, June 11, 2019

android studio 3.4.1 and google admob change

In build.gradle (Module:app) change
...
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
...
dependencies {
   implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.android.gms:play-services-ads:17.2.1'

In AndroidManifest.xml add
<manifest>
    <application>
        ...
        <meta-data
            android:name="com.google.android.gms.ads.AD_MANAGER_APP"
            android:value="true"/>
    </application>
</manifest>

Thursday, June 6, 2019

defender locking bignox virtual disk

windows defender sometimes open file in background process, to scan for malicious code. If defender (or other antivirus) open bignox virtual disk it will lock it and cause your emulator crash. You need to exclude virtual disk that used by bignox. Here are the steps you need to do:
  1. Open your windows defender (or your antivirus)
  2. Go to setting "Virus & thread protection settings"
  3. in "Exclusions" click "Add or remove exclusions"
  4. Click "Add an exclusion" and choose "File type"
  5. in "Enter extension" box type "vmdk"
  6. repeat step 4 for file type "vbox" and "vdi"
You may want to increase your emulator by excluding these files:
  1. C:\Program Files (x86)\Bignox\BigNoxVM\RT\NoxVMSVC.exe
  2. C:\Program Files (x86)\Nox\bin\Nox.exe

Thursday, April 25, 2019

Codeigniter: query builder select, insert, update and delete

Query table:
        $this->result = $this->db->get('ca_brand',$mmax, 0);
        if ($this->result) {
            return true;
        } else {
            return false;
        }
Query table with like filter:
        $this->db->like('name', $keyword); // buildin mysql escape
        $this->result = $this->db->get('ca_brand',0, $mmax);
        if ($this->result) {
            return true;
        } else {
            return false;
        }
 Insert row in table:
        // buildin mysql escape character
        $data = array('name' => $name);
        $this->db->insert('ca_brand', $data); // return true on success
        $insert_id = $this->db->insert_id(); // get id

Update row in table for spesific id
        // buildin mysql escape character
        $id = intval($id);
        $data = array ('name' => $name);
        $this->db->where('id', $id);
        //$this->db->update('ca_brand',$data, "id = "$id ); // option 1
        $this->db->update('ca_brand',$data); // // option 2
        $numaffectedrow = $this->db->affected_rows(); // to get nummber affected row
 Delete row:
        $id = intval($id);
        $this->db->where('id', $id);
        $this->db->delete('ca_brand');
        $numaffectedrow = $this->db->affected_rows(); // to get nummber affected row

Php 7.2 and Codeigniter 3.1.10

Codeigniter: check mysql connection

To check error in mysql connection, we need to change ENVIRONMENT to Production. Here is the example:
    //define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
    //define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'testing');
    define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production');
There are two ways to catch error in our controller:
1. Using dblib
        $this->load->dbutil();
        if ($this->dbutil->database_exists('myca')) {
            // Connection ok
        } else {
            // Connection fail
        }
2. Checking error in db
        $this->load->database();
        $errhandle = $this->db->error();
        if ($errhandle['code']==0) {
            // Connection ok
        } else {
            // Connection fail
            // to dump error code var_dump( $this->db->error());
        }
Tested on PHP 7.2 and Codigniter 3.1.10

windows: kill process by id using cmd

The most old games do not run on Windows 10. For example Red Alert and GTA San Andreas. Those games require DirectPlay in Windows 10 (legacy feature.
Before you try your old games you need to run cmd in administrator mode. In case the game does not play properly, switch to cmd and stop the game. 
To search pid for RA2
tasklist -v | find "RA2.exe"
tasklist -v | find "GAME.exe"
GAME.EXE                      7356 Console                    4    139,172 K Not Responding  xxx\xxx                                             0:02:48 Red Alert 2
To kill the process
taskkill /F /PID 7356
SUCCESS: The process with PID 7356 has been terminated.

Sunday, March 10, 2019

Install Flutter in android studio 3.3.1

Install Flutter in android studio 3.3.1
  1. Open SDK Manager
  2. Click "Plugins"
  3. In search box type "Flutter" then click "Search in repositories"
  4. Select Flutter Language and install
  5. Read all requirement and accept it. It will install Dart as requirement.
  6. Restart your android studio

android studio 3.3.1 and google admob change

change/update google service library:
  • com.google.android.gms:play-services-ads:16.0.0 -> com.google.android.gms:play-services-ads:17.1.2
  • com.google.android.gms:play-services-auth:16.0.0 -> com.google.android.gms:play-services-auth:16.0.1
To import and use google admob (service-ads), you must add this into application manifest:
<manifest>
<application
...
>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-################~##########"/>
...
</application>