Skip to content

Instantly share code, notes, and snippets.

View johnpolacek's full-sized avatar

John Polacek johnpolacek

View GitHub Profile
@johnpolacek
johnpolacek / Fun Data-Binding with jQuery
Last active August 29, 2015 13:59
Simple jQuery Pattern for doing cool data-binding stuff using jQuery.on() and jQuery.trigger() - see the demo at http://cdpn.io/mhCai
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
<p>Simple jQuery Pattern for doing cool data-binding stuff using <code>jQuery.on()</code> and </code>jQuery.trigger()</code></p>
<h1>Messages</h1>
<div id="output"></div>
@johnpolacek
johnpolacek / Shuffle Array
Created August 3, 2012 19:14
Randomly shuffle the sort order of an array.
array.sort(function() { return 0.5 - Math.random() });
@johnpolacek
johnpolacek / jquery-plugin-boilerplate
Created August 21, 2012 15:06
jQuery Plugin Boilerplate
/*
PluginName - Plug In Description
by John Polacek (@johnpolacek)
Dual licensed under MIT and GPL.
Dependencies: jQuery
*/
;(function($) {
@johnpolacek
johnpolacek / mura-state-select.cfm
Created August 24, 2012 21:09 — forked from joebrislin/mura-state-select.cfm
Code for Select Drop-down to insert States including District of Columbia into Mura CMS Form Builder
<select data-required="false" name="state" id="state">
<option selected="selected" value="">--</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
@johnpolacek
johnpolacek / gist:3490828
Created August 27, 2012 17:53
capitalize(word)
function capitalize(word) {
return word.charAt(0).toUpperCase() + word.substr(1);
}
@johnpolacek
johnpolacek / gist:3503441
Created August 28, 2012 19:51
PHP JSON Proxy
<?php
header('Content-type: application/json');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, preg_replace('/ /', "%20", $_REQUEST['url']));
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$head = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
@johnpolacek
johnpolacek / responsive-context-images.html
Created August 29, 2012 20:53 — forked from vasilisvg/responsive-context-images.html
Responsive context aware images without cookies or server logic
<!doctype html>
<meta charset="UTF-8">
<title>Client side context aware responsive images</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.image-container {
width: 50%;
position: relative;
}
.image-container img {
@johnpolacek
johnpolacek / gist:3853033
Created October 8, 2012 15:10
IE Inline-Block Fix
display: inline-block;
*display: block;
zoom: 1;
@johnpolacek
johnpolacek / gist:3899699
Created October 16, 2012 14:42
IE8 Transparent PNG Background Fix
#thing-with-transparent-png-bgr {
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF, endColorstr=#00FFFFFF);
}
/* via http://www.jacklmoore.com/notes/ie-transparency-problems */
@johnpolacek
johnpolacek / gist:3945823
Created October 24, 2012 12:32
Basic HTML5 Page
<!doctype html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Default Page Title</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="styles.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<!--[if lt IE 9]>