Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
building things

Chuck Reynolds chuckreynolds

🤖
building things
View GitHub Profile
@chuckreynolds
chuckreynolds / nodejs-github-webhook-webservice.md
Created Oct 21, 2019
How to Use Node.js and Github Webhooks to Keep Remote Projects in Sync - works for public repos only. Just storing this here for reference.
View nodejs-github-webhook-webservice.md
View twitch.badges.founder.subscriber.js
client.on('message', (channel, tags, message, self) => {
if(self) return;
const { badges, 'badge-info': badgeInfo } = tags;
let isSubscriber = false;
let monthsSubbed = -1;
if(badges) {
isSubscriber = badges.subscriber || badges.founder;
if(isSubscriber) {
monthsSubbed = badgeInfo.subscriber || badgeInfo.founder;
}
View lazy-load-youtube-embed.html
<!DOCTYPE html>
<html>
<head>
<title>Lazy load youtube embed</title>
<meta charset="UTF-8" />
</head>
<body>
<main>
<h1>Example of a lazy loaded embedded YouTube video</h1>
<iframe
@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
View astros-affiliate-link-hops.txt
@chuckreynolds
chuckreynolds / current-weather-openweathermap.js
Created Mar 12, 2019
Open Weather Map API Current Weather, node js, javascript, axios
View current-weather-openweathermap.js
// API specific settings https://openweathermap.org/current
const API_URL = 'https://api.openweathermap.org/data/2.5/weather';
const API_KEY = '';
const LOCATION_CODE = '';
const FULL_API_URL = `${API_CURRENT_URL}?id=${LOCATION_CODE}&appid=${API_KEY}`;
axios
.get(FULL_API_CURRENT_URL)
.then(response => {
// Assign vars to response data
@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 / wordpress-get-child-page-ids.php
Created Feb 5, 2019
Gotta be a better way to get an array of Child Page IDs than this. WordPress
View wordpress-get-child-page-ids.php
<?php
// basic idea here is a common function to pass a parent page ID
// and get back an array of it and its child page IDs only
function getChildPageIDs( $id ) {
$child_pages = get_pages('child_of='.$id);
$ids_to_remove = array($id); // we want to remove parent id too
foreach($child_pages as $child) {
array_push($ids_to_remove,$child->ID); // for every child add the id into array
}
@chuckreynolds
chuckreynolds / remove-jquery-migrate-wordpress.php
Created Jan 28, 2019
Removes jQuery Migrate script from WordPress. Reason: modern browsers don't need this anymore.
View remove-jquery-migrate-wordpress.php
<?php
/**
* Remove jQuery Migrate script
*/
function ryno_remove_jquery_migrate( $scripts ) {
if ( isset( $scripts->registered['jquery'] ) ) {
$script = $scripts->registered['jquery'];
if ( $script->deps ) { // Check whether the script has any dependencies
$script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
@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;
You can’t perform that action at this time.