Skip to content

Instantly share code, notes, and snippets.

View pdewouters's full-sized avatar
Working from home

Paul de Wouters pdewouters

Working from home
View GitHub Profile
View gist:70af7a3473b7f30ca4d91286ae5370b4
function count_tags( string $html ) {
// save the tag count to an option so each call to this function use it for a global count across all posts.
$tag_count = get_option( 'tibi_tag_count', [] );
$tags = new \WP_HTML_Tag_Processor( $html );
while( $tags->next_tag()) {
$tag = $tags->get_tag();
if ( ! isset( $tag_count[ $tag ] ) ) {
$tag_count[ $tag ] = 0;
pdewouters / youtube.js
Last active December 19, 2019 16:07
View youtube.js
import React, { useRef, useEffect } from 'react';
import PropTypes from 'prop-types';
import { Waypoint } from 'react-waypoint';
function Youtube( { youtubeId } ) {
const playerRef = useRef( null );
const elementRef = useRef( null );
const loadVideo = () => {
const player = new window.YT.Player( elementRef.current, {
View gist:c37b30462a3d49a9bdd6f66d0b4cd626
find . -type d \( -name wordpress -o -name .bin -o -name .circleci -o -name .config -o -name .ebextensions -o -name .github -o -name __mocks__ -o -name node_modules -o -name chassis -o -name .tests -o -name vendor -o -name uploads \) -prune -o -name "*.php" -print0 | xargs -0 -n 1 -P 4 php -l > /dev/null
pdewouters /
Created August 23, 2019 16:23
List repos for an org which dont have a readme
hub api orgs/humanmade/repos --paginate | npx jq -r '.[] | select(.archived != true) | .full_name' | while read -r i; do
if [[ $(hub api repos/"$i"/readme | npx jq -r '.name') = 'null' ]]; then
echo "$i has no readme"
View gist:b5fcc0ff9e48d76df08663343e1207e4
// /content/plugins/multilingualpress3/src/multilingualpress/Cache/NavMenuItemsSerializer.php
$menuItem = $postArray['menu_item'] ?? [];
foreach (self::MENU_ITEM_ALLOWED_PROPERTIES as list($property, $type, $default)) {
if (!isset($post->{$property})) {
$post->{$property} = $this->extractValue($menuItem, $property, $type, $default);
$this->unserialized[] = $post;
View gist:345664139b408e1d8dc99f3899fe77c8
// Update only a specific package with its dependencies
composer update --ignore-platform-reqs humanmade/coding-standards --with-dependencies
// Update packages (ignore platform requirements)
composer update --ignore-platform-reqs
View chassis error
Installing Chassis into /Users/paul/altistest/chassis
Cloning into '/Users/paul/altistest/chassis'...
remote: Enumerating objects: 947, done.
remote: Counting objects: 100% (947/947), done.
remote: Compressing objects: 100% (736/736), done.
remote: Total 17683 (delta 272), reused 447 (delta 202), pack-reused 16736
Receiving objects: 100% (17683/17683), 46.14 MiB | 6.07 MiB/s, done.
Resolving deltas: 100% (11919/11919), done.
Submodule 'puppet/modules/apt' ( registered for path 'puppet/modules/apt'
Submodule 'puppet/modules/mysql' ( registered for path 'puppet/modules/mysql'
pdewouters / gist:92af5d06f95fa201edf5b3c19809661b
Created February 8, 2019 16:34
Fetch from API with useEffect
View gist:92af5d06f95fa201edf5b3c19809661b
import React, { useState, useEffect } from "react";
export default function QuoteBox() {
const API_URL = "[orderby]=rand&filter[posts_per_page]=1";
const [quote, setQuote] = useState({});
const [isLoading, setLoading] = useState(false);
async function queryAPI() {
const response = await fetch(API_URL);
pdewouters /
Last active February 4, 2019 13:26 — forked from jazzsequence/
Template for How I Like to Work posts

How I work

This is my own interpretation of how I like to work, feedback welcome! Especially if my own view of how I think I like to work doesn't match your experience of how it seems I like to work!

When I work

Timezone: GMT I work 9 to 5 6-8 hours per day I don't work at the weekend I can be available after hours on occasion, if it's justified.

View gist:a1e52bafd98b7ce2c7599070b3403b36
# Task
Implement a recursive function that returns all of the unique dependencies, and sub-dependencies of a module, sorted alphabetically. Dependencies should be printed as dependency@version e.g. 'inflection@1.2.6'.
Multiple versions of the same module are allowed, but duplicates modules of the same version should be removed.
## Arguments:
* tree: A dependency tree. See below for an example of the structure.