Skip to content

Instantly share code, notes, and snippets.

Avatar
somone said this would be easy. someone LIED.

Norcross norcross

somone said this would be easy. someone LIED.
View GitHub Profile
@norcross
norcross / youtube-thumbs
Created Apr 14, 2013
get YouTube thumbnails
View youtube-thumbs
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
For the high quality version of the thumbnail use a url similar to this:
@norcross
norcross / norcross-debug-functions.php
Last active Mar 29, 2021
my list of debugging functions to keep in an MU file
View norcross-debug-functions.php
<?php
/*
Plugin Name: Norcross Debug Functions
Plugin URI: https://gist.github.com/norcross/7864205/
Description: A set of functions I use on all sites while building
Author: Andrew Norcross
Version: 0.0.1
Requires at least: 3.0
Author URI: http://andrewnorcross.com
*/
@norcross
norcross / country-array.php
Last active Jan 24, 2020 — forked from DHS/PHP Countries Array
PHP array of all country names
View country-array.php
<?php
$countries = array(
'Afghanistan',
'Albania',
'Algeria',
'American Samoa',
'Andorra',
'Angola',
'Anguilla',
@norcross
norcross / cron-delete-revisions.php
Created Dec 18, 2012
set cron to delete post revisions
View cron-delete-revisions.php
<?php
// add filter to allow for new weekly schedule
add_filter( 'cron_schedules', 'rkv_weekly_cron' );
function rkv_weekly_cron( $schedules ) {
// Adds once weekly to the existing schedules.
$schedules['weekly'] = array(
'interval' => 604800,
'display' => __( 'Once Weekly' )
);
@norcross
norcross / validate-passwords.js
Created Jan 19, 2013
some basic javascript password validation
View validate-passwords.js
// **************************************************************
// password validation
// **************************************************************
function checkPassword(pass) {
var numbers = pass.match(/\d+/g);
var uppers = pass.match(/[A-Z]/);
var lowers = pass.match(/[a-z]/);
var special = pass.match(/[!@#$%\^&*\+]/);
@norcross
norcross / wp-script-calls.php
Created Aug 23, 2012
using wp_enqueue_scripts and admin_enqueue_scripts
View wp-script-calls.php
// front end
function custom_front_scripts() {
wp_enqueue_style( 'front-css', plugins_url('/lib/css/front-css.css', __FILE__), array(), null, 'all' );
wp_enqueue_script( 'front-init', plugins_url('/lib/js/front.init.js', __FILE__) , array('jquery'), null, true );
}
add_action('wp_enqueue_scripts', 'custom_front_scripts' );
// back end
function custom_admin_scripts() {
@norcross
norcross / WooUpgradeTestSuiteCest.php
Last active Mar 7, 2019
Run various acceptance tests for WooCommerce
View WooUpgradeTestSuiteCest.php
<?php
/**
* WooCommerce Upgrade Test Suite
*
* A set of acceptance tests for a standard WooCommerce store.
*
* https://gist.github.com/norcross/4d45f1902bfb2f1f4cf79997a47d9d03
*/
// It'll error out sometimes without this ¯\_(ツ)_/¯ .
@norcross
norcross / csv-export-example.php
Created Aug 9, 2015
a basic CSV export example
View csv-export-example.php
<?php
/**
* Devin CSV Export
*
* Contains our export processing
*/
/*
Copyright 2015 Reaktiv Studios
This program is free software; you can redistribute it and/or modify
@norcross
norcross / admin-bar-kill.php
Created Jan 17, 2013
remove admin bar globally on front and back end
View admin-bar-kill.php
<?php
add_action ( 'init', 'rkv_adminbar_front_kill' );
add_action ( 'admin_init', 'rkv_adminbar_back_kill' );
function rkv_adminbar_front_kill() {
show_admin_bar( false );
wp_dequeue_script('admin-bar');
wp_dequeue_style('admin-bar');
@norcross
norcross / emailbot_ssc.php
Created Oct 1, 2012
Obfuscate email shortcode
View emailbot_ssc.php
/*
Usage (on the HTML tab, not the visual editor)
[email address="you@emailcompany.com"]
*/
function emailbot_ssc($attr) {
extract( shortcode_atts( array(
'address' => '',
), $attr ) );