Skip to content

Instantly share code, notes, and snippets.

Shaw shshaw

Block or report user

Report or block shshaw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@artlawry
artlawry / radio-control ie7 ie8 shim.js
Last active Aug 29, 2015
Adds a checked class to all checked radio buttons for
View radio-control ie7 ie8 shim.js
(function () {
var labels, label, inputs, input, type, i, ilen;
if (!document.addEventListener) {
labels = document.getElementsByTagName('label');
inputs = document.getElementsByTagName('input');
function inputClick() {
clicked = window.event.srcElement;
@markhowellsmead
markhowellsmead / speed_test.js
Last active Aug 29, 2015
Measure how fast an image loads: mainly to test network speed
View speed_test.js
/*
This example is the basis of a simple WordPress plugin
which measures the download speed of a sample image
and then sends this information to the server for further action.
(e.g. writing to a database)
*/
function measureSpeed() {
var duration = (endTime - startTime) / 1000;
var bitsLoaded = downloadSize * 8;
@raybellis
raybellis / jquery.classlist.js
Last active Dec 14, 2015
A shim for jQuery that uses the native "classList" property of an element for class modifications, if available.
View jquery.classlist.js
/*global jQuery */
;(function($) {
/*global document */
"use strict";
if (typeof document !== 'undefined' && ('classList' in document.createElement('a'))) {
var $ = jQuery;
View modernizr.shaw.js
Modernizr.testStyles('#modernizr { height: 50px; width: 50px; margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0; display: table; }', function(elem, rule) {
Modernizr.addTest('shaw', Math.round(window.innerHeight / 2 - 25) === elem.offsetTop);
});
View 01. vertical and horizontal centering
.Absolute-Center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
@shshaw
shshaw / functions.php
Last active Aug 22, 2016 — forked from fardog/functions.php
Fixes a `Creating default object from empty value` on [line 61](https://gist.github.com/fardog/9356458#file-functions-php-L61)
View functions.php
<?php
function north_cast_api_data($content) {
if (is_numeric($content)) $content = intval($content);
else {
$unserialized_content = @unserialize($content);
// we got serialized content
if ($unserialized_content !== false) {
// make sure that integers are represented as such, instead of str
foreach ($unserialized_content as $fn => &$c) {
@davidmh
davidmh / custom-post-type-archive-menu-links.php
Last active Oct 14, 2016 — forked from helgatheviking/custom-post-type-archive-menu-links.php
Adds Custom Post Type archives to the WordPress-powered menus. Compatible with WP 3.8
View custom-post-type-archive-menu-links.php
<?php
/*
Plugin Name: Custom Post Type Archive Menu Links
Plugin URI: http://codeseekah.com/2012/03/01/custom-post-type-archives-in-wordpress-menus-2/
Description: Easily Add Custom Post Type Archives to the Nav Menus
Version: 1.1
Author: soulseekah
Author URI: http://codeseekah.com
License: GPL2
@fardog
fardog / functions.php
Last active Feb 5, 2017
A function for sending Wordpress Advanced Custom Fields (ACF) Repeater Field, Flexible Content Field, Gallery Field data with Thermal API.
View functions.php
<?php
function north_cast_api_data($content) {
if (is_numeric($content)) $content = intval($content);
else {
$unserialized_content = @unserialize($content);
// we got serialized content
if ($unserialized_content !== false) {
// make sure that integers are represented as such, instead of str
foreach ($unserialized_content as $fn => &$c) {
View gist:afac4906f2b330509fc7
<svg preserveAspectRatio="xMinYMin" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 560 1388">
<defs>
<mask id="canTopMask">
<image width="560" height="1388" xlink:href="img/can-top-alpha.png"></image>
</mask>
</defs>
<image mask="url(#canTopMask)" id="canTop" width="560" height="1388" xlink:href="can-top.jpg"></image>
</svg>
@nolanlawson
nolanlawson / parens-and-perf-counterpost.md
Last active Nov 28, 2017
"Parens and Performance" – counterpost
View parens-and-perf-counterpost.md

"Parens and Performance" – counterpost

Kyle Simpson (@getify) wrote a very thoughtful post decrying optimize-js, which is a tool I wrote that exploits known optimizations in JavaScript engines to make JS bundles parse faster (especially minified bundles, due to what could be reasonably described as a bug in Uglify).

Kyle lays out a good case, but I tend to disagree with nearly all his points. So here's my rebuttal.

You can’t perform that action at this time.