Skip to content

Instantly share code, notes, and snippets.

View paulgibbs's full-sized avatar

Paul Wong-Gibbs paulgibbs

View GitHub Profile
@n7studios
n7studios / post-to-social.php
Last active March 9, 2024 10:47
Determine Post Publish / Update via Classic Editor, Gutenberg and REST API
<?php
/**
* Example class implementation to perform actions, such as sending a Post
* to a third party API or service, when the Post is published or updated through:
* - Classic Editor
* - Gutenberg
* - REST API
*
* @package Post_To_Social
* @author Tim Carr
@davidrleonard
davidrleonard / add-team-to-repos.js
Last active April 9, 2024 18:49
Add a new team to all Github repos in an organization
/*
* Adds a team to all the repos in a Github organization. This is a tedious
* process in the UI. You'll need a newer version of node to run this (e.g 9+)
* because it uses async/await.
*
* Instructions:
*
* 1. Copy this file somewhere on your computer, e.g. ~/addteamrepos.js
* 2. Fill in the uppercase variables below with the right values
* 3. Run this file: `$ node ~/addteamrepos.js`
@avafloww
avafloww / PhpJava.java
Last active October 16, 2022 18:50
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@boonebgorges
boonebgorges / cac-asset-ver.php
Created June 16, 2015 13:50
Custom version querystring appending for WordPress JS and CSS assets
<?php
/**
* Note that CAC_VERSION is a custom constant. Replace as necessary.
*/
function cac_asset_ver( $tag, $handle, $src = '' ) {
// 'style_loader_tag' doesn't pass a src, so we sniff it from the tag.
if ( ! $src ) {
preg_match( '/href\=\'([^\']+)\'/', $tag, $src_matches );
if ( $src_matches ) {
$src = $src_matches[1];
@ryoppy
ryoppy / getQueryParams.js
Last active March 28, 2019 17:31
Parse query string. use Underscore.js.
/**
* Parse query string.
* ?a=b&c=d to {a: b, c: d}
* @param {String} (option) queryString
* @return {Object} query params
*/
getQueryParams: function(queryString) {
var query = (queryString || window.location.search).substring(1); // delete ?
if (!query) {
return false;
@alexkingorg
alexkingorg / deploy.sh
Created August 16, 2012 13:12 — forked from dancameron/deploy.sh
Script to deploy from Github to WordPress.org Plugin Repository
#! /bin/bash
#
# Script to deploy from Github to WordPress.org Plugin Repository
#prompt for plugin slug
echo -e "Plugin Slug: \c"
read PLUGINSLUG
# main config, set off of plugin slug
CURRENTDIR=`pwd`
@markjaquith
markjaquith / gist:2628225
Last active March 29, 2023 23:30
Script to sync WordPress SVN to GitHub
#!/bin/bash
# cd into the directory
cd ~/gitsync/github-wordpress-sync/;
# Make sure we are not already running
if [ -f .sync-running ];then
if test ! `find ".sync-running" -mmin +10`;then
# Currently running, but not stuck
exit 1;
fi
fi;
@kyleturner
kyleturner / Remove Submodule
Created January 5, 2012 01:07
How to remove a submodule from a Github project
To remove a submodule you need to:
Delete the relevant line from the .gitmodules file.
Delete the relevant section from .git/config.
Run git rm --cached path_to_submodule (no trailing slash).
Commit and delete the now untracked submodule files.
@mjangda
mjangda / sync-svn-folders.sh
Created December 30, 2011 16:35
Sync files between two SVN folders
#!/bin/bash
# Script Name: Sync SVN folders
# Description: Use this script to sync changes from one SVN folder to another. A common use is syncing between prod and preprod repos.
# Tags: svn, sync
# Usage: ./sync-svn-folders.sh /path/to/from-repo /path/to/to-repo
FROM_REPO=$1
TO_REPO=$2
# Check that we don't have empty paths