Skip to content

Instantly share code, notes, and snippets.

View KZeni's full-sized avatar

Kurt Zenisek KZeni

View GitHub Profile
@KZeni
KZeni / 2012-09-06_complete_comments_v1.1.sql
Created September 10, 2012 18:22
Updated ThinkUp migration script to fix "Syntax error or access violation: 1103 Incorrect table name" error.
--
-- Comment encoded_locations table
--
CREATE TABLE IF NOT EXISTS `tu_encoded_locations_1_1` (
id int(11) NOT NULL AUTO_INCREMENT COMMENT 'Internal unique ID.',
short_name varchar(255) NOT NULL COMMENT 'Short name of a location, such as NYC.',
full_name varchar(255) NOT NULL COMMENT 'Full name of location, such as New York, NY, USA.',
latlng varchar(50) NOT NULL COMMENT 'Latitude and longitude coordinates of a place, comma-delimited.',
PRIMARY KEY (id),
KEY short_name (short_name)
@KZeni
KZeni / index.html
Created September 10, 2012 23:40
Text effect animations
<html>
<body>
<p>fly in, fly out</p>
</body>
</html>
@KZeni
KZeni / functions.php
Created September 27, 2012 18:30
Standalone / On-demand MailHide Function
// On-demand MailHide function (give it a raw email & it returns the raw MailHide url)
// *Useful when added to a WordPress theme's functions.php file if you need to mailhide an email anywhere
// *Usage: <a href="<?php echo mailhide_this('[email protected]'); ?>" target="_blank" title="Reveal email address">Send me an email</a>
function mailhide_this($email){
$pubkey = '01aIqfsfCm4RVQsVt7lx95tA==';
$privkey = '228ff0e136ae39a0c7bc22ab595667b9';
$ky = pack('H*', $privkey);
$mode = MCRYPT_MODE_CBC;
$enc = MCRYPT_RIJNDAEL_128;
$block_size = 16;
@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;
@KZeni
KZeni / gist:6873106
Created October 7, 2013 19:00
Prevent Twitter Typeahead drop down overlap due to IE7 z-index behavior (position:relative on container causes typeahead inputs after it to be a higher z-index by default [causing the drop down to be shown under it], but this makes it so each typeahead container decreases in z-index as it's later in the page).
var zIndexNumber = $('.twitter-typeahead').length+1;
$('.twitter-typeahead').each(function() {
$(this).css('z-index',zIndexNumber);
zIndexNumber -= 1;
});
@KZeni
KZeni / gist:7205026
Created October 28, 2013 21:22
Modified wr2x_srcset_rewrite function for Retina 2x WordPress plugin that fixes the [partial] stripping of HTML tags when using the HTML srcset option. This is the all-new function that follows the HTML rewrite's method of adding the retina image's code.
function wr2x_srcset_rewrite( $buffer ) {
if ( !isset( $buffer ) || trim( $buffer ) === '' )
return $buffer;
$doc = new DOMDocument();
@$doc->loadHTML( $buffer ); // = ($doc->strictErrorChecking = false;)
$imageTags = $doc->getElementsByTagName('img');
foreach ( $imageTags as $tag ) {
$img_info = parse_url( $tag->getAttribute('src') );
$img_pathinfo = ltrim( $img_info['path'], '/' );
$filepath = trailingslashit( ABSPATH ) . $img_pathinfo;
@KZeni
KZeni / gist:7225183
Created October 30, 2013 00:26
Updated jQuery Equalize.js to add option for "margin" to be true or false (false being default). This takes the bottom margin of the last child of the element(s) being equalized and adds that to the resulting height (simply using outerHeight isn't sufficient as that doesn't take the margin of children elements into account). Useful when there's …
;(function($) {
$.fn.equalize = function(options) {
var $containers = this, // this is the jQuery object
children = false,
reset = false,
margin = false,
equalize,
type;
@KZeni
KZeni / gb-chat-cloud.js
Last active December 27, 2015 08:19
Code adds tag cloud feature to Giant Bomb chat room (http://www.giantbomb.com/chat/). Should be able to copy & paste this into your browser's console to try it out on your own. Otherwise, let's see if this feature is added at some point.
// Set global variables to be used when switching between auto/manual refresh & their interactivity
origInitialTagCloudH = '80px';
initialTagCloudH = origInitialTagCloudH;
// Fuction to update tag cloud... simply execute updateTagCloud() when you want a fresh cloud
function updateTagCloud(){
// Get text from chat
text = '';
$('#conversation-main .msg').each(function(){text+= $(this).text()+' ';});
@KZeni
KZeni / smartWebBanner-example-full.js
Last active August 29, 2015 13:57
Smart Web App Banner Example (with full options)
$().smartWebBanner({
title: "Website Name", // What the title of the "app" should be in the banner | Default: "Web App"
titleSwap: true, // Whether or not to use the title specified here has the default label of the home screen icon (otherwise uses the page's <title> tag) | Default: true
url: '/', // URL to mask the page as before saving to home screen (allows for having it save the homepage of a site no matter what page the visitor is on) | Default: ""
author: "Company Name", // What the author of the "app" should be in the banner | Default: "Save to Home Screen"
speedIn: 300, // Show animation speed of the banner | Default: 300
speedOut: 400, // Close animation speed of the banner | Default: 400
useIcon: true, // Whether or not it should show site's apple touch icon (located via <link> tag) | Default: true
iconOverwrite: "http://other-url.com/icon-512x512.png", // Force the URL of the icon (even if found via <link> tag) | Default: ""
iconGloss: "auto", // Whether or not to show the gloss over the i
@KZeni
KZeni / smartWebBanner-example-defaults.js
Created March 17, 2014 19:13
Smart Web App Banner Example (using default settings)
$().smartWebBanner();