Skip to content

Instantly share code, notes, and snippets.

🤖
building things

Chuck Reynolds chuckreynolds

🤖
building things
Block or report user

Report or block chuckreynolds

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chuckreynolds
chuckreynolds / stopwatch.php
Created Jul 27, 2016
Simple "StopWatch" class to measure PHP execution time. The class can handle multiple separate timers at the same time
View stopwatch.php
<?php
class StopWatch {
/**
* @var $startTimes array The start times of the StopWatches
*/
private static $startTimes = array();
/**
* Start the timer
*
@chuckreynolds
chuckreynolds / robots.txt
Last active Aug 17, 2019
Solid start Robots.txt for WordPress Sites. (HEADS UP: Make sure you're viewing the most recent version of this Gist) https://gist.github.com/chuckreynolds/135728/
View robots.txt
# robots.txt for wordpress
# https://gist.github.com/chuckreynolds/135728
User-agent: *
Disallow: /cgi-bin/
Disallow: /trackback/
Disallow: /comment-page-*
Disallow: /?s=*
Disallow: /*.php$
@chuckreynolds
chuckreynolds / fetch-dadjoke-api.php
Last active Aug 8, 2019
Fetches a dad joke from icanhazdadjoke.com
View fetch-dadjoke-api.php
<?php
$url = 'https://icanhazdadjoke.com/';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept:text/plain']);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
@chuckreynolds
chuckreynolds / Wordpress .HTACCESS file
Created Jun 25, 2009
Hardened .htaccess file for WP installs
View Wordpress .HTACCESS file
# canonical redirect to no www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# protect wp-config at all cost
<files wp-config.php>
Order deny,allow
deny from all
</files>
View wp-config-debug.php
<?php
/**
* == About this Gist ==
*
* Code to add to wp-config.php to enhance information available for debugging.
*
* You would typically add this code below the database, language and salt settings
*
* Oh.. and *do* make sure you change the path to the log file to a proper file path on your server (make sure it exists).
*
@chuckreynolds
chuckreynolds / functions.php
Created Jun 29, 2019 — forked from tessak22/functions.php
Hero Gutenberg Block using Advanced Custom Fields 5.8 Pro
View functions.php
/**
* Register hero block
*/
add_action('acf/init', 'hero');
function hero() {
// check function exists
if( function_exists('acf_register_block') ) {
// register a hero block
@chuckreynolds
chuckreynolds / wp-local-media-nginx.txt
Last active May 6, 2019
Local NGINX WordPress Media Uploads Fallback. Substitute {PROD} for the domain to use images from.
View wp-local-media-nginx.txt
location ~* ^.+\.(svg|svgz|jpg|jpeg|gif|png|ico|bmp)$ {
try_files $uri @image_fallback;
}
location @image_fallback {
proxy_pass http://{PROD};
}
@chuckreynolds
chuckreynolds / oxford.resp.json
Last active Apr 20, 2019
sample oxford dict api vs response to learn to loop through
View oxford.resp.json
{
"id": "average",
"metadata": {
"operation": "retrieve",
"provider": "Oxford University Press",
"schema": "RetrieveEntry"
},
"results": [
{
"id": "average",
@chuckreynolds
chuckreynolds / block.twitter.live.txt
Last active Apr 13, 2019
Block script to put into Ublock Origin Filters to get rid of Twitter's Live Video sidebar object
View block.twitter.live.txt
twitter.com##.is-playing.module.LiveVideoHomePageModule
twitter.com##.roaming-module.LiveVideoHomePageModuleContainer
View astros-affiliate-link-hops.txt
You can’t perform that action at this time.