Skip to content

Instantly share code, notes, and snippets.

<?php
// Function `parse_yturl()` from <http://stackoverflow.com/a/10524505/624466>
/**
* Check if the input string is a valid YouTube URL
* and try to extract the YouTube Video ID from it.
*
* @author Stephan Schmitz <[email protected]>
* @param $url string The string that shall be checked.
@macbookandrew
macbookandrew / findStyles.js
Last active March 30, 2024 15:24
List unique CSS properties for all DOM elements
/**
* List unique CSS properties for all DOM elements
* Initially created to list unique font stacks on a page
* @see {@link http://stackoverflow.com/a/35022690/ Inspired by this StackOverflow answer}
*
* @see {@link https://gist.github.com/macbookandrew/f33dbbc0aa582d0515919dc5fb95c00a/ URL for this file}
*
* @author AndrewRMinion Design (https://andrewrminion.com)
* @version 1.1
*
@helgatheviking
helgatheviking / sortable-select2.php
Last active December 1, 2021 04:34
Add drag and drop sorting to WooCommerce enhanced product select
<?php
/**
* Plugin Name: WooCommerce Sortable Enhanced Product Search
* Plugin URI: https://gist.github.com/helgatheviking/279ebd34b1e4de7e2380ca3b9936e9c4
* Description: Sort enhanced product search via drag and drop, ideal for Mix and Match, Bundles, etc
* Version: 1.0.0b
* Author: Kathy Darling
* Author URI: http://kathyisawesome.com/
*
* Copyright: © 2016 Kathy Darling
<?php
class StephanisAddition {
public static function add_two_numbers( $number_one, $number_two ) {
if ( ! is_numeric( $number_one ) || ! is_numeric( $number_two ) ) {
return null;
}
return $number_one + $number_two;
}
@ahmadazimi
ahmadazimi / replace-zero-width-space.php
Last active April 23, 2024 16:20
PHP replace Zero Width Space using preg_replace
<?php
/**
* http://stackoverflow.com/questions/11305797/remove-zero-width-space-characters-from-a-javascript-string
* U+200B zero width space
* U+200C zero width non-joiner Unicode code point
* U+200D zero width joiner Unicode code point
* U+FEFF zero width no-break space Unicode code point
*/
@ShinichiNishikawa
ShinichiNishikawa / newreview
Last active June 26, 2016 14:08
Creating a whole new Theme Review environmet in 1 minute using wp-cli
wp db reset --yes
wp core install --url=http://theme-review.loc --title="This is a really long long title to check if this theme design doesn't break with the long site title" --admin_user=admin --admin_password=admin [email protected]
wp core update
wp plugin install theme-check debug-bar log-deprecated-notices monster-widget wordpress-importer show-current-template customizer-theme-resizer --activate
wp plugin install wordpress-beta-tester debogger jetpack
wp plugin update --all
wp option update blogdescription "I'm in the theme review process and this is a very very long tagline to see if this long tagline text string in WordPress doesn't break the design of the theme header and else."
wp option update posts_per_page 5
wp option update thread_comments 1
wp option update thread_comments_depth 3
@Rarst
Rarst / GPLv2.php
Last active August 25, 2024 11:31
WordPress File Templates for PhpStorm.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@Rarst
Rarst / WordPress.xml
Last active September 5, 2024 01:49
WordPress Live Templates for PhpStorm
<?xml version="1.0" encoding="UTF-8"?>
<templateSet group="WordPress">
<template name="aa" value="add_action( '$hook$', '$callback$' );&#10;$END$" description="add_action" toReformat="false" toShortenFQNames="true">
<variable name="hook" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="callback" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="HTML_TEXT" value="false" />
<option name="HTML" value="false" />
<option name="XSL_TEXT" value="false" />
<option name="XML" value="false" />
@dbspringer
dbspringer / badfunc.sh
Created September 23, 2014 01:56
Recurse through directories looking for bad functions
#!/usr/bin/env bash
dir="."
if [ $1 ]; then dir=$1; fi
bad_funcs="exec system passthru shell_exec escapeshellarg escapeshellcmd proc_close proc_open dl popen show_source ini_set"
for func in $bad_funcs
do
grep -R --include=*.php $func $dir
done
@JamesMGreene
JamesMGreene / gitflow-breakdown.md
Last active November 5, 2024 15:51
`git flow` vs. `git`: A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository