Skip to content

Instantly share code, notes, and snippets.

View ashblue's full-sized avatar

Ash Blue ashblue

View GitHub Profile
@ashblue
ashblue / twentyeleven-shiv.php
Created August 18, 2011 15:48
WordPress TwentyEleven Child Theme Shiv
<?php
/*
Title: TwentyEleven Child Theme Shiv
Version: .02
Author: Ash Blue
Author URL: http://www.blueashes.com
Repository URL: https://gist.github.com/gists/1154369/
*/
@ashblue
ashblue / wp-wysiwyg-demo.html
Created October 1, 2011 05:50
Dummy content that can be dropped into any WordPress content area to test the WYSIWYG editor instantly. Includes everything except images.
To use this drop it into any content area with a WYSIWYG in the HTML view. Do not post into the visual view or the sky will fall. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent pellentesque vestibulum diam, id placerat nisi tempor quis. Proin erat metus, accumsan in sagittis vitae, suscipit a eros. Nam interdum pellentesque felis consequat condimentum. Maecenas nec augue justo. Vestibulum vehicula sodales diam nec volutpat.
<!--more-->
<h1>Header 1</h1>
<h2>Header 2</h2>
<h3>Header 3</h3>
<h4>Header 4</h4>
<h5>Header 5</h5>
<h6>Header 6</h6>
@ashblue
ashblue / gist:1260698
Created October 4, 2011 01:19
WordPress MySQL URL Update
# To use this script you must replace the first url http://currentsite.com to http://newsite.com and run it in your MySQL
UPDATE asdf_options SET option_value = REPLACE(option_value, 'http://currentsite.com', 'http://newsite.com');
UPDATE asdf_postmeta SET meta_value = REPLACE(meta_value, 'http://currentsite.com', 'http://newsite.com');
UPDATE asdf_posts SET guid = REPLACE(guid, 'http://currentsite.com', 'http://newsite.com');
UPDATE asdf_posts SET post_content = REPLACE(post_content, 'http://currentsite.com', 'http://newsite.com');
UPDATE asdf_rg_lead SET source_url = REPLACE(source_url, 'http://currentsite.com', 'http://newsite.com');
@ashblue
ashblue / fbjs-blah.js
Created April 27, 2012 20:46
fb call
loginStatus: function() {
FB.getLoginStatus(function(response) {
if (response.status === 'unknown') {
NRD.Scroll.offset = 130;
}
});
}
@ashblue
ashblue / callback-append.js
Created July 30, 2012 16:41
Append an existing JavaScript callback
/**
* Append an existing callback.
* @param {function} callback Callback to append.
* @param {function} append Data appended to the existing callback.
* @returns {function} Returns the newly assembled callback.
*/
function appendCallback(callback, append) {
var newCallback = function () {
callback();
append();
@ashblue
ashblue / bounding-box.js
Created August 17, 2012 20:04
Gets the bounding box (an imaginary box) that surrounds an array of squares.
/**
* Creates a bounding box from multiple square objects and returns a rectangle.
* @param {array} squares An array of square objects such as [square1, square2]. Must have
* x, y, width, and height parameters for each object of the sky will fall
* @returns {object} Returns the bounding box of the current squares
*/
function getBoundingBox(squares) {
// Setup basic test properties
var x = Number.POSITIVE_INFINITY;
var y = Number.POSITIVE_INFINITY;
@ashblue
ashblue / hex-to-rgb.js
Created August 21, 2012 00:34
Convert hexidecimal colors to RGB (red, green, blue) format. Includes support for hex shorthand '#000'
function hexToRGB(hex) {
// Strip '#'
var nums = hex.slice(1);
// If they pass in a shorthand hexcode convert it
if (nums.length === 3) {
var numStack = '';
for (var i = 0; i < nums.length; i++) {
numStack += nums.charAt(i) + nums.charAt(i);
}
@ashblue
ashblue / vertices-to-square.js
Created August 28, 2012 21:08
Creates a square bounding box from an array of x and y points
/**
* Create a square bounding box from an array of x and y points
* @param {array} A collection of objects with x and y coordinates {x, y}
* @returns {object} Square formatted as {x, y, width, height} from the given vertices
*/
function getBoundingBox (vertices) {
// Setup basic test properties
var xMin = Number.POSITIVE_INFINITY,
yMin = Number.POSITIVE_INFINITY,
xMax = 0,
@ashblue
ashblue / sort-array.js
Created September 10, 2012 22:00
Sorts an array by a specific property
/**
* Sorts an array by a specific property
* @link https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort
* @example http://jsfiddle.net/truefreestyle/Fqn4J/34/
* @param {array} arrayTarget Array of JSON objects you want to sort
* @param {string} property JSON property you want to sort by
* @returns {undefined}
*/
function arraySort (arrayTarget, property) {
arrayTarget.sort(function (a, b) {
@ashblue
ashblue / points-to-square-top-left.js
Created September 12, 2012 17:06
Calculates the top left corner of a square from any two x and y points.
/**
* Gets the top left corner of a square from two vertices. Uses nested
* if statements, but its the best way to opimize performance. Point
* parameters can be passed in any order.
* @param {object} point1 Object formatted as { x, y } on a cartesian graph
* @param {object} point1 Object formatted as { x, y } on a cartesian graph
* @returns {object} { x, y } of the top left corner on a square
*/
function getSquareTopLeft (point1, point2) {
// Declare coordinate collection variables