[Phpmyadmin] Temporary disable phpmyadmin how to?

December 19, 2016

Phpmyadmin is an easy tools to have visualize interface to access database. If it is not in use, better to disable it to protect your site from hack or SQLInjection, You do not want to remove it, because in future it might be needed again, so just disable it in a simple way and enable […]

Building ‘_imagingft’ extension error command ‘cc’ failed with exit status 1

November 3, 2015

This error is due to freetype header missing. _imagingft.c:73:10: fatal error: ‘freetype/fterrors.h’ file not found #include <freetype/fterrors.h> ^ 1 error generated. error: command ‘cc’ failed with exit status 1  First, verify freetype is installed. With brew: brew install freetype If freetype installed, warning message shows: Warning: freetype-2.5.5 already installed Next to fixed the issue, is […]

Screen Shot 2015-11-03 at 11.33.25 AM

Pip Install error: invalid command ‘bdist_wheel’ Mac Os

November 3, 2015

Install the wheel package first: pip install wheel If requirement already satisfied, you will see: Requirement already satisfied (use –upgrade to upgrade) Then, you should update your setuptools: pip install setuptools –upgrade Run again pip install, it should works now!

python validate string allowed only spaces, alphabet and numbers

September 29, 2015

Using pattern matching, this is not hard to achieve. To check that each character matches your requirements Regular expression “^[a-zA-Z0-9_]*$” With spaces checking: “^[a-zA-Z0-9_ ]*$” Code example: if allow_special_char == False: import re if not re.match(“^[a-zA-Z0-9_ ]*$”, gname): print “Invalid” Regular expression refer from http://stackoverflow.com/a/336220/1903116 reference: http://stackoverflow.com/questions/19970532/how-to-check-a-string-for-a-special-character

PHP get first day of current month, datepicker friendly

December 22, 2014

The simplest and readable way to do it is using this clean solution. All you need is a string represent the date. First day of the month: Last day of the month:

MySql find all tables with specific column/field name

December 8, 2014

How to look up in the entire DB and list out all tables which have specific column name or field name? Example belows looks for field `currency` from all database: To add specific database to the query, use:

PHP script execution time tracking wallclock time

December 1, 2014

A simple way to find out execution time of php script without lots of calculation is tracks the wallclock time. Compare to tracking CPU time, it also include time that PHP is sat waiting for external resources such as disks or databases, which is not used for max_execution_time. Output: Execution time get user: 0.00023317337036133

PHP fgetcsv count lines end of file, eof

November 17, 2014

Due to fgetcsv read only a line from open file, or line by line if looping. As decribe below, it doesn’t able to return number of line from specific file. The fgetcsv() function parses a line from an open file, checking for CSV fields. The fgetcsv() function stops returning on a new line, at the […]

PHP check string exist in string

November 17, 2014

The correct way to write the statement to check if string contains specific words is use strpos function. Strpos is used to find the occurrence of one string inside other. Note that the use of !== false is deliberate; strpos returns either the offset at which the needle string begins in the haystack string, or […]

PHP dealing with commas in CSV data

November 12, 2014

Look carefully the data, there are multiple commas ‘,’ inside the address field. When transform the data to array, the output will be each commas separated in one array value. Example: (wrong way) Don’t attempt to do this with a regular expression. Just use str_getcsv()! The third parameter informs str_getcsv() to look for quote-enclosed fields. […]