Archive (35 tips)
Use needrestart to determine if some services need restart or system reboot is required after Debian or Ubuntu update
When you prompt user to input text (e.g. username, lastname etc), you may use Regular expressions to sanitize User Input
If you want to start a youtube playlist from random video, just add: &index=random_number to the src attribute of the embed code.
Php has functions to easily get basename and file extension. In some cases using of regular expression is necessary.
December 9th, 2013 15,824
A good solution is to use immutable disks. When a virtual disk marked as immutable, it becomes read-only and differences will be stored in differencing disks
December 9th, 2013 24,004
It is useful to prevent direct access of AJAX calls (from browser address bar). A solution could be the following simple function check_is_ajax()
November 4th, 2013 34,516
Date manipulation is a common and useful development task. It was never easy with PHP, until PHP5 and DateTime class. Take a look at date_convert() function
November 4th, 2013 13,129
Sometimes you want to check if a string represents a valid timezone. Using PHP versions greater than 5.2, timezone_identifiers_list() would be a solution.
October 2nd, 2013 138,205
Browser (and browser version) detection is an "all time classic" development requirement. jQuery.browser WAS an excellent solution, but it was removed
September 27th, 2013 63,626
PHP shuffle randomizes (shuffles) the order of the elements in an array. You may use this function to create a simple banner rotator.
September 27th, 2013 19,481
Sometimes, you want to create a list of available time zones to prompt your user to select his/her time zone. PHP offers timezone_identifiers_list
September 13th, 2013 4,405
In most cases you can distinguish if a PHP script was invoked from the command line (or Cron) or by the web server, using php_sapi_name()
September 9th, 2013 26,853
Sometimes you need to replace accented characters with non accented, for example when you want to perform an accent insensitive search. See this function.
September 8th, 2013 32,170
PHP DateTime class, available with PHP versions greater than 5.2 is very powerful. As an example, it ts very easy to check if a string represents a valid date
September 7th, 2013 2,462
How can you create a reference to a DOM element using jquery? In other words, what is the jquery equivalent of document.frm.element_name
September 6th, 2013 23,943
How to display line numbers in nano text editor
September 5th, 2013 2,381
A simple solution to scan your network is nmap. Avoid to use nmap in external networks, as it could be considered as an 'attack'.
September 4th, 2013 10,552
September 3rd, 2013 31,211
September 2nd, 2013 11,705
Use of include is very common in PHP. include will parse a file and display the result. But, how to store the result in a variable for later use?
September 1st, 2013 3,573
A I am running Linux (Archlinux or Debian) on my workstations and I use XFCE for desktop environment. I keep two portable backup versions
How to take a screenshot from command line in Linux (even from ssh connection) in a system running X server
August 30th, 2013 400,527
To get current datetime (now) with PHP you can use date with any PHP version, or better datetime class with PHP version greater than 5.2
PHP is_numeric() is useful to find whether a variable is a number or a numeric string. How you can check if a variable is an integer?
Use the powerful find command with exec parameter to change permissions using chmod
A convenient way to pass a single or multidimensional (possible utf-8) array is to serialize it ("convert it to a string") and pass it using a hidden input.
It is very important for dynamic web applications, any js and css changes to become available to user (without need to refresh - reload browser page)
PHP stripos (or mb-stripos) finds the position of the first occurrence of a case-insensitive substring in a string. How to find all occurrences?
This error is produced, because MySQL exports DEFINER with views or procedures, which might be not the same in production and developer machines
The ideal way to escape a string with php, is json_encode. This requires php > 5.2. Here is a solution for older versions of php.
Using Facebook LIKE button or other SM buttons, it is useful to define the URL of the page you want to share. It is not requested, as the page URL is used.
You can search for a certain package in a Debian system using dpkg
To find out system CPU is 64-bit capable or not, use /proc/cpuinfo
To find out if you are running a 64-bit or 32-bit kernel, uname command is enough: uname -m