Here is a command line method to replace a string in multiple files in the current and sub directories.
Weiterlesen „String replace in multiple files using a recursive file search“
Get list of modified files in directory
Here is a command to get a list of modified files in a directory and subdirectories;
Weiterlesen „Get list of modified files in directory“
Get last line of file in PHP
Here is a simple way to get the last line of a file without reading the entire file into memory.
Weiterlesen „Get last line of file in PHP“
Php Sleep function in javascript
Here is a tidy javascript function that I found on stack overflow to mimic PHP’s usleep function which has been useful when testing javascript.
Weiterlesen „Php Sleep function in javascript“
An efficient alternative to paging with SQL OFFSETs
Paging large MySQL tables can be slow using the typical offset method. This alternative method leveraging the primary key is a more efficient solution.
How to debug your WordPress plugin
If you are developing a plugin on WordPress, you will need to debug your code as you go.
To enable debugging, go to your wp-config.php file.
Find the line…
[source language=“php“]define(‚WP_DEBUG‘, false);[/source]
Replace the line above with the following…
[source language=“php“]
// Turns WordPress debugging on
define(‚WP_DEBUG‘, true);
// Tells WordPress to log everything to the /wp-content/debug.log file
define(‚WP_DEBUG_LOG‘, true);
// Doesn’t force the PHP ‚display_errors‘ variable to be on
define(‚WP_DEBUG_DISPLAY‘, false);
// Hides errors from being displayed on-screen
@ini_set(‚display_errors‘, 0);
[/source]
Now you all warnings and errors will show up in the /wp-content/debug.log file, including WordPress warnings of deprecated functions.
You can write directly to this log from your plugin using the error_log() function.
Typically…
[source language=“php“]
//output some debug string
error_log( ‚this works yo‘ );
//output some array/object
error_log( print_r( $some_obj_or_array, 1 ) );
[/source]
Kudos to this post. It has some good plugin development tips, including how to enable debugging on WordPress.
WP Plugins: How to remove a Filter
Do not use remove_filter(). It is possible it will break other hooks which can have unintended consequences. This post gives a really good alternative approach using static variables.
How to request just the response headers with cURL
Here is the cURL config to request just the response headers with the cURL library
Weiterlesen „How to request just the response headers with cURL“
How to Auto-Forward Gmail Messages in Bulk
Unfortunately, Gmail will not allow you to forward old email via a filter.
I found a way that you can transfer all email from one Gmail account to another, and it works but it’s a tad complicated.
If you want to simply forward old email, the solution from Digital Inspiration using Google Docs is better.
Weiterlesen „How to Auto-Forward Gmail Messages in Bulk“
Magpie Lane

