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 } ?>