Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
building things

Chuck Reynolds chuckreynolds

🤖
building things
View GitHub Profile
@chuckreynolds
chuckreynolds / wordpress-remove-block-suggestions.php
Created Oct 7, 2022
WordPress Remove Block Suggestions when viewing the Block Directory in WP Admin.
View wordpress-remove-block-suggestions.php
// Remove Block Suggestions in wp-admin Block Directory
function chuckdev_remove_block_directory() {
wp_add_inline_script(
'wp-block-editor',
"wp.domReady( () => wp.plugins.unregisterPlugin( 'block-directory' ) )"
);
}
add_action( 'admin_enqueue_scripts', 'chuckdev_remove_block_directory' );
@chuckreynolds
chuckreynolds / wikimedia-enterprise-auth-postman-prerequest.js
Created Jan 20, 2022
Postman Collection Pre-Request script to get access token for Wikimedia Enterprise Auth
View wikimedia-enterprise-auth-postman-prerequest.js
const wmeAuthUrl = 'https://auth.enterprise.wikimedia.com/v1/login';
const wmeUsername = pm.collectionVariables.get("wmeUsername");
const wmePassword = pm.collectionVariables.get("wmePassword");
const getTokenRequest = {
method: 'POST',
url: wmeAuthUrl,
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
@chuckreynolds
chuckreynolds / twitch-helix-oauth2-postman-prerequest.js
Last active Jan 8, 2022
Postman Pre-Request script to get access token for Twitch OAuth2
View twitch-helix-oauth2-postman-prerequest.js
/*
* Twitch Helix OAuth2 Postman Pre-Request Script
* @see https://dev.twitch.tv/docs/authentication#registration
* @see https://learning.postman.com/docs/writing-scripts/pre-request-scripts/
*/
const authUrl = 'https://id.twitch.tv/oauth2/token';
const clientId = pm.collectionVariables.get('clientId');
const clientSecret = pm.collectionVariables.get('clientSecret');
@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",