Skip to content

Instantly share code, notes, and snippets.

Avatar

Natalie Downe natbat

View GitHub Profile
View gist:e01446d68f1e1f6840f3
https://gist.github.com/natbat/b283b8fb6560dbc4ace2
View gist:843506aeb110a6b8ca3b
Check this out... ‮this is backwards‬
View downlevel reveal conditional comment
<!--[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]-->
View Javascript wait function
function wait(millis) {
var date = new Date();
var curDate = null;
do {
curDate = new Date();
} while(curDate-date < millis);
var date = null;
var curDate = null;
View Print footer
View Print styles preview
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 Sep 1, 2015
Future proof console.log() code from breaking IE
View console.js
// 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() {};
View On unload notification
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 Sep 22, 2015
Person list component on Eventbrite
View person-list.html
<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 Nov 10, 2011
Works out the time since, takes a an argument in unix time (seconds)
View TimeSince.php
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'),
);