Web & Software Developer

Code Snippets and Tutorials

Insert Google Adsense Native In-article ad on Regular WordPress Posts, and AMP ad on AMP pages

This is one code snippet to insert Google Adsense ads on all your WordPress posts, both regular and AMP. (This code works with the official AMP for WordPress plugin.) This one code snippet will automatically insert one Google Adsense ad after the first paragraph of every post. On regular posts, it will insert a “Native … Read more →

Bash Shell Script To Create a Release on GitHub

This shell script will create a new Release on GitHub for your git repo. This script should be placed in the base of your local git repository. You must configure the first 3 variables: ACCESSTOKEN – Set this to your personal GitHub access token. You can create an access token in your GitHub account > … Read more →

Show WP Admin Notice With Pure JavaScript

This adds a dismissible admin notice to the WP admin with pure JavaScript. No jQuery or other dependencies. The admin notice will have a Dismiss icon just like the regular WP admin notices. When the icon is clicked, the message will go away. This admin notice will have a blue left border which is given … Read more →

PHP mktime() Changes Your Time, Here’s the Fix

If you’re using PHP mktime() to make a timestamp for a specific moment in time that should not change, then be sure to first set the default timezone to UTC. Otherwise, the dynamic behavior of mktime() is to modify or change your time, based on the timezone settings on your server. This may be desirable … Read more →

PHP strftime() is Faster Than date() in PHP 7

After running several benchmark tests, I find that the PHP strftime() is faster than date(). I tested each one creating the same datetime string in this format: ‘YYYY-MM-DD HH:MM’. The test iterates 100000 times over each function. I repeated this test several times. Each time, I alternated which function ran first. Here are the benchmark … Read more →