Skip to content

Instantly share code, notes, and snippets.

@artlawry
artlawry / radio-control ie7 ie8 shim.js
Last active August 29, 2015 14:04
Adds a checked class to all checked radio buttons for
(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 August 29, 2015 14:25
Measure how fast an image loads: mainly to test network speed
/*
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 December 14, 2015 16:38
A shim for jQuery that uses the native "classList" property of an element for class modifications, if available.
/*global jQuery */
;(function($) {
/*global document */
"use strict";
if (typeof document !== 'undefined' && ('classList' in document.createElement('a'))) {
var $ = jQuery;
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);
});
.Absolute-Center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
@shshaw
shshaw / functions.php
Last active August 22, 2016 10:39 — 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)
<?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 October 14, 2016 08:11 — 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
<?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 February 5, 2017 19:46
A function for sending Wordpress Advanced Custom Fields (ACF) Repeater Field, Flexible Content Field, Gallery Field data with Thermal API.
<?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) {
@edwinwebb
edwinwebb / gist:5155504
Last active February 1, 2019 15:39
A simple less loop with comments and simple from, to syntax.
/* Define two variables as the loop limits */
@from : 0;
@to : 10;
/* Create a Parametric mixin and add a guard operation */
.loop(@index) when(@index =< @to) {
/* As the mixin is called CSS is outputted */
div:nth-child(@{index}) {
top: unit(@index * 100, px);
const CODES = ['o', 'W', 'X', 'H', 'i', 'a', 'l', 's', 's','Q', 'v', 'y'];
console.log(`/${CODES.filter((c,i) => i % 3 == 0).join('')}`)