Skip to content

Instantly share code, notes, and snippets.

View timrwood's full-sized avatar

Tim Wood timrwood

View GitHub Profile
@timrwood
timrwood / problem-solved.txt
Created October 17, 2012 17:55
Folder Structure
/base
/header
_header.scss
/footer
_footer.scss
/modules
_my-module.scss
/mixins
_new-mixin.scss
/sections
@timrwood
timrwood / sync.js
Created October 15, 2012 16:20
Syncing local clock with server time
var clientNow = moment(),
serverNow;
$.ajax('/gettime', function (resp) {
serverNow = moment(resp);
});
function syncedMoment(i, f) {
return moment(i, f).subtract('milliseconds', clientNow - serverNow);
}
{
"bold_folder_labels": true,
"highlight_modified_tabs": true,
"color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
"draw_white_space": "all",
"font_options":
[
"no_bold",
"no_round",
"subpixel_antialias"
@timrwood
timrwood / dabblet.css
Created June 26, 2012 04:33
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@timrwood
timrwood / dabblet.css
Created June 26, 2012 01:17
Scrolling shadows by @kizmarh and @LeaVerou
/**
* Scrolling shadows by @kizmarh and @leaverou
* Only works in browsers supporting background-attachment: local; & CSS gradients
* Degrades gracefully
*/
html {
background: white;
font: 120% sans-serif;
}
@timrwood
timrwood / dabblet.css
Created June 26, 2012 01:11
Scrolling shadows by @kizmarh and @LeaVerou
/**
* Scrolling shadows by @kizmarh and @leaverou
* Only works in browsers supporting background-attachment: local; & CSS gradients
* Degrades gracefully
*/
html {
background: white;
font: 120% sans-serif;
}
@timrwood
timrwood / formatted diff.js
Created June 22, 2012 15:58
Formatted diff
function pad(input) {
if (input < 10) {
return '0' + input;
}
return input;
}
moment.duration.fn.formatCountdown = function() {
var output = [
pad(this.years()),
@timrwood
timrwood / gist:2789940
Created May 25, 2012 19:08
Year difference
var now = new Date();
var birth = new Date(1986, 6, 10); // remember that we're using zero indexed months...
var yearDiff = now.getFullYear() - birth.getFullYear();
var monthDiff = now.getMonth() - birth.getMonth();
var dayDiff = now.getDate() - birth.getDate();
var hourDiff = now.getHours() - birth.getHours();
var minuteDiff = now.getMinutes() - birth.getMinutes();
var secondDiff = now.getSeconds() - birth.getSeconds();
var millisecondDiff = now.getMilliseconds() - birth.getMilliseconds();
@timrwood
timrwood / gist:2726713
Created May 18, 2012 17:53
Routing roundup
@timrwood
timrwood / moment.calendarWithoutTime.js
Created February 8, 2012 16:50
Moment calendar without time plugin
(function(){
var oldcal = moment.calendar;
var newcal = {
sameDay : '[Today]',
nextDay : '[Tomorrow]',
nextWeek : 'dddd',
lastDay : '[Yesterday]',
lastWeek : '[last] dddd',
sameElse : 'L'
};