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
@pdewouters
pdewouters / phpcs.xml
Created May 30, 2024 12:25
WP codesniffer config
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="MyConfig" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
<description>My Coding standards</description>
<file>.</file>
<arg name="extensions" value="php" />
<arg name="colors" />
<arg value="ps" />
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
pdewouters / youtube.js
Last active December 19, 2019 16:07
youtube
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, {
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
pdewouters / repos.sh
Created August 23, 2019 16:23
List repos for an org which dont have a readme
#!/bin/bash
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"
fi
done
// /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;
}
// 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
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' (https://github.com/puppetlabs/puppetlabs-apt.git) registered for path 'puppet/modules/apt'
Submodule 'puppet/modules/mysql' (https://github.com/puppetlabs/puppetlabs-mysql.git) registered for path 'puppet/modules/mysql'
@pdewouters
pdewouters / gist:92af5d06f95fa201edf5b3c19809661b
Created February 8, 2019 16:34
Fetch from API with useEffect
import React, { useState, useEffect } from "react";
export default function QuoteBox() {
const API_URL = "http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1";
const [quote, setQuote] = useState({});
const [isLoading, setLoading] = useState(false);
async function queryAPI() {
setLoading(true);
const response = await fetch(API_URL);
@pdewouters
pdewouters / how-i-work-template.md
Last active February 4, 2019 13:26 — forked from jazzsequence/how-i-work-template.md
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.