Skip to content

Instantly share code, notes, and snippets.

View jawinn's full-sized avatar

Josh Winn jawinn

View GitHub Profile
@jawinn
jawinn / MulitpleUniqueArrayValues.js
Last active August 29, 2015 13:56
Multiple *Unique* Array Values (uses jQuery)
// MULTIPLE *UNIQUE* ARRAY VALUES (uses jQuery)
// Parameter arr: array containing values
// Parameter totalNum: total number of values to get
// Returns Array
function rndArrValues(arr, totalNum){
if ( totalNum <= 0 ){ return; }
var theResult = [];
var newElement;
@jawinn
jawinn / JS_Array_Helpers.js
Created March 1, 2014 23:44
Array Helpers for JavaScript + jQuery
// For getting unique values in array
// usage:
// var duplicates = [1,3,4,2,1,2,3,8];
// var uniques = duplicates.unique(); // result = [1,3,4,2,8]
Array.prototype.contains = function(v) {
for(var i = 0; i < this.length; i++) {
if(this[i] === v) return true;
}
return false;
};
@jawinn
jawinn / toast.js
Created March 23, 2014 20:28 — forked from kamranzafar/toast.js
jQuery Mobile - Toast-style popup, modified
// JQuery Mobile Android-style Toast popup
// https://gist.github.com/kamranzafar/3136584
// Usage: toast("Your Message Here");
var toast = function(msg){
$("<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h4>"+msg+"</h4></div>")
.css({ display: "block",
opacity: 0.96,
"background-color": "#332C2C",
"z-index":"9999",
position: "fixed",
@jawinn
jawinn / bare_bones_redux_config_starting_point.php
Last active August 29, 2015 14:00
Bare bones Redux config starting point
<?php
// ACTUAL DECLARATION OF SECTIONS
$this->sections[] = array(
'icon' => 'el-icon-cogs',
'title' => __('General Settings', 'YOURTHEME'),
'fields' => array(
array(
'id' => 'opt-social-facebook',
'type' => 'text',
@jawinn
jawinn / empty_paragraphs.php
Created April 24, 2014 16:01
Remove Empty Paragraphs from Shortcodes, WordPress
<?php
// http://webandphp.com/remove-markup-from-wordpress-shortcodes
/**
* Removes mismatched </p> and <p> tags from a string
*
* @author Jason Lengstorf <jason@copterlabs.com>
*/
function copter_remove_crappy_markup( $string )
{
@jawinn
jawinn / dot_irecommendthis.js
Created June 18, 2014 17:17
I Recommend This - JS Fix
jQuery(document).ready(function($){
$(document).on('click', '.dot-irecommendthis',function() {
var link = $(this);
if(link.hasClass('active')) return false;
var id = $(this).attr('id'),
suffix = link.find('.dot-irecommendthis-suffix').text();
$.post(dot_irecommendthis.ajaxurl, { action:'dot-irecommendthis', recommend_id:id, suffix:suffix }, function(data){
@jawinn
jawinn / random_diff_element.js
Last active August 29, 2015 14:03
Random JS Array Element, Different than the Last One
// via http://stackoverflow.com/questions/4550505/getting-random-value-from-an-array
// usage: var myRandomDiffElement = myArray.randomDiffElement(lastRandomElement);
Array.prototype.randomDiffElement = function(last) {
if (this.length == 0) {
return;
} else if (this.length == 1) {
return this[0];
} else {
var num = 0;
do {
@jawinn
jawinn / ondeviceready_ionic.js
Last active August 29, 2015 14:03
OnDeviceReady for Ionic Framework
// Snippet from app.js
.run(function($ionicPlatform, $rootScope) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
@jawinn
jawinn / http-vhosts.conf
Created August 7, 2014 03:06
WAMP - Additional www folders using httpd-vhosts.conf (www2, www3)
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
@jawinn
jawinn / functions_wp_woo.php
Last active August 29, 2015 14:05
WooCommerce Support to a Custom Theme
<?php
// ----------------------------------------------------
// WooCommerce Additions to functions.php in WordPress
// ----------------------------------------------------
// Theme support. Removes warning message in admin.
add_theme_support( 'woocommerce' );
// Removing tabs and replace with simple product description (removes "Reviews" etc)
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );