Saturday, December 24, 2016

Rsync .ssh keys and permissions

I've had the same ssh keys for years. I just rsync them to a new system when I get one. I always seem to end up with mucked up permissions moving them around and never seem to remember how the permissions were set. Here's my reminder.
~/.ssh 700
~/.ssh/authorized_keys 600
~/.ssh/config 644
~/.ssh/id_dsa 600
~/.ssh/ 644
~/.ssh/known_hosts 644

Saturday, November 26, 2016

Ubuntu - ApacheBench

$ sudo apt install apache2-utils
$ ab -c 50 -n 5000

Fix Apache Error: Could not reliably determine the server’s fully qualified domain name

$ sudo systemctl status apache2
● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
   Active: inactive (dead)
     Docs: man:systemd-sysv-generator(8)

Nov 26 00:48:49 kripx systemd[1]: Stopped LSB: Apache2 web server.
Nov 26 00:49:04 kripx systemd[1]: Starting LSB: Apache2 web server...
Nov 26 00:49:04 kripx apache2[8738]:  * Starting Apache httpd web server apache2
Nov 26 00:49:04 kripx apache2[8738]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the ' ServerName' directive globally to suppres

Just open apache2.conf via your terminal
$ sudo nano /etc/apache2/apache2.conf

Put ServerName localhost at end of the file, then restart you Apache service.

Thursday, November 24, 2016

My programmer setup (UBUNTU)

This is just a public raw post.. Just as note for myself about my so called "dev-machine" setup. I am Fedora lovers but most of my VPS are running on Ubuntu and Centos. My computer at office are running Ubuntu LTS.
$ sudo apt-get install \
vim \
vim-gnome \
git-cola \
meld \

I use Git for tracking my source code changes for a few projects. I don’t work in it that much, so it is nice to have a GUI for certain things. The git-cola package has done that nicely in the past. Installing it also installs the actual git application.

I am not depend on IDE for my task, but some php project that use framework need IDE such Phpstorm to speed-up you project.
$ sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
$ sudo apt update
$ sudo apt install ubuntu-make
$ sudo umake ide phpstorm

Do you use SublimeText editor? It awesome!!
$ sudo add-apt-repository ppa:webupd8team/sublime-text-3
$ sudo apt-get update
$ sudo apt-get install sublime-text-installer

Hmm.. what should I write now.. ** blank **

Database - 15 Ways to Kill Your MySQL Application

Tuesday, November 22, 2016

Linux - Permission /var/www/html

Problem :
fatal: could not create work tree dir '/var/www/html/secret': Permission denied

Solution :
$ sudo usermod -a -G www-data <username> 
$ sudo chown -R www-data:www-data /var/www
$ sudo chmod -R g+rwX /var/www

Sunday, November 6, 2016

How to - Enable MySQL Server Remote Connection in Ubuntu 16.04

By default MySQL Server on Ubuntu run on the local interface, This means remote access to the MySQL Server is not Allowed. To enable remote connections to the MySQL Server we need to change value of the bind-address in the MySQL Configuration File.

Open the /etc/mysql/mysql.conf.d/mysqld.cnf file, then change bind-address = into bind-address =, then saved you changes.

Now restart mysql services via systemctl restart mysql.service command. MySQL Server now running on the socket 0 instead of on all network interface, which allow remote connection.

Plus, now you can add remote user by following how to create new user and grant remote access on mysql tutorial post. Bye!

Monday, October 24, 2016

PHP - Detect Facebook user agent

    print "Facebook User-Agent detected!";

Monday, October 17, 2016

How to fix : Cannot login MySQL without sudo command (Ubuntu)

1. Log MySQL with sudo command
sudo mysql -u root

2. Drop current [email protected] account
mysql> DROP USER 'root'@'localhost';

3. Recreate your user *without password
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '';

4. Give all database and table permissions to your root user then flush privileges
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';

Done! Now you can use MySQL without sudo command. I suggested you to restart MySQL services after this work around. bye!

Tuesday, October 11, 2016

PHP Fatal error: Call to undefined function bccomp() - Ondřej PHP PPA

I am using PPA from Ondřej for my PHP project, seem the default installation does't came with bcmath library.
Stack trace:
1. {main}() /var/www/html/
Fatal error:  Call to undefined function bccomp() in /var/www/html/

Fix it by enter this command :
$ sudo apt install php5.6-bcmath
$ sudo apt install php7.0-bcmath
$ sudo apt install php-bcmath
Ref :

How to - Convert MkDocs to PDF

I has been requested to create website that will use as Term of Services and Privacy Policy on our services, I am dealing with future changes and I want people get alert and know what has been modified soon. I found out creating simple static page are more convinince. I'am using MkDocs - Project documentation with Markdown as the platform which is quite simple. This documentation site are using markdown and python. I recorded any changes using our private git as tracker. Simply just install Python and PIP then pull mkdocs via pip command. The problem is, MkDocs does't have any built in PDF converter so we need to install pandoc, mkdocs-pandoc and few Tex library to compile the documentation into PDF.

$ sudo pip install pandoc
$ sudo pip install mkdocs-pandoc
$ sudo apt-get install texlive-full

To convert written MkDocs into PDF just type this command :
$ mkdocs2pandoc > myFile.pd
$ pandoc --toc -f markdown+grid_tables+table_captions -o myFile.pdf myFile.pd

That all, Adios!

Sunday, September 18, 2016

Facebook Open Graph for Osclass

My team of developer are upgrading our online market places which using osclass cms. After we are done, we found the the theme doesn't header dont have meta for facebook open graph to display title, description and image. I found solution here, which you need to open the \oc-content\themes\YOUR-THEME-NAME\common\head.php file and paste the code below
<meta property="og:title" content="<?php echo osc_item_title() ; ?>" />
<meta property="og:description" content="<?php echo osc_highlight(strip_tags(osc_item_description()), 140) ; ?>" />
<?php if( osc_count_item_resources() > 0 ) { ?>
<meta property="og:image" content="<?php echo osc_resource_url(); ?>" />
<?php } else { ?>
<meta property="og:image" content="PUT-YOUR-DEFAULT-IMAGE-HERE" />
<?php } ?>

Wednesday, August 31, 2016

MySQL - InnoDB Imports (Faster)

mysql> use database_Name
mysql> set autocommit=0; set unique_checks=0; set foreign_key_checks=0;
mysql> source /path/to/database_dump.sql
mysql> commit; set unique_checks=1; set foreign_key_checks=1;

Friday, August 26, 2016

MySQL - Case sensitive for database name in Windows

Hi there! I'm have problem on my windows machine with LAMP stack environment to maintenance existing web system that has been deploy on Linux server. I create a copy of database and import on my local MySQL. The original database consist of lowercase and uppercase letter database name but when after imported it convert to lowercase database name that causing stupid mess error and waste lot of time!

I about MySQL collation of insensitive case and sensitive case but it seem valid on tables only, not the database name itself. I figure a work around to force MySQL on windows to store it on disk with case sensitive names.

Open you MySQL location folder and open my.ini file, insert lower_case_table_names=2 and restart the MySQL service. Done!

Friday, August 12, 2016

MySQL / MariaDB - Show warning details

mysql> flush privileges;                                                 
Query OK, 0 rows affected, 5 warnings (0.08 sec)                         
mysql> \w;                                                               
Show warnings disabled.                                                  
No query specified                                                       
mysql> show warnings;                                                    
| Level   | Code | Message                             |                 
| Warning | 1292 | Truncated incorrect time value: 'N' |                 
| Warning | 1292 | Truncated incorrect time value: 'N' |                 
| Warning | 1292 | Truncated incorrect time value: 'N' |                 
| Warning | 1292 | Truncated incorrect time value: 'N' |                 
| Warning | 1292 | Truncated incorrect time value: 'N' |                 
5 rows in set (0.00 sec)

Tuesday, August 9, 2016

CodeIgniter - htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

Friday, July 22, 2016

Fedora - Checking boot time, verify journal log, calculate journal log size and clean logs

$ systemd-analyze
Startup finished in 1.569s (kernel) + 5.077s (initrd) + 1min 36.483s (userspace) = 1min 43.131s

$ systemd-analyze blame
     1min 8.481s plymouth-quit-wait.service
         51.288s dnf-makecache.service
         10.577s systemd-udev-settle.service
          9.210s dev-sdb6.device
          8.583s systemd-journal-flush.service
          8.491s libvirtd.service
          7.880s firewalld.service

$ journalctl --disk-usage
Archived and active journals take up 656.1M on disk.

$ du -sh  /var/log/journal
657M    /var/log/journal

$ journalctl --verify
000000: Invalid tail monotonic timestamp                                                                                                             
File corruption detected at [email protected][email protected]rnal:6502ed0 (of 109051904 bytes, 97%).
FAIL: [email protected][email protected]rnal (Bad message)
PASS: [email protected][email protected]l            
PASS: [email protected]67b01ae6-23ce9c5d42e3dba7.journal~                                            
PASS: [email protected]bbbf8870-02b44febe18a6235.journal~                                            
5aa8278: Unused data (entry_offset==0)                                                                                                               
PASS: [email protected]45c23726fd6-d4b9e97e2b2c7246.journal~                                         
PASS: [email protected]1bfe8603-b0df6d6afd47b76d.journal~                                            
PASS: [email protected]59dbb3e2-cdd6e212043dc4bf.journal~                                            
PASS: [email protected]01a4efc4-2a7a09659026f270.journal~                                            
PASS: /var/log/journal/0cfa1379b4e94fd4bd1cdc4bb20a8a25/user-1000.journal                                                                            
000000: Invalid tail monotonic timestamp                                                                                                             
File corruption detected at [email protected]7ccb5cc8-168a8bb731df29f9.journal~:ee6b38 (of 16777216 bytes, 93%).
FAIL: [email protected]7ccb5cc8-168a8bb731df29f9.journal~ (Bad message)
PASS: [email protected]59d7468c197-df87dd623a6a7deb.journal~                                         
PASS: /var/log/journal/0cfa1379b4e94fd4bd1cdc4bb20a8a25/system.journal                                                                               
PASS: [email protected]c7e54f38-1ff1cfcb111bc56b.journal~                                            
PASS: [email protected]57804ffa241-e7dc957cecea3ba5.journal~                                         
PASS: [email protected]6fa407a3-8e3c6afba238749a.journal~                                            
PASS: [email protected]149fbd05-2893f465d26bbe5a.journal~     

$ ls /var/log/journal/0cfa1379b4e94fd4bd1cdc4bb20a8a25/* 
[email protected]149fbd05-2893f465d26bbe5a.journal~
[email protected]67b01ae6-23ce9c5d42e3dba7.journal~
[email protected]bbbf8870-02b44febe18a6235.journal~
[email protected]c7e54f38-1ff1cfcb111bc56b.journal~
[email protected]1bfe8603-b0df6d6afd47b76d.journal~
[email protected]01a4efc4-2a7a09659026f270.journal~
[email protected]6fa407a3-8e3c6afba238749a.journal~
[email protected]59dbb3e2-cdd6e212043dc4bf.journal~
[email protected]7ccb5cc8-168a8bb731df29f9.journal~
[email protected][email protected]l
[email protected]45c23726fd6-d4b9e97e2b2c7246.journal~
[email protected]57804ffa241-e7dc957cecea3ba5.journal~
[email protected]59d7468c197-df87dd623a6a7deb.journal~
[email protected][email protected]rnal

$ sudo rm -rf /var/log/journal/0cfa1379b4e94fd4bd1cdc4bb20a8a25/* 

Wednesday, June 29, 2016

Coding Is Over - Lauren Mendoza

When many products are essentially the same app with different color schemes and copy, why are we still coding?

The files in your computer can be represented in multiple ways. The way most people find their files is with a visual interface, like Mac Finder. But you could also do all the same things using a text-based interface like the Terminal. These are multiple ways to model and interact with the same information.

A web application can be represented in many ways too; An architecture diagram, a conversation, mockups. As working software engineers, we usually interact with code. But is this the most intuitive and productive approach?


I used to make electronic music with a program called Reason. I loved it because it let you drag and drop wires between different machines, showing you exactly how everything was connected. To me, the visual wires made a lot more sense than an endless array of menus and dropdowns, which was prevalent in the cutting-edge software of the 2000's. (I luv u Adobe Flash CS3 Professional) Because of Reason’s interface, I had a deeper understanding of what I was doing, and I made a lot more music than I made Flash movies.

We Need More Fun

I don’t know when or how it happened, but at some point, “IT person” became “developer” which became “software engineer”. I love being called an engineer, especially after only three months of “education”. But most of what we do is not engineering. Being an engineer is about solving new problems, and about deep thinking. It’s intellectual work.

Thousands of CRUD apps have already been built. We’ve already solved that problem. But for some reason, we’re still building more of the same apps, mostly from scratch.

Once a problem has been solved, that solution should be applied to other similar problems. A template of instructions is handed off to a worker, or a factory of workers, to duplicate the design as needed. We don’t tell each worker in a car factory to design a new car from scratch. Instead, we give workers a template, and we make it impossible for them to mess things up. When the instructions are so easy anyone can follow them, it becomes a menial job. More than that, it becomes a robot’s job.

Engineers should be solving new and interesting problems, not rebuilding the same apps over and over. That is a job for robots.

Same great website, now with more CSS

It is a proven fact (probably) that the more “original” your UI design, the less people will understand how to use it. It is counterproductive to reinvent established visual language. The internet would work much better if we agree on a handful of common elements, and then express our meaning by combining those. Styles should generate themselves based on a few keywords like “make it metal, black, and evil”, or “make it business, respectable, and blue”, “make it hipster and fun and Apple", or “make it cute and appeal to moms”. At no point should we be typing code to move something over by 5 pixels.

Ego Problems

Coding is revered by many as the holy grail of software engineering. Real engineers code, they say, and coding is what makes you a great engineer. A lot of people have attached their egos and their identities to coding. These people probably need counseling, and I don’t say that flippantly. I am becoming one of these people.

But knowing fancy syntax and “coding skillz” does not make you a good engineer and it does not make you smart. You can be a great coder and a horrible engineer. Devising better, faster, scalable, creative ways to solve real people’s problems is what is valuable, and this will become increasingly true in the coming years.

Coding is super dumb

Coding allows for typos. More than that, it allows for infinite “creativity”, also known as code smells. Most code is pretty rank. Engineers spend countless hours dealing with syntax, typos, indentation, linting, errors, arguing over style and best practices, and making shortcuts to try to coax some of the code to type itself. It’s absurd. And it’s a waste of time.

We’re already there

GraphQL eliminates backend routes and will completely replace REST in the coming years. Have you ever wondered why we need a server acting as a middleman between the client and the database? This should be abstracted away yesterday.

Algolia makes a pile of data searchable. I’m not sure how they do it. But what I do know is, a computer is cheaper and better at optimizing structured data than a human is.

We should be throwing data into a pile and databases should organize and optimize themselves using machine learning and other buzzwords. People should not be writing database schemas, because we inevitably get it wrong. Database design is an optimization algorithm, not an area of engineering.

Engineers around the world are re-writing things like authentication, shopping carts, messaging, and countless other ubiquitous features. And a lot of them are probably feeling pretty cool about it.

These are just a few examples of how engineers waste time duplicating the same basic features over and over.

Good For Engineering Culture

Software engineers are grossly overpaid, and many (I) feel entitled to the money and benefits they (I) enjoy. In reality, software engineers are not smarter or better than any other type of worker. With the death of coding, diversity will increase. Engineering will reflect the rest of society, rather than favoring a very small and socioeconomically exclusive subset of people.


Basically, Moneyball is a great movie. I know it’s old, but I just watched it last night, and I was gonna try and relate this all back to this awesome movie, but I didn’t. And I don’t even care.

You Know What Else Would be Cool?

Building stuff in virtual reality. I just bought one of these and it’s dope.

Sunday, June 5, 2016

NodeJS : Using nodemon

To easier development process on NodeJS project, we need a server that able to auto-reload source code during coding. A tool called as 'Nodemon' are needed to support our need :
$ npm install -g nodemon
Then when you want to run and auto-reload source code :
$ nodemon <put-your-script-here>.js
Another benefit of nodemon are it can run run source code with coffee script formatted. Good luck!

Saturday, June 4, 2016

Forensic - metadata

Exiftool -a Perl application for editing metadata in a wide variety of files.
exiv2 - a C++ application to manage image metadata
jhead - a jpeg header manipulation tool
pdfparanoia - a tool to remove watermark from academic papers
Mat - a toolbox composed of a GUI application, a CLI application and a library, to anonymize/remove metadata.

Apache - Allow htaccess rule on Fedora

When using laravel framework for php, we better use clean URL. For that reason we need to allow .htaccess rewrite so that Laravel will be able to display clean urls.

Open up your Apache configuration file and edit it :
$ sudo vi /etc/httpd/conf/httpd.conf
Change AllowOverride None to AllowOverride ALL within <Directory "/var/www/html"> tag
<Directory "/var/www/html">
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    # The Options directive is both complicated and important.  Please see
    # for more information.
    Options Indexes FollowSymLinks

    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    AllowOverride ALL

    # Controls who can get stuff from this server.
    Require all granted
Then restart Apache to reload our new configuration
$ sudo systemctl restart
It is not really recommended to edit your Apache configuration file with the above mentioned method but it is good enough for a small project.

Fedora / Centos / RHEL - Installing Adminer

$ git clone
$ sudo cp -r adminer/* /var/www/html
$ sudo systemctl start httpd

Wednesday, June 1, 2016

What happen to you ?!

” You think you want to die, but in reality you just want to be saved. “

Monday, May 30, 2016

Sublime Text 3 - Show whitespace and tabs on editor

I still learning how to use VIM but my preferable editor stilll Sublime Text FTW! I wrote some bash script today and whitespace are too sensitive for unix. Let's handle it properly, okey?

1) Open Sublime Text editor
2) Click on "Preference"
3) Choose "Setting - user"
4) Now, add "draw_white_space": "all" after the curly braces (put on tops of other setting)
5) Press Ctrl+S
6) Done! Now tabs show up as dashes, while spaces are dots.

That all for now..Wasssalam ~

Software Wars!

Thursday, May 26, 2016

Installing NodeJS 4.4.* (LTS) on Fedora 23

I was switch to use Ubuntu 16.04 LTS about 3 week ago, seem APT still suck to manage repos and pulling to much data bandwidth with deb compressing format. Now I switch back to Fedora 23 and I missed DNF so much..LOL, enough with the unnecessary chit-chat.

When I using the official Fedora repo, seem version of nodejs a to far behind and I prefer to use LTS version. Thank god, I found someone make a COPR repo for nodejs
$ sudo dnf copr enable voor/nodejs-lts
$ sudo dnf install nodejs
Yeah, Awesome...

Update : Hmm.. now switching to NVM (Node Version Manager)

Tuesday, May 24, 2016

Unix - View JSON format in terminal

I learning NodeJS and I play a lot with JSON formated data. It realy mess-up when you want to curl any JSON ouput into terminal. My solution is to use json package via npm :
$ sudo npm install -g json

Let's check some example :
$ curl -X GET "" | json
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   407    0   407    0     0    352      0 --:--:--  0:00:01 --:--:--   352
  "metadata": {
    "generated_at": "2016-05-24 15:58:06",
    "total_result": 2,
    "zone": {
      "id": "JHR04",
      "name": "Batu Pahat, Muar, Segamat, Gemas"
  "data": [
      "date": "2016-05-24",
      "imsak": "5:28",
      "subuh": "5:38",
      "syuruk": "6:59",
      "zohor": "13:08",
      "asar": "16:32",
      "maghrib": "19:14",
      "isyak": "20:28"
      "date": "2016-05-25",
      "imsak": "5:28",
      "subuh": "5:38",
      "syuruk": "6:59",
      "zohor": "13:08",
      "asar": "16:32",
      "maghrib": "19:14",
      "isyak": "20:28"

NodeJS - npm via proxy

Add proxy :
$ npm config set proxy
$ npm config set https-proxy

Remove proxy (unix) :
$ npm config rm proxy
$ npm config rm https-proxy
$ unset HTTP_PROXY
$ unset http_proxy
$ unset https_proxy

Remove proxy (Windows) :
npm config delete proxy
npm config delete https-proxy

Saturday, May 21, 2016

Solved - Server unable to read htaccess file, denying access to be safe

I create a custom virtual host on my apache for my current web project which is I called it as "" and directed/located at my dropbox folder /home/krip-hensem/Dropbox/Coding/manja-dev, let have a look at our site config file :
$ cat /etc/apache2/sites-available/ 

        <VirtualHost *:80>
            ServerAdmin [email protected]
            DocumentRoot /home/krip-hensem/Dropbox/Coding/manja-dev
            <Directory />
                AllowOverride All
            <Directory /home/krip-hensem/Dropbox/Coding/manja-dev>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Require all granted
            ErrorLog /var/log/apache2/
            LogLevel error
            CustomLog /var/log/apache2/ combined

But then, I got an error message that telling :
You don't have permission to access / on this server.
Server unable to read htaccess file, denying access to be safe

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request."

The heck! I tried to chmod .htaccess file with 644 permission. But nothing happen. It getting my nerve, so I check the error log :
$ cat /var/log/apache2/
[Sat May 21 03:03:06.126741 2016] [core:crit] [pid 13917] 
(13)Permission denied: [client] 
AH00529: /home/krip-hensem/Dropbox/.htaccess pcfg_openfile: 
unable to check htaccess file, ensure it is readable and that '/home/krip-hensem/Dropbox/' is executable

Auww.. This is kacang! Just need to let the *bold* folder executable, just ran an chmod command :
$ sudo chmod 755 /home/krip-hensem/Dropbox/
Tango! The problem just solved! Alhamdulillah..

Wednesday, May 18, 2016

How to use - Google doc to embed and view on your website

<iframe style="width: 100%; height: 500px;"
src="< YOUR PDF FILE LOCATION HERE>&amp;embedded=true" 
width="300" height="150" frameborder="0"></iframe>

Saturday, May 14, 2016

Vagrant - The guest additions on this VM do not match the installed version of VirtualBox!

Each time when I ran vagrant up, I will get this annoying message:
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default: Guest Additions Version: 4.3.28
default: VirtualBox Version: 5.0
==> default: Setting hostname...

My VM image using the older VirtualBox Guest Additions tool than my Oracle VirtualBox installed on my machine. This cause my shared folder unable to mount and sync correctly. Now, let upgrade our tool:

1. Mount VBoxGuestAdditions.iso as optical disk drive (located at Oracle Virtualbox installed folder)

2. Run VM via Oracle Virtualbox or SSH inside our VM and install the linux kernel headers and the basic developer tools
$ sudo apt-get install linux-headers-$(uname -r) build-essential dkms

3. Run the shell script on your VM to install the guest additions.
$ sudo sh /media/cdrom/

Now restart / halt you VM. Next time when booting, the vagrant doesnt give the annoying message anymore and Oracle VirtualBox should able to mount the shared folder correctly.

Wednesday, May 11, 2016

Powershell - View wifi password using psget module

> (new-object Net.WebClient).DownloadString("") | iex
> Install-Module WiFi-Password
> Show-WiFiPassword
Password : 1122XX3344YY556677ZZ8899 
Auth type : WPA2-Personal

Sunday, May 8, 2016

Friday, May 6, 2016

MSSQL - Search string in all table on a database via query declaration


DECLARE @SearchStr nvarchar(100) = 'STRING_YOU_WANT_TO_FIND'
DECLARE @Results TABLE (ColumnName nvarchar(370), ColumnValue nvarchar(3630))


DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET  @TableName = ''
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')


    SET @ColumnName = ''
    SET @TableName = 
        WHERE         TABLE_TYPE = 'BASE TABLE'
            AND    OBJECTPROPERTY(
                        QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
                         ), 'IsMSShipped'
                           ) = 0

    WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)

        SET @ColumnName =
            WHERE         TABLE_SCHEMA    = PARSENAME(@TableName, 2)
                AND    TABLE_NAME    = PARSENAME(@TableName, 1)
                AND    DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar', 'int', 'decimal')
                AND    QUOTENAME(COLUMN_NAME) > @ColumnName

        IF @ColumnName IS NOT NULL

            INSERT INTO @Results
                'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630) 
                FROM ' + @TableName + ' (NOLOCK) ' +
                ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2

SELECT ColumnName, ColumnValue FROM @Results

MSSQL - Search string in all tables on a database via stored procedure

Query to create programmability stored procedure :

CREATE PROC SearchAllTables
    @SearchStr nvarchar(100)

    CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))


    DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
    SET  @TableName = ''
    SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')

    WHILE @TableName IS NOT NULL

        SET @ColumnName = ''
        SET @TableName =
            WHERE         TABLE_TYPE = 'BASE TABLE'
                AND    QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
                AND    OBJECTPROPERTY(
                            QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
                             ), 'IsMSShipped'
                               ) = 0

        WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)

            SET @ColumnName =
                WHERE         TABLE_SCHEMA    = PARSENAME(@TableName, 2)
                    AND    TABLE_NAME    = PARSENAME(@TableName, 1)
                    AND    DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar', 'int', 'decimal')
                    AND    QUOTENAME(COLUMN_NAME) > @ColumnName

            IF @ColumnName IS NOT NULL

                INSERT INTO #Results
                    'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
                    FROM ' + @TableName + ' (NOLOCK) ' +
                    ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2

    SELECT ColumnName, ColumnValue FROM #Results


To start searching, please create new query tab and put this code

DECLARE @return_value int

EXEC @return_value = [dbo].[SearchAllTables]

SELECT 'Return Value' = @return_value


Thursday, May 5, 2016

Fixed - Unable to open the physical file (attach) on MSSQL server

Problem :
Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file "C:\beruk\mung\Databases.mdf". Operating system error 5: "5(Access is denied.)".

Solution :
  1. Press Win+R (Run dialog)
  2. Type services.msc on open dialog and press OK
  3. Search service name of SQL Server (MSSQLSERVER) or SQL Server (SQLEXPRESS) depending on you server instance name.
  4. Right click > Properties
  5. Click on Log On tab menu
  6. Select Local Account and press OK
  7. Right click on service name again and choose Stop
  8. Right click on service name again and choose Start
Now, open SQL Server 20** management studio and login as usual, try to attach you database. It should worked as expected.  

Tuesday, May 3, 2016

MSSQL - Check Microsoft SQL server version information

Peace be upon you, I tried to copy database from network server to localhost server and the operation are failed and it give me notice that said:
The destination server cannot be a SQL Server 2005 or later Express instance.
From the error message, we know that my MSSQL server on my network using old MSSQL version which is 2005. But how to check it by yourself? It is very simple, just open new query and type SELECT @@VERSION, the you will get the MYSSQL server version information..wo0t! Just a simple knowledge sharing here, I hope it useful for us. Wassalam~

Note : If you get message just like I quote above, it mean you can't copy database but you can export to *.mdf and *.ldf file via right click on database > "task" > "export" as you working solution :)

Monday, May 2, 2016

Linux - Check which network card are used to connect internet network

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    600    0        0 wlp2s0   U     600    0        0 wlp2s0     U     1000   0        0 virbr0   U     0      0        0 virbr0 UGH   600    0        0 wlp2s0


SELECT [Code_no]
FROM [DB_name].[dbo].[Table_name]
WHERE [Created_Date] BETWEEN '2016-04-18' AND '2016-04-20 23:59:59.999'
ORDER BY [Created_Date] asc

Sunday, May 1, 2016

Database disaster prevention by Olek Nilson (Microsoft SQL)

Disclamer: This article was taken from DineSQL blog and this post is written by Olek Nilson. All credit goes to them.

Database disaster prevention is one of the greatest pains in life of every DBA. Data from database are changing daily, gradually expanding the size of the latter. Of course, there is no perfect way to prevent database corruption, but there are some practical steps that can help you to bring the risk to minimum.

It’s important to say a few words about Microsoft Corporation. In spite of the fact that SQL Server is 100% Microsoft product, the company does not provide any means to protect your database, meaning that database protection completely up to the user.

Below we would like to discuss cases that can trigger database disaster.

One of the most popular cases that can potentially cause database corruption is hardware failure, for example, incorrect work of Disk, CPU or Memory Module.

Another thing that can corrupt your database is Antivirus software. Please note that after your antivirus software is installed, all SQL Server Database Files should be excluded from being scanned by the Antivirus software.

The next issue that can potentially damage your database is a desire to save free space on the local disk. Based on my personal experience, there were some users who stored all SQL Server database files in zip or 7zip files to save some space on their disks. Ultimately, these actions lead to a database failure. If you desperately need free space, you can use third party tool to make database backups with compression and store them online.

Another important thing that will help you to prevent database disaster is setting up the latest updates for SQL Server and Windows. Otherwise it will cause incorrect working of your shift.  

And do not forget about the case with a power failure that may lead to all databases being corrupted.

It is not an exhaustive list of failures that can destroy your database. So what shall we do to prevent database disasters and minimize the risk? You have to remember that there is no perfect way or method that will ensure 100% protection for your database. However, the best thing that can help you to minimize the risk of the database corruption is to make scheduled database backups. Database backups cannot prevent the corruption, but they can help you to restore the database with minimal losses.   

It is recommended that all experienced DBAs should make regular database backups. This leads to a question  – How often should I make backups or what backup strategies should I employ? Before answering this question, please consider yet another question - How much data can you afford to lose? Working as a DBA, I have had a great many databases to restore and I can say that the more quality backups you have the less data you will eventually lose. 

Presently there are three ways to make database backups:
  1. Using T-SQL commands:

    If you prefer using T-SQL command you have to keep in mind that you need to make database backups all the time. Even you have to create a schedule and carefully stick to it. Perhaps, make backups with the help of T-SQL commands are comfortable if the database is not large and grows slowly. But in the most cases changes in the database are taking place all day and night, so how do make backups at night? Of course, to solve this issue you can find in the Web scripts for making schedule backups.

    So, if you make the decision to make database backups with the help of T-SQL use the following commands:
    -- To make a full database backup use the following command:
    BACKUP DATABASE AdventureWorks TO DISK = 'Z:\SQLServerBackups\AdventureWorks.bak'
    -- Use the following command to make a differential backup:
    BACKUP DATABASE AdventureWorks TO DISK = 'Z:\SQLServerBackups\AdventureWorksDiff.bak' WITH DIFFERENTIAL
    -- The following command will help you to make a transaction log backup:
    BACKUP LOG AdventureWorks TO DISK = 'Z:\SQLServerBackups\AdventureWorksLog.bak'
  2. With the help of SSMS (SQL Server Management Studio):

    Using SSMS for making backups is a little bit easier then make backups with the help of T-SQL commands. You don't need to write commands every time when you are going to make a backup it is enough to make a couple simple steps, which we described below. It has to be admitted that you can also make scheduled backups with the help of SSMS, but it will take more efforts from you.

    To make a backup please:
    a. Right-click on the database you want to backup
    b. Select “Tasks”, then “Back up…”
    c. Choose “Backup type"
    d. Add backup destination
    e. Click “OK”
  3. Or use third party tools; You can choose such enterprise solutions as SQL Backup Pro from RedGate, something similar to SqlBackupAndFtp, or try out if you prefer SAAS model.
In my opinion, this is the best way for making scheduled database backups. Here everything you need is to create the job for the scheduled backups and run the application. The third party tool will make backups according to the schedule.

     So, if your databases are growing fast and there are many changes occurring every hour, it would be better to choose “maniacal” backup plan, for example, it is a Full database backup every 24 hours, a Differential backup every three hours and make transaction log backups every 15 minutes. Yes, perhaps it will take more time to restore your database should failure occur, but the percentage of data loss will be minimal.

    Friday, April 29, 2016

    Linux - Check if Android Studio emulator using KVM or not

    $ lsof -e /run/user/1000/gvfs | grep /dev/kvm
    qemu-syst 14818                 kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    QXcbEvent 14818 14842           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14868           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14869           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14870           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14871           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14872           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14873           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14874           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14875           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    threaded- 14818 14876           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14877           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14878           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14898           kripx   26u      CHR             10,232        0t0        564 /dev/kvm
    MainLoopT 14818 14899           kripx   26u      CHR             10,232        0t0        564 /dev/kvm

    Wednesday, April 20, 2016

    Linux - Random MAC address at boot (systemd)

    1. Determine you wireless adapter name:
    $ iwconfig | grep 802.11bg

    2. Create and edit /etc/systemd/system/macspoof@.service file for a new startup service as superuser / root
    Description=macchanger on %I
    ExecStart=/usr/bin/macchanger -r %I

    3. Enable this script run each time you linux is booted
    $ sudo systemctl enable macspoof@wlp2s0.service
    * Note : Please replace "wlp2s0" with you adapter card name on step 1

    4. Now reboot you computer and after booted, check you current MAC address:
    $ macchanger --show wlp2s0
    Current MAC:   ea:f7:07:3f:fa:b8 (unknown)
    Permanent MAC: 25:7d:9f:uc:k7:c0 (Intel Corporate)

    Linux - Installing GitKraken from tar.gz files

    This is simple tutorial how to install GitKraken version 1.1.0 for my laptop which using Gnu/Linux Fedora 23 x86_64

    $ wget
    $ tar -xvzf gitkraken-amd64.tar.gz 
    $ sudo rsync -va --delete-after GitKraken/ /opt/GitKraken/

    Sunday, April 3, 2016 configuration for UTHM internal network bad, I spend 3 hours figure why my gradle unable to fetch dependencies from Maven / JCentral repository for my Android project. To keep it short (Yes! I'm so busy) I put my configuration file here. It will pass proxy exception for both JVM and Gradle then...boom, now gradle able to fetch and sync dependency file.

    Notes : I also put gradle for parallel compilation, allowing demon daemon (for faster build process) and increase JVM max heap size..

    Saturday, March 12, 2016

    The difference between native, web & hybrid mobile applications

    NodeJS + Ionic : Fixing " Error: Cannot find module 'wordwrap' "

    $ ionic
    throw err;
    Error: Cannot find module 'wordwrap'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object. (/usr/lib/node_modules/ionic/node_modules/optimist/index.js:3:16)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)


    $ sudo npm install -g wordwrap

    NodeJS + Ionic : Fixing " Error: Cannot find module 'wordwrap "

    $ ionic
    throw err;
    Error: Cannot find module 'wordwrap'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object. (/usr/lib/node_modules/ionic/node_modules/optimist/index.js:3:16)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)

    $ sudo npm install -g wordwrap

    NodeJS + Ionic : Fixing " Error: Cannot find module 'archiver' "

    $ ionic
    throw err;
    Error: Cannot find module 'archiver'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object. (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/utils.js:3:16)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

    $ sudo npm install -g archiver

    NodeJS + Ionic : Fixing " Error: Cannot find module 'xmlbuilder' "

    $ ionic start todo blank
    throw err;
    Error: Cannot find module 'xmlbuilder'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object. (/usr/lib/node_modules/ionic/node_modules/xml2js/lib/xml2js.js:12:13)
    at Object. (/usr/lib/node_modules/ionic/node_modules/xml2js/lib/xml2js.js:436:4)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)

    Solution :
    $ sudo npm install -g bplist-parser xmlbuilder

    Preparing ionic development enviroment (Fedora 23)

    It is quite simple and straight foward..
    $ sudo curl --silent --location | bash -
    $ sudo dnf nodejs
    $ sudo npm install -g cordova
    $ sudo npm install -g ionic

    If you have module problem when creating object, try to install the modules
    $ sudo npm install -g bplist-parser xmlbuilder archiver wordwrap winston

    Saturday, March 5, 2016

    Git - Remove all file in repository based on gitignore file

    $ git rm -r --cached .
    $ git add .
    $ git commit -m "Removing all files in .gitignore"

    Tuesday, March 1, 2016

    Joomla! security jday2015 - Security Hardening by Shaiffulnizam Mohamad

    Security hardening : suPHP

    Use suPHP
    PHP files are run under the user of the website instead of the Apache user and globally reset all files (user,group,file and directory):
    $ sudo chown -R user:group *
    $ sudo find . -type f -exec chmod 644 {} \;
    $ sudo find . -type d -exec chmod 755 {} \;

    Saturday, February 27, 2016

    10 Things I Look For When I Interview People by Sinsee Ho

    What do I look for in my candidates? To start off, let me point out there is a slight difference between wearing the hat of a Recruitment Consultant/Headhunter for an employment agency and that of the Interviewer/Hiring Manager for an internal hire. Here’s why: the Recruitment Consultant has more than one client/employer that he/she is servicing as compared to a Hiring Manager that interviews a candidate for a specific job and position. In the latter, certain specific behaviors in line with the culture of the company would be something to look out for, which may not be the case for a Recruitment Consultant.

    For someone donning the hat of a Recruitment Consultant, the things I look out for would be more general in nature and any serious job seeker would have the following checked:

    1. Well-groomed -  say whatever you like but good grooming gives candidates a great advantage. To me, this is a simple principle. People that take time to choose what to wear for interviews are serious job seekers and give respect to the occasion. So, I say thumbs up to ladies that wear make-up and men that choose to wear a tie even under a hot day. Nothing beats a good first impression!
    2. Display a “likeable” disposition -  likeable does not mean being charming, cute or trying to flirt with the interviewer. It simply means wearing a genuine smile, be polite, make the right greetings, wait before you are asked to sit, good eye contact and etc. No one is totally comfortable with strangers, including the interviewers. A smile can melt ice and it’s true. So before any question is asked, smile!
    3. Good posture -  do not underestimate the power of good posture. It projects the person’s energy and enthusiasm. If you can’t even sit upright during an interview, you probably can’t do that on any occasion. This reason alone may not cut you off immediately but you certainly would not want your interviewer to doubt your personality
    4. Clear expression of thoughts -  verbal communication is key to a successful interview. You may have a lot of knowledge and experience but if you are unable to express them clearly, you lose marks. Technical people such as Programmers and Engineers seem to struggle quite a bit in this aspect. To be able to explain clearly is a skill. If you know this is your weakness, my advice is that you take time to practice it before hand. Write them down or find a partner to practice. If your partner can’t understand what you are sharing, most likely the Interviewer can't too.
    5. Quiet confidence -  Being confident does not mean you have to shout every word you speak. Quiet confidence comes from within. If you know your stuff and able to explain it well, you will naturally exudes confidence. In other words, this ties closely with what you know and your ability to communicate that.
    6. Answer the questions posed -  seems an easy feat, isn’t it? Unfortunately, some candidates choose to give answers to their own questions. And it can be rather embarrassing because it means two things: either you are not listening or you did listen but were not able to comprehend what was asked. My advice is if in doubt, do not be afraid to ask the Interviewer to clarify the question.
    7. Listen then speak -  although in an interview setting, the candidates are expected to speak more than the Interviewer but that does not mean you do not know when to stop and listen. Speak up only when you are given the cue. A bad habit is when the candidate interjects on every sentence or trying to finish off the question by the Interviewer.
    8. A few good stories -  arm yourself with some good stories. Questions such as “What was your greatest achievement?”, “Please elaborate a challenging task that you managed to overcome” and etc. would require you to tell a story from your past.
    9. Good preparation -  it means you bring along your updated resume, photo, original and copied certificates, and other related documents. And if you know what job you are being interviewed for, do some prior homework will give you a huge advantage.
    10. Ask appropriate questions -  appreciate candidates that ask questions, albeit appropriate ones. That shows the candidate had done some thorough thinking before the interview, an indication that he/she is serious about the job.

    The key is this: work with your Recruitment Consultants or Headhunters by being cooperative. Your goal is to ensure you are “marketable”.

    Friday, February 26, 2016

    Git Commands and Best Practices Cheat Sheet

    Fedora : Installing & removing Vuze / Azureus torrent application

    Installing :
    $ wget
    $ tar -xjvf VuzeInstaller.tar.bz2
    $ sudo rm -rf /opt/vuze*
    $ sudo mv vuze /opt/vuze

    Create application launcher (using Alacarte) :

    Removing (uninstall) :
    $ sudo rm -r /opt/vuze /usr/bin/vuze

    Tuesday, February 16, 2016

    Unix : Move and replace existing files and directory using rsync command

    $ sudo rsync -va --delete-after sublime_text_3 /opt/sublime_text_3/
    building file list ... done
    sublime_text_3/Packages/Batch File.sublime-package
    sublime_text_3/Packages/Color Scheme - Default.sublime-package
    sublime_text_3/Packages/Language - English.sublime-package
    sublime_text_3/Packages/Regular Expressions.sublime-package
    sublime_text_3/Packages/Theme - Default.sublime-package
    sent 3,958,228 bytes  received 1,046 bytes  7,918,548.00 bytes/sec
    total size is 3,953,429  speedup is 1.00

    Sunday, February 7, 2016

    MonoDevelop - Could not connect to the debugger.

    This morning I spent my time to learn C# programming language.. Somehow I pissed with Java which eat to much memory. I use MonoDevelop to train my self. I don't use Microsoft Visual Studio and booting into Windows.. I grab and learn "C# Fundamentals for Absolute Beginners" from MVA (Microsoft Virtual Academy).

    But I faced a problem here, seem MonoDevelop are not compatible with Gnome desktop environment. Alternatively, you need to launch it from the Gnome terminal and use xTerm terminal as program out put.

    1. Install xTerm terminal first (Skip if you already installed this program)
    2. Open Gnome terminal and give this command:
    $ monodevelop

    If you hate to give terminal command each time you launch MonoDevelop, you can put unset GNOME_DESKTOP_SESSION_ID inside you MonoDevelop run script.

    Let find where you script are located:
    $ which monodevelop 
    $ ls -l /usr/bin/ | grep "monodevelop"
    -rwxr-xr-x.   1 root root         775 Feb  7 11:19 monodevelop
    Then, modify that "monodevelop" file using any text editor with root privilege such gedit. Here my modified script:

    #!/usr/bin/env bash
    unset GNOME_DESKTOP_SESSION_ID # <-- add this code
    #Workaround for Unity gnome shell
    # Ubuntu overlay scrollbars are not working well with the 1px boundaries in the monodevelop shell
    # The Oxygen GTK theme crashes unless this is set
    #this script should be in $PREFIX/bin
    MONO_EXEC="exec -a monodevelop mono-sgen"
    if [ -n "$_MD_REDIRECT_LOG" ]; then
     mkdir -p `dirname "$_MD_REDIRECT_LOG"`

    Now you can use MonoDevelop and do some awesome kung-fu with CSharp..r0x!