Skip to content

Instantly share code, notes, and snippets.

@fitzhaile
fitzhaile / getSassyJSON.js
Created April 5, 2014 18:20
Get JSON from Sass output
function getSassyJSON() {
var style = null;
var json = null;
// Get the json string from CSS
if ( window.getComputedStyle && window.getComputedStyle(document.body, '::before') ) {
style = window.getComputedStyle(document.body, '::before');
style = style.content;
}
<?php
// Delete all revisions from all posts in either a network or a single blog.
// Quick hack by @mrazzari, 2014.
// For context see this thread started by Kitchin at the forums:
// http://wordpress.org/support/topic/deleting-post-revisions-do-not-use-the-abc-join-code-you-see-everywhere
// HOWTO
// This snippet is meant to be called as a standalone script.
// Like http://example.com/tmp/multisite_delete_revisions.php
@fitzhaile
fitzhaile / is_blog.php
Created August 28, 2014 22:15
An is_blog() conditional function for Wordpress.
<?php
/**
* An is_blog() conditional function for Wordpress.
*
* Determines if the current page is blog(y), including:
*
* - Posts page
* - Archive (category, tag, author)
* - Single post
@fitzhaile
fitzhaile / woocommerce_variable_fields.php
Last active August 29, 2015 14:06 — forked from corsonr/gist:9152652
WooCommerce Custom Fields for Variations
<?php
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'my_variable_fields', 10, 2 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'my_variable_fields_js' );
//Save variation fields
add_action( 'woocommerce_process_product_meta_variable', 'my_save_variable_fields', 10, 1 );
/**
@fitzhaile
fitzhaile / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">FB.init("INSERT-YOUR-API-KEY");</script>
<fb:fan profile_id="INSERT-YOUR-PAGE-ID" connections="10" width="300" height="210" css="http://yoursite.com/path-to-your-stylesheet/style.css?5"></fb:fan>
@fitzhaile
fitzhaile / *.php
Created September 26, 2012 15:27
PHP: Get Twitter Timeline
/**
* Simple Twitter status getter.
* @param string $handle User Twitter handle
* @param integer $count Desired number of tweets
* @return array Indexed array of tweets
*/
function dev_get_twitter_timeline($handle, $count = 3) {
// WP template tag
$save = get_stylesheet_directory() . '/assets/twitter.json';
$time = time();
@fitzhaile
fitzhaile / *.scss
Created September 26, 2012 20:52
SASS: Quotes Mixin
// Add quotes to an element.
//
// Parameters:
//
// * [optional] `size` -- Size, in em of the quotes
// * [optional] `padding` -- Top-left padding on lefthand quote
// * [optional] `left` -- Left quote glyph
// * [optional] `right` -- Right quote glyph
@mixin my-quotes($size: 1.3em, $padding:false, $left:'\201C', $right:'\201D') {
&:after, &:before { font-size: $size; }
@fitzhaile
fitzhaile / css-stats-ack.sh
Created October 2, 2012 17:56 — forked from pjkix/css-stats-ack.sh
shell script to generate some css file statistics
#!/bin/bash
## v1.0.6
## this script will gernerate css stats
### example output
# CSS STATS
# ----------
# Floats: 132
@fitzhaile
fitzhaile / *.scss
Created October 3, 2012 21:39
SASS: Bordered Box Arrow
@import "compass/css3";
// Add outward pointing arrows (triangles) to the sides of a box that has borders. (CSS triangles obviously
// based on Chris Coyier's CSS triangle. http://css-tricks.com/snippets/css/css-triangle.)
//
// Parameters:
//
// * `direction` -- What side of the box and direction of the arrow
// * `flatten` -- An *even numbered* factor of flattening the triangle (MUST be a even number)
// * `arrowBaseLength` -- Width or height of the arrow's base