Skip to content

Instantly share code, notes, and snippets.

Avatar
🌄
Working from home

Paul de Wouters pdewouters

🌄
Working from home
View GitHub Profile
@pdewouters
pdewouters / gist:4143978
Created Nov 25, 2012
Numeric pagination from Genesis
View gist:4143978
function pdw_spine_numeric_posts_nav() {
if( is_singular() )
return;
global $wp_query;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
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, {
@pdewouters
pdewouters / new_gist_file
Created Jun 21, 2013
whitelist gitignore
View new_gist_file
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
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
View gist:92af5d06f95fa201edf5b3c19809661b
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 / repos.sh
Created Aug 23, 2019
List repos for an org which dont have a readme
View repos.sh
#!/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
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' (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:2693274
Created May 14, 2012
featured posts loop with wp_reset_postdata
View gist:2693274
/**
* Filter the home page posts, and remove any featured post ID's from it. Hooked
* onto the 'pre_get_posts' action, this changes the parameters of the query
* before it gets any posts.
*
* @global array $featured_post_id
* @param WP_Query $query
* @return WP_Query Possibly modified WP_query
* http://developer.wordpress.com/2012/05/14/querying-posts-without-query_posts/
*/