how to post on twitter api | use mysqli or pdo instead | bot ios code auto like posts facebook | testing


Archive (38 tips)

How To Create A Strong Password Without Having To Remember It

Strong password without having to remember it? Is it possible? Is it safe?

How To Delete or Not Keep a Command in Bash History

How to delete a command in Bash history. Sometimes it is better to not include a secret command in history. See how.

How to Display Grub Menu at Boot Time in Ubuntu

In Ubuntu, Grub boot menu is hidden by default. You can display it by pressing "SHIFT" continuously at boot time. This is useful (among other cases) in case you want to boot in Recovery mode. How to make this change permanent?

When to Restart Services or Reboot after Update on Debian or Ubuntu

Use needrestart to determine if some services need restart or system reboot is required after Debian or Ubuntu update

Sanitize User Input Text with PHP

When you prompt user to input text (e.g. username, lastname etc), you may use Regular expressions to sanitize User Input

How to Start Youtube Playlist from Random Video

If you want to start a youtube playlist from random video, just add: &index=random_number to the src attribute of the embed code.

Get basename and file extension with PHP or Javascript

Php has functions to easily get basename and file extension. In some cases using of regular expression is necessary.

Easily Backup Virtualbox disks using Immutable Images

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

How to check if a Request is an AJAX call with PHP

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()

How to Convert Date or Time to any Timezone and Dateformat with PHP

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

Check if a String represents a Valid Timezone with PHP

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.

How to Detect Browser (and browser version) using JavaScript

Browser (and browser version) detection is an "all time classic" development requirement. jQuery.browser WAS an excellent solution, but it was removed

What is the JavaScript Equivalent of print_r in PHP?

What is the JavaScript Equivalent of PHP print_r() function? In other words, how you can print a javascript object in a way that's readable by humans?

Create a Simple Banner Rotator with PHP in a Minute

PHP shuffle randomizes (shuffles) the order of the elements in an array. You may use this function to create a simple banner rotator.

Easily Create a List of Time Zones with PHP

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

Determine PHP script Invocation: CLI or by the Web Server

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()

Replace accented characters with non accented with PHP

Sometimes you need to replace accented characters with non accented, for example when you want to perform an accent insensitive search. See this function.

Check if a string represents a valid Date or Time with PHP

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

Reference to a DOM element using jQuery

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

Display Line Numbers in nano

How to display line numbers in nano text editor

Scan IP addresses on LAN

A simple solution to scan your network is nmap. Avoid to use nmap in external networks, as it could be considered as an 'attack'.

Call javascript Function Using Variable for its Name

What is the javascript equivalent of PHP call-user-func? How to call a javascript function dynamically using a variable holding its name?

Center popup window on the Screen with Javascript

Javascript Window open() Method opens a popup window. How to center this window on the screen?

How to Parse an include file and Store the result in a Variable with PHP

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?

ext2read: a Portable Solution to Access Linux files from Windows

A I am running Linux (Archlinux or Debian) on my workstations and I use XFCE for desktop environment. I keep two portable backup versions

Take a Screenshot from Command Line

How to take a screenshot from command line in Linux (even from ssh connection) in a system running X server

How to Get Current Datetime (NOW) with PHP

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

How to find whether a variable is a (positive) integer with PHP

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?

Massive Change of File Permissions

Use the powerful find command with exec parameter to change permissions using chmod

Passing Array Variables using POST or GET with PHP

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.

Preventing JS or CSS Caching on Web Applications

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)

Find all occurrences of a substring in a string with PHP

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?

A Workaround for mysqldump Error 1449

This error is produced, because MySQL exports DEFINER with views or procedures, which might be not the same in production and developer machines

How to Escape JSON Special Characters using PHP

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.

How to define Share URL in Social Buttons (and Why you Should)

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.

Search your Debian system for a Certain Package

You can search for a certain package in a Debian system using dpkg

Find out the CPU is 32bit or 64bit

To find out system CPU is 64-bit capable or not, use /proc/cpuinfo

Find out the Running Kernel is 32bit or 64bit

To find out if you are running a 64-bit or 32-bit kernel, uname command is enough: uname -m