Skip to content

Instantly share code, notes, and snippets.

View astockwell's full-sized avatar

Alex Stockwell astockwell

View GitHub Profile
@astockwell
astockwell / Readme.md
Last active December 26, 2015 13:59
The following is an extraction of depricated methods from jQuery UI v1.9.2 as a quick-fix monkey-patch for the Wordpress Bannerize plugin to enable compatibility with the new jQuery UI v1.10 included in Wordpress v3.6. USE AT YOUR OWN RISK, BACK UP YOUR FILES & DATABASE. I do not advocate modifying core plugin files unless it is an emergency. NO…

Two files must be modified for this fix to work:

#	modified:   wp-content/plugins/wp-bannerize/js/jquery-ui.min.js
#	modified:   wp-content/plugins/wp-bannerize/js/jquery.timepicker.min.js
  1. Save everything else, ensure you are using source control, and backup your files and database!
  2. Replace the entire contents of wp-content/plugins/wp-bannerize/js/jquery.timepicker.min.js with the contents of the latest version.
  3. Replace the entire contents of wp-content/plugins/wp-bannerize/js/jquery-ui.min.js with the contents of jquery-ui.min.js from this gist.
<?php
/*
* Reference
*
* Term object keys:
* [term_id, name, slug, term_group, term_taxonomy_id, taxonomy, description, parent]
*
*/
@astockwell
astockwell / index.html
Last active February 4, 2016 05:23
AddThis implementation (that actually works!) (add your AddThis analytics profile ID!)
<a class="addthis_button_facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>">Facebook</a>
<a class="addthis_button_twitter" target="_blank" href="https://twitter.com/intent/tweet?url=<?php the_permalink(); ?>">Twitter</a>
<a href="" class="addthis_button">Share this</a>
<script type="text/javascript">
var addthis_config = addthis_config || {};
addthis_config.data_track_clickback = false; //tracking codes added to URLs after a share event
addthis_config.data_track_addressbar = false; //tracking codes added to URL in the address bar using JavaScript
addthis_config.ui_click = true; //open share panel on click (not hover)
</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-XXXXXXXXXXXXX"></script>
@astockwell
astockwell / README.md
Last active June 14, 2024 13:17
PHP Video Url Parser

Youtube/Vimeo Video Url Parser

Parses URLs from major cloud video providers. Capable of extracting keys from various video embed and link urls to manipulate and access videos in various ways.

Usage

VideoUrlParser::identify_service("https://www.youtube.com/watch?v=x_8kFbZf20I&amp;feature=youtu.be");
@astockwell
astockwell / functions.php
Last active August 29, 2015 14:01
Better way to get Wordpress post featured image
<?php
/**
* Get everything you could ever want about a featured image
*
* Usage:
* <?php $image = get_featured_image(); ?>
* <img class="thumbnail" src="<?php echo $image['url']; ?>" alt="<?php echo $image['title']; ?>">
*
* @param integer|object $post_id The ID/Object of the post that has the desired post thumbnail image
* @return false|array Null on failure to find the image, wp_prepare_attachment_for_js array on success
@astockwell
astockwell / Vagrantfile
Created July 20, 2014 16:58
Vagrantfile to extract data table from Microsoft Access to CSV
# -*- mode: ruby -*-
$script = <<SCRIPT
apt-get update
apt-get install -q -y wget make libtool automake autoconf bison flex unixodbc git mdbtools
cd /vagrant
echo "Get a copy of the MDB file and run 'vagrant ssh -c 'mdb-export /vagrant/database.mdb table_name > /vagrant/table_name.csv''"
SCRIPT
Vagrant.configure("2") do |config|
@astockwell
astockwell / page.php
Last active August 29, 2015 14:06
Advanced Custom Fields Pristine Field Uses
<!-- Text Field -->
<?php $field_name_slug = get_field("field_name_slug"); if ( !empty($field_name_slug) ): ?>
<?php echo $field_name_slug; ?>
<?php endif; ?>
<!-- Image Field -->
<?php $image_field_name = get_field("image_field_name"); if ( $image_field_name ): ?>
<img src="<?php echo $image_field_name["url"]; ?>" alt="<?php echo $image_field_name["title"]; ?>" />
<?php endif; ?>
@astockwell
astockwell / index.php
Last active July 27, 2016 17:21
Teaching PHP: Basic principles to use PHP in Wordpress (with ACF)
<?php
/*
* Discovering variables:
*/
echo "string";
print_r(expression);
/*
@astockwell
astockwell / sortStrings.js
Last active August 29, 2015 14:17
Sort array of string numbers correctly
// JsFiddle: http://jsfiddle.net/astockwell/6jxLeppm/4/
// Array.prototype.filter polyfill for <= IE8
if (!Array.prototype.filter) {Array.prototype.filter = function(fun/*, thisArg*/) {if (this === void 0 || this === null) {throw new TypeError(); } var t = Object(this); var len = t.length >>> 0; if (typeof fun !== 'function') {throw new TypeError(); } var res = []; var thisArg = arguments.length >= 2 ? arguments[1] : void 0; for (var i = 0; i < len; i++) {if (i in t) {var val = t[i]; if (fun.call(thisArg, val, i, t)) {res.push(val); } } } return res; }; }
var containsNoNumbers = function(s) {
return s.indexOf('0') === -1;
};
var containsNumbers = function(s) {
return !containsNoNumbers(s);
@astockwell
astockwell / parse_guid.py
Last active June 8, 2020 10:09
Decoding Oracle Raw(16), in Python 3 and Ruby 2
def split_into_chunks(string, chunk_length=2):
chunks = []
while len(string) > 0:
chunks.append(string[:chunk_length])
string = string[chunk_length:]
return chunks
def to_oracle_raw16(string, strip_dashes=True, dashify_result=False):
oracle_format_indices = [3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15]
if strip_dashes: