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/