Thursday, December 24, 2015

Android - Debugging Lenovo A7-30 Tablet (A3300) on Linux

If you are using Windows, please read my article HERE on how to debugging using OEM driver from Lenovo Smart Assistant.

Lenovo A7-30 Tablet (A3300)

It has been a while since I wrote post about Android development, right? Today, I share with you how to add Lenovo A7-30 Tablet (A3300) as device for debugging with ADB on Linux operating system. Just like before, I did some research and keep trying until succesfully install and use this device. Oh, make sure you already enable developer mode on that Android table first before proceed to the #1 step.

Wednesday, December 23, 2015

Fixed - JDK >= 1.7.0 needed by astah_professional

Problem:
$ sudo dnf install astah-professional-7.0.0.846701-0.noarch.rpm 
Last metadata expiration check performed 0:26:51 ago on Wed Dec 23 07:38:28 2015.
Error: nothing provides jdk >= 1.7.0 needed by astah_professional-7.0.0.846701-0.noarch
(try to add '--allowerasing' to command line to replace conflicting packages)

Fixed :
$ sudo rpm -ivh --nodeps astah-professional-7.0.0.846701-0.noarch.rpm 
warning: astah-professional-7.0.0.846701-0.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID c22bd678: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
1:astah_professional-7.0.0.846701-0   ################################# [100%]

Linux - Disk space

How to check free disk space on an linux machine ?
$ df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G  1.9M  3.9G   1% /dev/shm
tmpfs                    3.9G  1.7M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/fedora-root   34G   12G   20G  38% /
tmpfs                    3.9G  992K  3.9G   1% /tmp
/dev/sdb2                477M  184M  265M  41% /boot
/dev/mapper/fedora-home   17G   11G  5.0G  68% /home
tmpfs                    785M  8.0K  785M   1% /run/user/42
tmpfs                    785M   40K  785M   1% /run/user/1000

Saturday, December 19, 2015

Fedora 23 - Installling KompoZer version 0.8 beta 3

Today I need to wrote HTML table very quick and I dont have time to play with matching tag. So I need WYSIWYG tool such KompoZer. I searched the package via DNF command but KompoZer are not available in Fedora repository. After google-fu, I found this website. I tried to install and boom! Success! Yeah
$ wget http://hbcom.info/kompozer/kompozer-0.8-0.4.b3.i386.rpm
$ sudo dnf install kompozer-0.8-0.4.b3.i386.rpm 

Last metadata expiration check performed 1:43:44 ago on Sat Dec 19 13:54:44 2015.
Dependencies resolved.
================================================================================
 Package                 Arch     Version                Repository        Size
================================================================================
Installing:
 GConf2                  i686     3.2.6-15.fc23          fedora           1.0 M
 ORBit2                  i686     2.14.19-14.fc23        fedora           178 k
 atk                     i686     2.18.0-1.fc23          fedora           259 k
 avahi-glib              i686     0.6.31-43.fc23         fedora            15 k
 avahi-libs              i686     0.6.31-43.fc23         fedora            61 k
 cairo                   i686     1.14.2-2.fc23          fedora           754 k
 cups-libs               i686     1:2.1.2-1.fc23         updates          402 k
 dbus-glib               i686     0.104-3.fc23           fedora           123 k
 gamin                   i686     0.1.10-18.fc23         fedora           133 k
 gdk-pixbuf2             i686     2.32.3-1.fc23          updates          447 k
 gdk-pixbuf2-modules     i686     2.32.3-1.fc23          updates           97 k
 glib2                   i686     2.46.2-1.fc23          updates          2.3 M
 gnome-vfs2              i686     2.24.4-19.fc23         fedora           388 k
 graphite2               i686     1.2.4-5.fc23           fedora            91 k
 gstreamer1              i686     1.6.2-1.fc23           updates          1.1 M
 gtk2                    i686     2.24.29-1.fc23         updates          3.4 M
 harfbuzz                i686     1.0.6-1.fc23           updates          182 k
 jasper-libs             i686     1.900.1-31.fc23        fedora           151 k
 keyutils-libs           i686     1.5.9-7.fc23           fedora            45 k
 kompozer                i386     1:0.8-0.4.b3           @commandline     9.7 M
 krb5-libs               i686     1.14-3.fc23            updates          856 k
 libIDL                  i686     0.8.14-10.fc23         fedora            89 k
 libXft                  i686     2.3.2-3.fc23           fedora            62 k
 libXt                   i686     1.1.5-2.fc23           fedora           174 k
 libart_lgpl             i686     2.3.21-13.fc23         fedora            72 k
 libbonobo               i686     2.32.1-8.fc22          fedora           432 k
 libbonoboui             i686     2.24.5-9.fc23          fedora           346 k
 libcanberra             i686     0.30-10.fc23           fedora            85 k
 libcom_err              i686     1.42.13-3.fc23         fedora            45 k
 libdatrie               i686     0.2.8-6.fc23           fedora            32 k
 libglade2               i686     2.6.4-13.fc23          fedora            68 k
 libgnome                i686     2.32.1-10.fc23         fedora           744 k
 libgnome-keyring        i686     3.12.0-5.fc23          fedora           114 k
 libgnomecanvas          i686     2.30.3-10.fc23         fedora           233 k
 libgnomeui              i686     2.24.5-11.fc23         fedora           790 k
 libtdb                  i686     1.3.8-1.fc23           updates           52 k
 libthai                 i686     0.1.21-2.fc23          fedora           193 k
 libverto                i686     0.2.6-5.fc23           fedora            21 k
 openssl-libs            i686     1:1.0.2e-3.fc23        updates          993 k
 pango                   i686     1.38.1-1.fc23          fedora           284 k
 pixman                  i686     0.33.4-1.fc23          updates          233 k
 polkit-libs             i686     0.113-4.fc23           fedora            70 k
 popt                    i686     1.16-6.fc23            fedora            60 k

Transaction Summary
================================================================================
Install  43 Packages

Total size: 27 M
Total download size: 17 M
Installed size: 94 M
Is this ok [y/N]: y

Checklist for Review of Use Case Specification

 Topic  Question  (Answer : Yes → Continue to next, No → add finding in review template)
Use case title
  1. Is the title an active phase (i.e 'verb'+'noun') expressing the goal of the primary actor?
  2. Can the goal be archived by the system?
Actors
  1. Is the use case triggered by at least one (primary) actor?
  2. Is the primary actor the first in the list of actor?
  3. Are all actors of the use case listed?
Precondition
  1. Is the precondition formulated as a condition that either true or false?
  2. Is the system able to check the precondition?
  3. Is it true that no checking of precondition is also done in the use case senario?
Post condition
  1. Is the post condition formulated as a condition that is either true or false?
  2. Is the system able to check the post condition?
  3. Can the post conditions always be met after a succesful development?
Primary path
  1. Is described with 3 to 9 steps?
  2. Do the steps describes a consistent scenario leading from trigger to archived post condition?
  3. Are branches and loops described as such?
  4. At condition in the flow: Is it defined what procedure shall be taken if the condition is not fulfilled?
For every step
  1. Can all steps be succesfully executed?
  2. Is it clear in all steps who is the acting actor?
  3. It is clear in all steps what the actor need to accomplish?
  4. Is none of the steps too complex?
  5. Is there no design description in all step (e.g description of UI)?
  6. Is it unambiguous, what information is processed in each step?
  7. Is each step described actively from the view of the acting actor or the system?
Alternative paths
  1. Are all alternative paths in the identical business context?
  2. For all alternative path perform the check check as described above the primary actor.
Overall view (Use case diagram)
  1. Are all the relevant use cases shown in the use case diagram?
  2. Do all actors have connection to at least one use case?
  3. Do all <<include>> and <<extend>> relationship make sense?
  4. Is the syntax of the UML diagram are correct (e.g. actor symbols, stereotypes <<actor>>, <<include>> and <<extend>>, labelling of the system and use case, lines for relationship, etc) ?

Wednesday, December 16, 2015

Fedora 23 - Hibernate

Peace be upon you..
By default, Fedora 23 have suspend function but I still prefer to use hibernate function with my laptop. We need to add resume parameter to the default grub parameter.

First thing, we need to get UUID of swap partition from our computer. Let use blkid command:

$ sudo blkid | grep swap
/dev/mapper/fedora-swap: UUID="bt81a351-8421-1337-96ca-r9ab3605ff7c" TYPE="swap"

Then copy UUID code from you output (Don't copy my swap UUID partition example), which we gonna need that in next step. Now lets edit the default GRUB2 file located at /etc/default/grub

Open that GRUB2 file and find GRUB_CMDLINE_LINUX then, put resume=UUID parameter inside the quote such like this :

GRUB_CMDLINE_LINUX="rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap rhgb quiet resume=UUID=bt81a351-8421-1337-96ca-r9ab3605ff7c"

Now we need to rebuild the GRUB2 config file. Just run sudo grub2-mkconfig -o /boot/grub2/grub.cfg or if you have EFI feature with you computer, please run sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg command, make sure you know which command to execute.

Congratulation, now you have hibernate features enabled. If you are using Gnome desktop, I suggest you to install this wonderful, awesome and nice hibernate status button extension that adds a Hibernate button in status menu.

That all for now. Thanks :)

Monday, December 7, 2015

symbolic link / symlink - Reaver-wps-fork-t6x

# ln -s /usr/local/bin/reaver /usr/bin/reaver
# ln -s /usr/local/bin/wash /usr/bin/wash

Wednesday, December 2, 2015

Fedora / Redhat - Pixie fatal error: openssl/sha.h (FIXED)

I tried to compile PixieWPS, but openSSL library are missing
$ cd src
$ make
cc -std=c99 -O3 -Wno-deprecated-declarations -o pixiewps pixiewps.c random_r.c -lcrypto
In file included from pixiewps.c:51:0:
pixiewps.h:66:25: fatal error: openssl/sha.h: No such file or directory
compilation terminated.
Makefile:11: recipe for target 'all' failed
make: *** [all] Error 1

Debian family call this library package as libssl-dev, but in RHEL family side, it's called as openssl-devel.
$ sudo dnf install openssl-devel
Last metadata expiration check performed 2:52:30 ago on Wed Dec  2 14:43:05 2015.
Dependencies resolved.
========================================================================================================================================================================
 Package                                        Arch                              Version                                      Repository                          Size
========================================================================================================================================================================
Installing:
 keyutils-libs-devel                            x86_64                            1.5.9-7.fc23                                 fedora                              45 k
 krb5-devel                                     x86_64                            1.14-2.fc23                                  updates                            649 k
 libcom_err-devel                               x86_64                            1.42.13-3.fc23                               fedora                              35 k
 libselinux-devel                               x86_64                            2.4-4.fc23                                   fedora                             182 k
 libsepol-devel                                 x86_64                            2.4-1.fc23                                   fedora                              77 k
 libverto-devel                                 x86_64                            0.2.6-5.fc23                                 fedora                              16 k
 openssl-devel                                  x86_64                            1:1.0.2d-3.fc23                              updates                            1.5 M
 pcre-devel                                     x86_64                            8.38-2.fc23                                  updates                            540 k
 zlib-devel                                     x86_64                            1.2.8-9.fc23                                 fedora                              55 k
Upgrading:
 krb5-libs                                      x86_64                            1.14-2.fc23                                  updates                            839 k

Transaction Summary
========================================================================================================================================================================
Install  9 Packages
Upgrade  1 Package

Total download size: 3.9 M
Is this ok [y/N]: y

Now I can compile PixieWPS without error anymore :)

$ make
cc -std=c99 -O3 -Wno-deprecated-declarations -o pixiewps pixiewps.c random_r.c -lcrypto
$ sudo make install 
rm -f /usr/local/bin/pixiewps
install pixiewps /usr/bin/pixiewps
install -m 755 pixiewps /usr/bin

Sunday, November 29, 2015

How To - Migrate Wordpress From Localhost to Production Server

1. Export local MYSQL database and import to MYSQL (production server).

2. Upload all localhost wordpress into you production server directory.

3. Change DB_NAME, DB_USER and DB_PASSWORD inside wp-config.php

4. Open wordpress database using MySQL tool (such PhpMyAdmin) and execute this SQL query:
UPDATE wp_options 
 SET option_value = replace(option_value, 'http://localhost/word_press', 'http://wordpress.site.my') 
WHERE option_name = 'home' OR option_name = 'siteurl';
 
UPDATE wp_posts 
 SET post_content = replace(post_content, 'http://localhost/word_press', 'http://wordpress.site.my');
 
UPDATE wp_postmeta 
 SET meta_value = replace(meta_value,'http://localhost/word_press','http://wordpress.site.my');
* Note : Please replace "http://wordpress.site.my" with you new wordpress URL location.

5.Login and go to the admin dashboard of your new website and browse to Settings > Permalinks. Select the structure you used for your local installation and save.

6. Done !

Tuesday, November 24, 2015

Fedora - Tomcat server


 $ sudo dnf install tomcat tomcat-webapps tomcat-admin-webapps tomcat-docs-webapp tomcat-javadoc
 $ sudo systemctl start tomcat.service
 $ sudo lsof -i :8080  
 COMMAND PID  USER  FD  TYPE DEVICE SIZE/OFF NODE NAME  
 java  9006 tomcat  49u IPv6 81129   0t0 TCP *:webcache (LISTEN)  
$ sudo gedit /etc/tomcat/tomcat-users.xml 
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
 <role rolename="manager-gui"/>
 <user username="tomcat" password="tomcat" roles="tomcat, manager-gui"/>
 <role rolename="admin"/> 
 <user username="admin" password="admin" roles="admin,manager,manager-gui"/>
</tomcat-users>

Monday, November 23, 2015

Linux - Check wireless card capabilities

$ iw dev
phy#0
Interface wlp2s0
ifindex 3
wdev 0x1
addr 6x:1x:43:2x:97:x3
type managed
channel 6 (2437 MHz), width: 20 MHz (no HT), center1: 2437 MHz

$ iw phy phy0 info
Wiphy phy0
max # scan SSIDs: 20
max scan IEs length: 195 bytes
max # sched scan SSIDs: 0
max # match sets: 0
Retry short limit: 7
Retry long limit: 4
Coverage class: 0 (up to 0m)
Device supports RSN-IBSS.
Supported Ciphers:
* WEP40 (00-0f-ac:1)
* WEP104 (00-0f-ac:5)
* TKIP (00-0f-ac:2)
* CCMP (00-0f-ac:4)
* 00-0f-ac:10
* GCMP (00-0f-ac:8)
* 00-0f-ac:9
Available Antennas: TX 0 RX 0
Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* monitor
Band 1:
Capabilities: 0x1072
HT20/HT40
Static SM Power Save
RX Greenfield
RX HT20 SGI
RX HT40 SGI
No RX STBC
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 4 usec (0x05)
HT Max RX data rate: 300 Mbps
HT TX/RX MCS rate indexes supported: 0-15
Bitrates (non-HT):
* 1.0 Mbps
* 2.0 Mbps (short preamble supported)
* 5.5 Mbps (short preamble supported)
* 11.0 Mbps (short preamble supported)
* 6.0 Mbps
* 9.0 Mbps
* 12.0 Mbps
* 18.0 Mbps
* 24.0 Mbps
* 36.0 Mbps
* 48.0 Mbps
* 54.0 Mbps
Frequencies:
* 2412 MHz [1] (16.0 dBm)
* 2417 MHz [2] (16.0 dBm)
* 2422 MHz [3] (16.0 dBm)
* 2427 MHz [4] (16.0 dBm)
* 2432 MHz [5] (16.0 dBm)
* 2437 MHz [6] (16.0 dBm)
* 2442 MHz [7] (16.0 dBm)
* 2447 MHz [8] (16.0 dBm)
* 2452 MHz [9] (16.0 dBm)
* 2457 MHz [10] (16.0 dBm)
* 2462 MHz [11] (16.0 dBm)
* 2467 MHz [12] (16.0 dBm) (no IR)
* 2472 MHz [13] (16.0 dBm) (no IR)
Supported commands:
* new_interface
* set_interface
* new_key
* start_ap
* new_station
* new_mpath
* set_mesh_config
* set_bss
* authenticate
* associate
* deauthenticate
* disassociate
* join_ibss
* join_mesh
* set_tx_bitrate_mask
* frame
* frame_wait_cancel
* set_wiphy_netns
* set_channel
* set_wds_peer
* probe_client
* set_noack_map
* register_beacons
* start_p2p_device
* set_mcast_rate
* set_qos_map
* connect
* disconnect
Supported TX frame types:
* IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* mesh point: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-device: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
Supported RX frame types:
* IBSS: 0x40 0xb0 0xc0 0xd0
* managed: 0x40 0xd0
* AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* mesh point: 0xb0 0xc0 0xd0
* P2P-client: 0x40 0xd0
* P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* P2P-device: 0x40 0xd0
WoWLAN support:
* wake up on disconnect
* wake up on magic packet
* wake up on pattern match, up to 20 patterns of 16-128 bytes,
maximum packet offset 0 bytes
* can do GTK rekeying
* wake up on GTK rekey failure
* wake up on EAP identity request
* wake up on rfkill release
software interface modes (can always be added):
* AP/VLAN
* monitor
valid interface combinations:
* #{ managed } <= 1, #{ AP } <= 1,
total <= 2, #channels <= 1, STA/AP BI must match
* #{ managed } <= 2,
total <= 2, #channels <= 1
HT Capability overrides:
* MCS: ff ff ff ff ff ff ff ff ff ff
* maximum A-MSDU length
* supported channel width
* short GI for 40 MHz
* max A-MPDU length exponent
* min MPDU start spacing
Device supports TX status socket option.
Device supports HT-IBSS.
Device supports SAE with AUTHENTICATE command
Device supports scan flush.
Device supports per-vif TX power setting
Driver supports a userspace MPM
Device supports static SMPS
Device supports dynamic SMPS
Device supports configuring vdev MAC-addr on create.

WPS / King Office - Some formula symbols might not be display correctly due to missing fonts: Wingdings, Wingdings 2, Wingdings 3 (FIXED)

I just installed WPS on my machine.. and received a warning said :
Some formula symbols might not be display correctly due to missing fonts: Wingdings, Wingdings 2, Wingdings 3

Well, this warning still exist since the earlier Alpha version that I tested 1 years ago. I don't know why they still didn't fix this problem. Here, I share how to fix this problem :
$ cd ~/.fonts
$ wget -c http://api.kriptonium.com/wps_symbol_fonts.zip
$ unzip wps_symbol_fonts.zip
$ rm wps_symbol_fonts.zip
$ sudo fc-cache -vf

Thursday, November 19, 2015

SELinux - Check http boolen status

$ sudo getsebool -a | grep httpd
httpd_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_check_spam --> off
httpd_can_connect_ftp --> off
httpd_can_connect_ldap --> off
httpd_can_connect_mythtv --> off
httpd_can_connect_zabbix --> off
httpd_can_network_connect --> on
httpd_can_network_connect_cobbler --> off
httpd_can_network_connect_db --> on
httpd_can_network_memcache --> off
httpd_can_network_relay --> off
httpd_can_sendmail --> off
httpd_dbus_avahi --> off
httpd_dbus_sssd --> off
httpd_dontaudit_search_dirs --> off
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> off
httpd_execmem --> off
httpd_graceful_shutdown --> on
httpd_manage_ipa --> off
httpd_mod_auth_ntlm_winbind --> off
httpd_mod_auth_pam --> off
httpd_read_user_content --> off
httpd_run_ipa --> off
httpd_run_preupgrade --> off
httpd_run_stickshift --> off
httpd_serve_cobbler_files --> off
httpd_setrlimit --> off
httpd_ssi_exec --> off
httpd_sys_script_anon_write --> off
httpd_tmp_exec --> off
httpd_tty_comm --> off
httpd_unified --> off
httpd_use_cifs --> off
httpd_use_fusefs --> on
httpd_use_gpg --> off
httpd_use_nfs --> off
httpd_use_openstack --> off
httpd_use_sasl --> off
httpd_verify_dns --> off

Tuesday, November 17, 2015

Fedora - Installing RabbitVCS



$ sudo dnf install python-simplejson rabbitvcs*
$ nautilus -q

PHP / MySQL - Converting a Date to MySql Formatted Date

function dateconvert($date,$func) {
    if ($func == 1){ //insert conversion
      list($day, $month, $year) = split('[/.-]', $date); 
      $date = "$year-$month-$day"; 
      return $date;
    }
    if ($func == 2){ //output conversion
      list($year, $month, $day) = split('[-.]', $date); 
      $date = "$day/$month/$year"; 
      return $date;
    }
}
Credit : https://chrismckee.co.uk/converting-a-date-to-mysql-formatted-date/

Fedora - Enable htaccess rules by AllowOverride setting

Peace be upon you, by default Apache is configured to ignore some or all directives in .htaccess files. This is for security reasons. The AllowOverride directive controls which features will be allowed in .htaccess files. For example AllowOverride None can turn off htaccess files for a folder and its subfolders. All you need it to setting Apache web server configuration file.
# vi /etc/httpd/conf/httpd.conf
Then go to line 151 and change AllowOverride None with AllowOverride All.

Next, reload you Apache webserver with new setting
# systemctl restart httpd.service

Sunday, November 15, 2015

Form File Upload Limits With PHP

$arrayMaxes = array(
    'upload_max_filesize' => intval(ini_get('upload_max_filesize')),
    'post_max_size' => intval(ini_get('post_max_size')),
    'memory_limit' => intval(ini_get('memory_limit'))
);
$maxUploadSize = min($arrayMaxes);
foreach ($arrayMaxes as $key => $value) {
    if ($value == min($arrayMaxes)) {
        $minimumOfThree = $key;
        break;
    }
}

echo "The maximum file size you can upload is $maxUploadSize, this is due to the php.ini setting $mininimumOfThree";

Credit : http://edmondscommerce.github.io/php/form-file-upload-limits-with-php.html

PhpMyAdmin - Login without a password is forbidden by configuration (see AllowNoPassword)


You need to turn on the option AllowNoPassword on file /etc/phpMyadmin/config.inc.php. Simply run :
$ sudo vim /etc/phpMyAdmin/config.inc.php
and change AllowNoPassword from FALSE to TRUE:
$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

Saved, then you can access phpMyAdmin without password.

Saturday, November 14, 2015

Fedora 23 - LAMP - Linux, Apache, MySQL And PHP


Currently, I'm using Gnu/Linux Fedora 23 Gnome. I need to setup a working LAMP environment but I not familiar yet with RPM based distro and after some research, I figure out this tutorial.

First thing, you need to update your repository at first :
$ sudo dnf update
Then, lets begin to install Apache web server and MySQL database server (Not familiar with Nginx dan MariaDB yet):
$ sudo dnf install httpd
$ sudo dnf install community-mysql-server
Now install PHP engine
$ sudo dnf install php php-mysql
Do you need PhpMyAdmin? I always need that
$ sudo dnf install phpmyadmin 
* Tutorial : Allow no password on PhpMyAdmin

Start Apache and MySQL services via systemctl:
$ sudo systemctl start httpd.service
$ sudo systemctl start mysqld.service
If you are using Gnome desktop enviroment, I recommend you to install this LAMP status extension :
https://extensions.gnome.org/extension/990/lamp-status/

By default web server is only accessible as localhost. To allow access publicly to the LAMP over HTTP and HTTPS, you need to configure the firewall rules and after that reboot or reload the firewall:
$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --permanent --add-service=https
$ sudo firewall-cmd --reload 

Linux - Restart network after updating DNS

$ sudo systemctl restart NetworkManager
$ cat /etc/resolv.conf

Friday, November 13, 2015

Fedora 23 - Install fendy with WGET

Well, I don't like cURL. Because of my company proxy setting. So I made a custom Fedy installer that use wget..
#!/bin/bash

# Script to install Fedy < http://folkswithhats.org/ >.
# Copyright (C) 2014  Satyajit sahoo
# Custom by kriptonium - 13/11/2015

if [[ ! $(whoami) = "root" ]]; then
    echo "Please run the script as root."
    exit 1
fi

echo "Downloading RPM files.."
wget http://folkswithhats.org/repo/$(rpm -E %fedora)/RPMS/noarch/folkswithhats-release-1.0.1-1.fc$(rpm -E %fedora).noarch.rpm
wget http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
wget http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

echo "Adding repositories..."
rpm --quiet --query folkswithhats-release || dnf -y --nogpgcheck install folkswithhats-release-1.0.1-1.fc$(rpm -E %fedora).noarch.rpm
rpm --quiet --query rpmfusion-free-release || dnf -y --nogpgcheck install rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
rpm --quiet --query rpmfusion-nonfree-release || dnf -y --nogpgcheck install rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

echo "Installing fedy..."

dnf -y --nogpgcheck install fedy

echo "Delete RPM files.."
rm folkswithhats-release-1.0.1-1.fc$(rpm -E %fedora).noarch.rpm
rm rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
rm rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
# Please report bugs at < http://github.com/folkswithhats/fedy/issues >
# End of the Script

$ wget https://gist.githubusercontent.com/Kriptonium/e863d954d2f2ada224e7/raw/b8d65862ffede6c5a1b3155e8b6987fdcde741cc/fedy-installer-custom
$ sudo chmod +x fedy-installer-custom
$ sudo ./fedy-installer-custom

Fedora : DNF with proxy

# dnf update
Error: Failed to synchronize cache for repo 'fedora' from 'https://mirrors.fedoraproject.org/metalink?repo=fedora-23&arch=x86_64': Cannot prepare internal mirrorlist: Curl error (28): Timeout was reached for https://mirrors.fedoraproject.org/metalink?repo=fedora-23&arch=x86_64 [Connection timed out after 120000 milliseconds]

Currently, I using Gnu/Linux Fedora 23. If you are working behind a proxy server just like me, then you have to edit the file /etc/dnf/dnf.conf so that DNF can know which proxy setting to use.

# gedit etc/dnf/dnf.conf

Then add proxy=http://proxy:port at end of the file. Example :
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=true
proxy=http://192.168.100.252:8080

References:
  1. http://dnf.readthedocs.org/en/latest/conf_ref.html
  2. https://docs.fedoraproject.org/en-US/Fedora/
  3. http://linoxide.com/how-tos/yum-replace-dnf




Tuesday, November 10, 2015

Snippet - My Bahasa Malaysia Bootstrap data table

Peace be upon you,

Bootstrap table with Data Tables

I am fan of bootstrap design for my website design. But I still need another scripting for my table component which is about filter, sort and navigation. DataTable are my favorites script. It keep my HTML table so clean and breeze. Here, I share with you, my personal language configuration in Malay:

<script type="text/javascript">
        $('#bootstrap-table').dataTable( {
            "ordering": false,
            "language": {
                "search": "Carian:",
                paginate: {first:    '<<',previous: '<<',next:     '>>',last:     '>>'},
                "info": "Paparan halaman _PAGE_ daripada _PAGES_ halaman",
                "lengthMenu": "Lihat _MENU_ rekod per halaman",
                "infoEmpty":      "",
                "infoFiltered":   "(Tapisan carian daripada _MAX_ rekod maklumat)",
                "zeroRecords":    "Tiada padanan carian di temui"
            }
        } );
</script>

Kudos for Datatables for this excellent and wonderful add-on to my bootstrap design :)

Sunday, November 8, 2015

XAMPP : Automate MySQL database backup

Well, this is a simple script that allow you to backup MySQL database on Windows. I just ripped off several code on internet and make my own version. Such a script kiddie, huh? Wait, If you let this script run with Windows Task Scheduler in certain time, it will be automate MySQL database backup, Wohaa. Read this beruk bodo as you references. Plus, this script use 7zip to compress the SQL file which quite useful to save the our precious disk usage (Download here). Change thus variable (at line 11-16) with you own setting, before execute this script. Each backup are saved in separated directory, sort by date and time during backup process ..That all, K..bye!

Tuesday, November 3, 2015

Problem :
Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\dev\session.php on line 3

Solution : Open session.php and replace session_start();(line 3) with this code
if(!isset($_SESSION)){
    session_start();
}

Sunday, November 1, 2015

XAMPP - Mailer Error: Extension missing: openssl

I helped my friend to build a web based system and we have a features that allow system to send new password if users forgot they password. I use PhpMailer class for the mailing function. On top of that, we use stack XAMPP as our production playground. Then I found this problem :
Mailer Error: Extension missing: openssl

After some google-fu, I need to enable OpenSSL extension from my PHP configuration file. So, just open C:/xampp/php/php.ini with you favorite text editor such notepad++, sublime-text or else. Then goto line 636 and remove ; and just left extension=php_openssl.dll and save your files. Now restart Apache, MySQL services and problem solved.

Saturday, October 31, 2015

Semantic Versioning

If you notice, software development usually released their software product with some label or using version numbers. There is many ways of naming convention rules that developer use for their software label / version. I prefer to use numbering formatted as MAJOR.MINOR.PATCH as references and it look much professional, right? If you need more information, come and read guidance wrote by Tom Preston Werner (inventor of Gravatars and cofounder of GitHub) about semantic versioning at SemVer.org.

As summary, just follow the rules:
  1. MAJOR version when you make incompatible API changes,
  2. MINOR version when you add functionality in a backwards-compatible manner, and
  3. PATCH version when you make backwards-compatible bug fixes.

Git - Remove directory / folder from remote repository

git rm -r --cached Directory-Folder
git commit -m "Removed Directory-Folder from repository"
git push origin master

Monday, October 26, 2015

Updating OwnCloud via terminal

[email protected] [~/public_html/cloud]# ./occ upgrade
-bash: ./occ: Permission denied
[email protected] [~/public_html/cloud]# chmod +x occ
[email protected] [~/public_html/cloud]# ./occ upgrade
ownCloud or one of the apps require upgrade - only a limited number of commands are available
Set log level to debug - current level: 'Debug'
Checked database schema update
Checked database schema update for apps
Updated database
Updating <files_texteditor> ...
Updated <files_texteditor> to 2.0
Updating <gallery> ...
Updated <gallery> to 14.2.0
Updating <files> ...
Updated <files> to 1.2.0
Updating <activity> ...
Updated <activity> to 2.1.3
Updating <files_sharing> ...
Updated <files_sharing> to 0.7.0
Updating <files_trashbin> ...
Updated <files_trashbin> to 0.7.0
Updating <files_versions> ...
Updated <files_versions> to 1.1.0
Updating <provisioning_api> ...
Updated <provisioning_api> to 0.3.0
Update successful
Maintenance mode is kept active
Reset log level to 'Debug'

[email protected] [~/public_html/cloud]# cd config/
[email protected] [~/public_html/cloud/config]# ls
./  ../  .htaccess  ca-bundle.crt  config.php  config.sample.php
[email protected] [~/public_html/cloud/config]# nano config.php

Saturday, October 24, 2015

Proper git commit message

$ git log
commit c5a016458849fce834f7d0d85i90167acbd8e30d
Author: Kriptonium <[email protected]>
Date:   Sat Oct 24 03:44:51 2015 +0800

    Bugfix #1 :  Could not render and output PDF with HtmlToPdf class.

    Problem :
    After user click "cetak" from "Rekod Penempatan" menu, cetak_pdf.php
    will be trigger and the rendering process will started and output file
    as PDF format unfortunately, HTML codes inside rekod_penempatan.php
    are not properly close and PDF output file cant be processed.

    Solution :
    Reformat the HTML table with proper closing tags and remove inline CSS
    from the HTML table.

Thursday, October 22, 2015

HTML + JS : Disable Input if another input selected (onChange)

<script type="text/javascript">
        function carianMelalui() {
            var carian = document.getElementById('cari');
            var katakunciPegawai = document.getElementById('katakunciPegawai');
            var katakunciLokasi = document.getElementById('katakunciLokasi');
            var flag = document.getElementById("flag");

            if ((carian.value == "pegawai") || (carian.value == "lokasi")) {
                var pilih = carian.value
                if (pilih == "pegawai") {
                    katakunciPegawai.disabled = false
                    flag.value = "pegawai"
                }
                if (pilih == "lokasi") {
                    katakunciLokasi.disabled = false
                    flag.value = "lokasi"
                }
            } else {
                katakunciPegawai.disabled = true
                katakunciLokasi.disabled = true
            }
        }
    </script>

<form id="form1" name="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <p>
    <select id="cari" onchange="carianMelalui()">
        <option value='0'>Carian melalui nama pegawai / lokasi :</option>
        <option value='pegawai'>Pegawai</option>
        <option value='lokasi'>Lokasi</option>
    </select>
    <select id="katakunciPegawai" name="pegawai" disabled>
        <option value=""> Pilihan Nama Pegawai</option>
    </select>
    <select id="katakunciLokasi" name="lokasi" disabled>
        <option value=""> Pilihan Nama Lokasi</option>
    </select>
    <input type="hidden" name="flag" id="flag" value="">
    <input type="submit" name="mulaMencari" value="Cari">
    </p>
</form>

Monday, October 19, 2015

Git push to multiple remote host (HTPPS)

Peace be upon you,
Some of my project need to have multiple remote repository git hosting. Well, I figure out how to push to multiple remote host by adding the SSH access or HTTPS url. So I pasted my git bash command so you guys can studies the command. In this example, i use bitbucket as my primary repo and gitlab as backup repo. Check it out...

$ git remote -v
origin https:[email protected]/danish/my-project.git (fetch)
origin https:[email protected]/danish/my-project.git (push)

$ git remote set-url --add --push origin https:[email protected]/danish/my-project.git
$ git remote set-url --add --push origin https:[email protected]/danish/my-project.git

$ git remote -v
origin https:[email protected]/danish/my-project.git (fetch)
origin https:[email protected]/danish/my-project.git (push)
origin https:[email protected]/danish/my-project.git (push)

$ git push origin master
Counting objects: 2, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1/1), done.
Writing objects: 100% (2/2), 232 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 1 (delta 1)
To https:[email protected]/danish/my-project.git
   42c6244..791ced9  master -> master

Counting objects: 2, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1/1), done.
Writing objects: 100% (2/2), 232 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 1 (delta 1)
To https:[email protected]/danish/my-project.git
   42c6244..791ced9  master -> master

Do you understand from here? Sorry, I'm to busy this month. I hope you can learn from this example.. Wassalam ~

Sunday, October 18, 2015

Snippet - PHP select option from database differ with default

<select class="form-control" name="lokasi" required="true">
 <? /* Get current value in selected row as first option value */ ?>
 <option value="<?php echo $row['lokasi']; ?>"><?php echo $row['lokasi']; ?></option>

 <? /* Gelt list of option in another table */ ?>
 <?php
 $BlokBilik = $row['lokasi'];
 $sql = "SELECT * FROM lokasi";
 $result1 = mysql_query($sql) or die("Error : " . mysql_error());
 while ($rowLokasi = mysql_fetch_array($result1)) {
     $lokasi = $rowLokasi['blok'] . " / " . $rowLokasi['bilik'];
     /* Compare string are same or not */
     if (strcmp($lokasi, $BlokBilik) != 0) {
         echo "<option value='" . $lokasi . "'>" . $lokasi . "</option>";
     }
 }
 ?>
</select>

Sunday, October 11, 2015

Sublime Text Codeformatter - Format error: [Errno 2] No such file or directory: '/home/username/.config/sublime-text-3/Packages/CodeFormatter/codeformatter/lib/phpbeautifier/php_beautifier'



Peace be upon you, Still remember about codeformatter package for SublimeText editor in my previous post? Well today, I boot into my Ubuntu 15.04 (Vivid) operating system and install this codeformatter package and tried to use it and it throw me with error :
Format error:
[Errno 2] No such file or directory: '/home/username/.config/sublime-text-3/Packages/CodeFormatter/codeformatter/lib/phpbeautifier/php_beautifier'

I read the README file, the developer ask linux users to chmod +x php_beautifier file but I still get this error. Hmm..what should I do?

Wednesday, October 7, 2015

Sublime Text - Reformat (beautify) source code for html / css / php / json / js /pthon


Just sharing ST2/3 package to beautify html/css/php/json/js/pthon codes. Mostly I use phpstorm to reformat code within my project files. But when I need to edit a single files, sublime-text are my choice. Just open ugly code file with ST, press ctrl+alt+f or ctrl+shift+p and type "format" and press enter, Ohh, I am very glad to see this clean structured codes.

Install this tool by searching "CodeFormatter" from package install control.
Read the instruction and details from here (https://github.com/akalongman/sublimetext-codeformatter).

Monday, October 5, 2015

Adding RM (Ringgit Malaysia) prefix to bootstrap input box


Well, I need a Ringgit Malaysia (RM) prepend on my bootstrap input box. After some reading, I got an idea and this is the result. Yeay!
<div class='col-sm-4'>
    <div class='form-group'>
        <label for="user_title">Harga perolehan</label>
        <div class="input-group">
            <span class="input-group-addon">RM</span>
            <input type="text" class="form-control" placeholder="00.00">
        </div>
    </div>
</div>

Friday, October 2, 2015

Application launcher for Android Studio in Ubuntu

Open "/home/<username>/.local/share/applications" Create file name "android-studio.desktop" with this code below :
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Icon=/home/<username>/tools/android/android-studio/bin/idea.png
Exec="/home/<username>/tools/android/android-studio/bin/studio.sh" %f
Comment=Android Studio developer environment
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-android-studio

Then saved that file. Now this menu available at you application dash.


If you find this to nerd..just open Android Studio => Tools =>Create desktop Entry..and here you go!

Thursday, October 1, 2015

Remove Wordpress FTP Credentials (localhost)


Need to deactivate unused wordpress plugin in my local host. But the Wordpress throwing error and asking FTP connection credential. If you encounter problem with this (refer picture), what you just need to do are chmod and chown recursively the folder :

$ sudo chown -R daemon /opt/lampp/htdocs/
$ sudo chmod -R g+w /opt/lampp/htdocs/

Wednesday, September 30, 2015

Tuesday, September 29, 2015

Get latest files from master branch and overwrite local files

Peace be upon you,
Sometimes, I forgot to commit the local changes and after a few days when I opened the project, I getting lost of what I am doing, So I prefer to sync back my local files with current head from master branch and over write file locally then start coding back from fresh.

git fetch
git reset --hard origin/master
git clean -f -d

Using git fetch command will fetch and import commits from a remote repository into our local repo, then the git reset --hard origin/master will reset our index and working tree, any changes before this will be discarded.

Friday, September 25, 2015

Search inside file content using GrepWin with Windows


Well, Windows operating system allow us to search inside file content by activating it from advance search menu but I prefer using alternative tools which allow me to use regular expression (RegEx) for more precise result. For now, I using GrepWin.

You can downnload GrepWin binary and source code at SourceForge : http://sourceforge.net/projects/grepwin/. Just right click on you target folder and start digging and searching the content that you want to find.

Display last record from MySQL table row

SELECT * FROM 
   penyelengaraan 
WHERE 
   penyelengaraan.noSiriTag = 'd123' 
ORDER BY 
   penyelengaraan.idPenyelengaraan 
DESC LIMIT 1

Thursday, September 24, 2015

Wednesday, September 23, 2015

Hide default databases from phpmyadmin

Peace be upon you,
My favorite database are MySQL and PhpMyAdmin are the database administration that I use very frequently. MySQL and PhpMyAdmin comes with default configuration database such information_schema etc. Thus database that I not interact directly, I just interact with my own database set for my web application. So why not, we just hide these database from PhpMyAdmin?

Just locate and open \phpMyAdmin\config.inc.php with your favorite text editor (I use SublimeText3) and add this regex code:
/* hide database from phpmyadmin */
$cfg['Servers'][$i]['hide_db'] = '^(information_schema|performance_schema|mysql|phpmyadmin|cdcol|foo|webauth)$';

Then reload / restart your apache and mysql, and see changes on http://localhost/phpmyadmin, check it out on the left side. Now, we just see our own created database only.

Alternative way:
Open and browse "PhpMyAdmin" > Click on "Setting" tab > Then click on "Feature" tab and paste this code within "Hide database" field
^(information_schema|performance_schema|mysql|phpmyadmin|cdcol|foo|webauth)$

Thus default database are just hide from PhpMyAdmin and If you are using tool such MySQL Workbench, NaviCat, HeidiSQL,RazorSQL software or else, thus database still there and available. Hope this tips are useful. That all for now. Wassalam...

Wednesday, September 16, 2015

Easy way to convert phonegap into APK or IOS apps file

I saw someone from industrial training facebook group asking how to convert PhoneGap into Android APK. The answer and the easier way is using Phonegap Build. No need to setup SDK and compile by yourself, just upload the WWW directory and download the build of apps then install into your device.

Monday, September 14, 2015

Reload / restart Ubuntu unity desktop environment without logout



Sometimes, I need to reload or restart my Ubuntu unity desktop environment when needed. Mostly I just logout the computer but now I figure out that there are easy way to reload unity:

1. Press Alt+F2 from you keyboard to run a command.
2. Type unity --replace and press Enter.

Our computer screen will flicker for awhile and return to normal a few seconds later.

Friday, September 11, 2015

Google Maps - Latitude & longitude

<?php
/* 
* Given an address, return the longitude and latitude using The Google Geocoding API V3
*
*/
function Get_LatLng_From_Google_Maps($address) {

    $url = "http://maps.googleapis.com/maps/api/geocode/json?address=$address&sensor=false";

    // Make the HTTP request
    $data = @file_get_contents($url);
    // Parse the json response
    $jsondata = json_decode($data,true);

    // If the json data is invalid, return empty array
    if (!check_status($jsondata))   return array();

    $LatLng = array(
        'lat' => $jsondata["results"][0]["geometry"]["location"]["lat"],
        'lng' => $jsondata["results"][0]["geometry"]["location"]["lng"],
    );

    return $LatLng;
}

/* 
* Check if the json data from Google Geo is valid 
*/

function check_status($jsondata) {
    if ($jsondata["status"] == "OK") return true;
    return false;
}

?>

Source : http://gauravraimca.blogspot.my/2014/12/google-maps-converting-address-to.html

Thursday, September 10, 2015

Git proxy connection

Add proxy into git global configuration :
$ git config --global http.proxy "IP address:Port"

Remove proxy from git global configuration:
$ git config --global http.proxy ""

Check git global proxy configuration:
$ git config --global http.proxy

Wednesday, September 9, 2015

Checking which local branch is tracking which remote branch in Git?

For all branches:
git branch -avv

For local branches only:
git branch -lvv

shows you all branches as well as the name of the upstream branch.

Source : http://serverfault.com/questions/175052/how-to-tell-which-local-branch-is-tracking-which-remote-branch-in-git

Change git remote from SSH to HTTPS

Peace be upon you.. My office has strict network rules which filtered by proxy on port 8080 and does not allow me to use SSH connection to fetch and pull on my git repository. I tried to use subversion a.k.a svn as alternative but I not familiar with the command and GUI tool such RapidSVN on linux are not very helpful. Then, I google-fu and found that git support HTTPS connection too! Wohaa..good!

Let's check our current remote repository URL:
$ git remote -v
Now change our remote's URL from SSH to HTTPS with the git remote set-url command:
$ git remote set-url origin https:[email protected]/wawang/sistem_repo.git
* I use Bitbucket as example above, means it depends on your git hosting provider
* Bitbucket URL format : https://<username>@bitbucket.org/<username>/<reponame>.git
* Github URL format : https://github.com/<username>/<reponame>.git

Now, verify the remote repository URL using the git remote -v command. Easy right? That all,Peace!

Monday, September 7, 2015

How to change JasperSoft iReport locale

Tool -> option -> tab "report" -> tab "compilation and execution" -> tab "execution option" -> report locale

Thursday, September 3, 2015

Laravel 5 - No supported encrypter found. The cipher and / or key length are invalid

Hey, I got an error msg said my laravel 5 installation went wrong :
RuntimeException in compiled.php line 6779:
No supported encrypter found. The cipher and / or key length are invalid.
in compiled.php line 6779
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in compiled.php line 1086
at Container->build(object(Closure), array()) in compiled.php line 1039
at Container->make('encrypter', array()) in compiled.php line 1577
at Application->make('Illuminate\Contracts\Encryption\Encrypter') in compiled.php line 1131
at Container->resolveClass(object(ReflectionParameter)) in compiled.php line 1115
at Container->getDependencies(array(object(ReflectionParameter)), array()) in compiled.php line 1101
at Container->build('App\Http\Middleware\EncryptCookies', array()) in compiled.php line 1039
at Container->make('App\Http\Middleware\EncryptCookies', array()) in compiled.php line 1577
at Application->make('App\Http\Middleware\EncryptCookies') in compiled.php line 9274
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in compiled.php line 2776
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9274
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in compiled.php line 9264
at Pipeline->then(object(Closure)) in compiled.php line 2053
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2036
at Kernel->handle(object(Request)) in index.php line 54

We need to create a random of 32 char string as application key. Just run the command and get the access key:
$ php artisan key:generate

Copy that generated key and put it inside /config/app.php file, for example :
'key' => env('APP_KEY', 'ql9xRk2DuYTdl8QJrmjmRCfRx3kyCZC2'),

Dont forget to give write permission for /storage directory (chmod -R 755 are enough for that).

Wednesday, September 2, 2015

How to enable PHP debugging with XAMPP for Linux and XDebug

Peace be upon you.. I decide to learn debugging PHP web application using XAMPP for Linux and XDebug. This tutorial are based from XAMPP for Linux 5.6.11, but it suppose will be valid in future because I using xdebug that provided with the XAMPP and I just enable it.

Let's check our PHP installation with php --version command
$ php --version
PHP 5.6.11 (cli) (built: Aug 10 2015 20:47:04) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
* Note : If the output said about Xdebug version, it mean you PHP already debug enable and else are not enable yet.

The another way to check is to read from PHP info, just create a new file with code below and execute from our localhost:
<?php phpinfo() ?>
* Note : Find "xdebug" using ctrl+f and if you found this section it mean you PHP already debug enable and else are not enable yet.

Now, I assume our PHP does not enable Xdebug yet.. and we are going to enable it by edit /opt/lampp/etc/php.ini file
$ gksudo  gedit /opt/lampp/etc/php.ini
Add this line inside that file :
zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
And now, restart the server and after that we can run / debug the PHP web application :
$ sudo /opt/lampp/xampp restart
So easy right? That all we need, Thanks.

Composer - /usr/bin/env: php: No such file or directory

Today, I setup LAMPP (XAMPP) and laravel PHP framework with Ubuntu 15.04 but when I want use composer, this problem occur :
$ sudo composer install
/usr/bin/env: php: No such file or directory
The solution is to symlink the PHP cli with the bin path:
$ sudo ln -s /opt/lampp/bin/php /usr/local/bin/php
Nice and well played :)

SEMINAR ON COMPUTER SCIENCE SPECIAL TOPICS 2015, FSKTM, UTHM


Just another throwback memory of Seminar on Computer Science Special Topics 2015 on 26th May 2015 and held at FSKTM, UTHM. This event was handled by final year undergrad students and I was appointed as Program Director and Leader for software engineering course and and Chief of Secretary for the main groups of computer science (Combination of Software Engineering, Multimedia, Info Security and Web Technology students).

Our speakers and special topic discussed are :
1. Software Engineering - Gaining Experience with Open Source Software by En. Mohd Kamal Mustafa and En. Salahuddin Hairai.
2. Web Technology - Web Development Trends and Predictions for 2015 by En. Ahmad Zaman Nuri.
3. Multimedia - Venturing Into Serious Game Development by En. Helmi Adly Mohd Noor.
4. Info Security - Cyber Crime, role of MCMC, Smart click by En. Syed Isa Syed Shekh Alsagoff.

After speak session, we have an forum about Career and direction for Computer Science student after graduation. We also manage to get HP (Hewlett-Packard) Malaysia for walk-in interview for internship at my faculty.

My special thanks to friends, lecturer, speakers and JomWeb Johor.

That all I want to share... wassalam

Wednesday, August 26, 2015

How to : Export Data From Mysql To Excel (Spreadsheet) With PHP

Peace be upon you, This tutorial will demonstrate how to export / convert our PHP data set from MySQL into Excel spreadsheet document. I hope this tutorial knowledge will be useful for us. Without delay our time, let go through with our example. First we need to create a database, called "my_kripto_db" with one table called "users" and 3 column which is idusers, username and password. Just import and execute SQL file below:
CREATE DATABASE  IF NOT EXISTS `my_kripto_db`;
USE `my_kripto_db`;

DROP TABLE IF EXISTS `users`;

CREATE TABLE `users` (
  `idusers` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(45) DEFAULT NULL,
  `password` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`idusers`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

Lets insert a couple of dumb data into this database table :
INSERT INTO `users` VALUES (1,'Sera','nasikLemak1'),(2,'Mika','tehtarikkopi0');

We a done with database, and lets get our hand dirty by wrote our PHP code which I named as "data.php" which later will be use to query and display this data into tables when requested from web server by users.
<html>
<head>
 <title></title>
</head>
<body>
<table border="1">
    <tr>
     <th>No</th>
  <th>Username</th>
  <th>Password</th>
 </tr>
 <?php
 //connection to mysql
 mysql_connect("localhost", "root", ""); //server , username , password
 mysql_select_db("my_kripto_db");
 
 //query get data
 $sql = mysql_query("SELECT * FROM users ORDER BY idusers ASC");
 $no = 1;
 while($data = mysql_fetch_assoc($sql)){
  echo '
  <tr>
   <td>'.$no.'</td>
   <td>'.$data['username'].'</td>
   <td>'.$data['password'].'</td>
  </tr>
  ';
  $no++;
 }
 ?>
</table></body>
</html>

From this "data.php" table, we will export it into Excel spreadsheet document by sending a header function and let users download the file when this "data-set.php" are executed:
<?php
// Sending raw excel header 
header("Content-type: application/vnd-ms-excel");
 
// Defines the name of the export file "kriptonium-data.xls"
header("Content-Disposition: attachment; filename=kriptonium-data.xls");
 
// Add data table
include 'data.php';
?> 

Done and this is our result :

Thursday, August 20, 2015

MySQL - Check all database size and free size in MB

SQL command :
SELECT table_schema "Data Base Name", 
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB", 
sum( data_free )/ 1024 / 1024 "Free Space in MB" 
FROM information_schema.TABLES 
GROUP BY table_schema ;

Example result:
+--------------------+----------------------+------------------+
| Data Base Name     | Data Base Size in MB | Free Space in MB |
+--------------------+----------------------+------------------+
| e-virtue           |           0.06250000 |       0.00000000 |
| ict_iptho          |           0.07812500 |       0.00000000 |
| information_schema |           0.00976563 |       0.00000000 |
| mysql              |           0.78106689 |       0.00000000 |
| performance_schema |           0.00000000 |       0.00000000 |
| spppm              |           0.02952194 |       0.00000000 |
| sptrba_db          |           0.14062500 |       0.00000000 |
+--------------------+----------------------+------------------+
8 rows in set (0.02 sec)

Saturday, August 1, 2015

Wednesday, June 10, 2015

VB.net - Sanitize file name to remove illegal characters such * : \ / < > | " ? [ ] ; = + & £ $

When you develop a system that allow user to upload file, you need to take care the file types, permission and it name. To avoid naming convention that are illegal, you need to sanitize file name and remove any illegal character and replace the character with something else such underscore ("_") which is acceptable. Below are the code you neeed.
private static string MakeValidFileName(string name)
{
  string invalidChars = Regex.Escape( new string( Path.GetInvalidFileNameChars() ) );
  string invalidReStr = string.Format( @"[{0}]+", invalidChars );
  return Regex.Replace( name, invalidReStr, "_" );
}
This function are very helpful for filtering file name using regular expression (regex) and GetInvalidFileNameChars() function. For file path, you can change it with GetInvalidPathChars() function to sanitize file path from your input.