Copyright © if not true then false. All Rights Reserved. Snowblind by Themes by bavotasan.com. Powered by WordPress.

Posts Tagged ‘ Coding ’
Adobe Apache Applications Bash CentOS Coding Command line CSS Database date Fedora Firefox Gnome Google Guide Howto HTML JavaScript KDE Links Linux MySQL News Perl PHP PostgreSQL PostgreSQL Partitioning Programming Programs psql Red Hat RHEL Security SQL Styles Terminal time Tips Tricks Tweets Twitter UNIX Windows XFCE Yum

PHP MongoDB (Mongo Database) Driver Installation on Linux, UNIX, BSD and Mac OS X
MongoDB PHP driver is very simple install on Linux, UNIX, BSD and Mac OS X. You need just PEAR (PHP Extension and Application Repository) with PECL repository. Normally PHP development (dev) package and PHP Pear package installation from package management system is enough to get PEAR working. Also go-pear.php script can be used.
» Continue Reading "Install PHP MongoDB (mongo) Driver on Linux, Mac OS X, Windows, UNIX, BSD"
PHP has large number of predefined constants. This HOWTO will present the seven most important, most practical and most useful PHP Magic Constants.
- __FILE__ – The full path and filename of the file.
- __DIR__ – The directory of the file.
- __FUNCTION__ – The function name.
- __CLASS__ – The class name.
- __METHOD__ – The class method name.
- __LINE__ – The current line number of the file.
- __NAMESPACE__ – The name of the current namespace
This is example PHP script with comments, which demonstrate howto use all previously mentioned PHP Magic Constants.
This is a very typical case, the need to create a temp file on the command line quickly. Opening editor, writing content, save file and quit editor is not the fastest possible way. A faster way is to use the cat command with the name of the file and write contents of the file and give the end-of-file character (Ctrl-D).
Create Temporary File Without Editor on Command Line
» Continue Reading "Linux Tip: Create and Append to Temporary File Without Editor"
I was using simple function to calculate difference between two dates and timestamps until I noticed, it’s not working correctly in long intervals. It’s very easy to calculate difference between two timestamps in seconds, but it’s much more complicated print difference in human readable format. The Internet can be found in a wide range of ways to do this thing, but as a rule they use a fixed amount of seconds for the year and the month. So if we calculate year with using 365 or 365.25 days and month using 30 or 31 then the difference is not accurate, because of leap years, DST (Daylight Saving Time) and so on.
Because of this problem, I decided to make a function (at least in the short testing) to return the right kind of differences between the UNIX timestamps and dates in human readable format. This function uses PHP strtotime function to calculate real differences and can handle leap years and DST. This function can also return Twitter like about texts with precision parameter.
» Continue Reading "PHP: Calculate Real Differences Between Two Dates or Timestamps"
PHP Command Line Interface (CLI) has not built-in coloring for script output, like example Perl language has (perldoc.perl.org/Term/ANSIColor.html). So I decided to make own class for coloring PHP CLI output. This class works only Bash shells. This class is easy to use. Just create new instance of class and call getColoredString function with string and foreground color and/or background color.
