Skip to content

Instantly share code, notes, and snippets.

View natbat's full-sized avatar

Natalie Downe natbat

View GitHub Profile
https://gist.github.com/natbat/b283b8fb6560dbc4ace2
@natbat
natbat / gist:843506aeb110a6b8ca3b
Created May 18, 2015 22:24
Back to front text
Check this out... ‮this is backwards‬
<!--[if lte IE 6]><![if gte IE 7]><![endif]-->
<!-- This is a bit mad, but code inside here is served to everything except browsers less than IE7 -->
<!--[if lte IE 6]><![endif]><![endif]-->
function wait(millis) {
var date = new Date();
var curDate = null;
do {
curDate = new Date();
} while(curDate-date < millis);
var date = null;
var curDate = null;
if ((location.href.split('?')[1] || '').indexOf('print') > -1) {
/* assuming all other stylesheets are on media all, this means you can use the ?print query string to preview print styles */
$('link[media=print]').attr('media', '');
}
@natbat
natbat / console.js
Created September 1, 2015 00:14
Future proof console.log() code from breaking IE
// Console-polyfill. MIT license.
// https://github.com/paulmillr/console-polyfill
// Make it safe to do console.log() always.
(function(global) {
'use strict';
global.console = global.console || {};
var con = global.console;
var prop, method;
var empty = {};
var dummy = function() {};
warning = false;
window.onbeforeunload = function() {
if (warning) {
return 'You have made changes on this page that you have not yet confirmed. If you navigate away from this page you will loose your unsaved changes';
}
}
@natbat
natbat / person-list.html
Last active September 22, 2015 23:55
Person list component on Eventbrite
<div class="list-person g-group">
<ul>
<li class="g-cell g-cell-1-1 g-cell-md-1-3 g-cell-lg-1-4">
<img src="http://dummyimage.com/320x320/000/fff.jpg" alt="" class="list-person--image">
<h3 class="list-person--name">Anthony Edward Stark</h3>
<p>Stark Industries</p>
<p>Iron man</p>
</li>
<li class="g-cell g-cell-1-1 g-cell-md-1-3 g-cell-lg-1-4">
<img src="http://dummyimage.com/320x320/000/fff.jpg" alt="" class="list-person--image">
@natbat
natbat / TimeSince.php
Created November 10, 2011 10:39
Works out the time since, takes a an argument in unix time (seconds)
function time_since($original) {
// array of time period chunks
$chunks = array(
array(60 * 60 * 24 * 365 , 'year'),
array(60 * 60 * 24 * 30 , 'month'),
array(60 * 60 * 24 * 7, 'week'),
array(60 * 60 * 24 , 'day'),
array(60 * 60 , 'hour'),
array(60 , 'minute'),
);