Skip to content

Instantly share code, notes, and snippets.

View KZeni's full-sized avatar

Kurt Zenisek KZeni

View GitHub Profile
@billerickson
billerickson / gist:1209601
Created September 11, 2011 13:46
Add custom fields to Display Posts Shortcode
<?php
/**
* Add custom fields to Display Posts Shortcode
* @author Bill Erickson
* @link http://wordpress.org/extend/plugins/display-posts-shortcode/
* @link http://www.billerickson.net/shortcode-to-display-posts/comment-page-1/#comment-4565
*
* @param $output string, the original markup for an individual post
* @param $atts array, all the attributes passed to the shortcode
* @param $image string, the image part of the output
@jsundram
jsundram / cull.py
Last active April 5, 2023 15:22
Check if lat long is inside the bounds of the continental US (box model, not shape)
# http://en.wikipedia.org/wiki/Extreme_points_of_the_United_States#Westernmost
top = 49.3457868 # north lat
left = -124.7844079 # west long
right = -66.9513812 # east long
bottom = 24.7433195 # south lat
def cull(latlngs):
""" Accepts a list of lat/lng tuples.
returns the list of tuples that are within the bounding box for the US.
NB. THESE ARE NOT NECESSARILY WITHIN THE US BORDERS!
@jcanfield
jcanfield / wp-modifydb.php
Created March 29, 2012 17:06
Serialized PHP Search and Replace
<?php
/**
*
* Safe Search and Replace on Database with Serialized Data v2.0.1
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
* data on the database and change it, even if it's within a serialized PHP
* array.
@stevesouders
stevesouders / activetable.js
Last active March 18, 2024 15:15
ActiveTable is a bookmarklet that makes any table sortable. It also allows you to remove columns, and it remembers the removed columns for next time. Use alt+click to UNhide all columns (and clear memory). To use it, create a bookmark called "ActiveTable" that has this URL: javascript:(function(){ var jselem=document.createElement('SCRIPT'); jse…
// ActiveTable - a bookmarklet to make tables sortable and editable
function init() {
var aHrows = getHrows();
var numHrows = aHrows.length;
var aHidden = getHiddenColumns();
ATpopup = document.createElement("div");
ATpopup.style.cssText = "position: absolute; visibility: hidden; padding: 0; font-family: Arial; background-color: rgba(255, 255, 255, 0.9); border-radius: .5em; text-align: center; box-shadow: .05em .05em .5em #00C;";
ATpopup.innerHTML = "<a href='sort' title='sort' onclick='sortColumn(); return false'><img border=0 src='http://stevesouders.com/images/sort_up_down.png' style='padding-top: 0.2em;'></a><br><a href='hide' style='color: #C00; font-family: monospace; font-size: 1.5em; text-decoration: none;' title='hide' onclick='hideColumn(); return false'>x</a>"; // TODO - use protocol-less URL for img
@KZeni
KZeni / gist:6735287
Created September 27, 2013 21:14
Prevent memory limit crash in Mobile Safari (and other mobile browsers) when viewing an Impress.JS presentation with a lot of images and/or 3d elements by only showing the current, next, and previous slide on mobile devices.
<script>
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){ // Detect mobile browsers & use memory optimized styling if on mobile (hide all but the previous & next slides). Can prevent crashes when presentation contains many images and/or 3d elements.
var root = document.documentElement;
root.className += ' mobile';
}else{
var root = document.documentElement;
root.className += ' desktop';
}
function getPreviousSibling(element){
var p = element;
@jacrook
jacrook / font_variables.scss
Last active July 2, 2023 16:47
Sass Css Font Stack Variables
//////////////////////////////////////////////////////////////
// Font Variables (http://cssfontstack.com/)
//////////////////////////////////////////////////////////////
//
// Serif font-stacks
//
$baskerville-font-stack: "Big Caslon", "Book Antiqua", "Palatino Linotype", Georgia, serif !default;
@eteubert
eteubert / wordpress-passwort-reset-unmultisite.php
Last active May 4, 2024 18:30
Multisite: Passwort Reset on Local Blog
<?php
/**
* Plugin Name: Multisite: Passwort Reset on Local Blog
* Plugin URI: https://gist.github.com/eteubert/293e07a49f56f300ddbb
* Description: By default, WordPress Multisite uses the main blog for passwort resets. This plugin enables users to stay in their blog during the whole reset process.
* Version: 1.0.0
* Author: Eric Teubert
* Author URI: http://ericteubert.de
* License: MIT
*/
@spivurno
spivurno / gw-gravity-forms-advanced-conditional-shortcodes.php
Last active October 21, 2020 17:51
Gravity Wiz // Gravity Forms // Advanced Conditional Shortcodes
<?php
/**
* Gravity Wiz // Gravity Forms // Advanced Conditional Shortcodes
*
* [gravityforms action="conditional" relation="any"
value="{:2}" operator="is" compare="First Choice"
value2="{:1}" operator2="isnot" compare2="Second Choice"]
Content you would like to conditionally display.
[/gravityforms]
*
@davidnash
davidnash / index.php
Created May 12, 2016 09:43
Pretty print fractions as HTML characters using PHP
//from post at http://davidnash.com.au/pretty-print-fractions-html-characters-using-php/
//supply a string, eg 1/2, return eg ½
function str_to_fraction( $str ) {
$f = explode('/', $str);
if( count($f) != 2 ) {
return $str; //if there's multiply / chars, this isn't a fraction
}
else {
@tripflex
tripflex / functions.php
Last active February 13, 2024 19:03
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback