Skip to content

Instantly share code, notes, and snippets.

View timrwood's full-sized avatar

Tim Wood timrwood

View GitHub Profile
@timrwood
timrwood / popout.txt
Last active November 21, 2019 15:22
YouTube and Vimeo video player popout bookmarklett
javascript:!function(){var h=location.href,y=h.match(/(youtu.be\/|v\/|u\/\w\/|embed\/|v=)([^#\&\? ]*).*/),v=h.match(/(vimeo.com\/)([^#\&\? ]*)/);y=y&&'http://www.youtube.com/watch_popup/?v='+y[2];v=v&&'http://player.vimeo.com/video/'+v[2];window.open(y||v,"_blank","height=345,width=560");}()
@timrwood
timrwood / api.md
Created May 22, 2014 15:41
Moment Timezone API

Formats

// Packed
"America/Los_Angeles|PST PDT|70 60|010101010101|-h234i0 fgd0 wef0 fgd0 wef0 fgd0 wef0"

// Unpacked
{
	name    : "America/Los_Angeles",
	abbrs   : ["PST", "PDT", "PST", "PDT", "PST", "PDT", "PST", "PDT", "PST", "PDT"],
@timrwood
timrwood / process.md
Created May 31, 2014 01:26
Moment Timezone Data Update Process

1. Download from iana.org/time-zones

temp/download/northamerica
temp/download/africa
temp/download/...

2. Compile with zic(8)

moment.tz.add(
{
"links": {
"Africa/Asmera": "Africa/Asmara",
"Africa/Timbuktu": "Africa/Bamako",
"America/Argentina/ComodRivadavia": "America/Argentina/Catamarca",
"America/Atka": "America/Adak",
"America/Buenos_Aires": "America/Argentina/Buenos_Aires",
"America/Catamarca": "America/Argentina/Catamarca",
"America/Coral_Harbour": "America/Atikokan",
manager dist manifest export ignore include entry
npm npm package.json cjs .npmignore #main
bower git bower.json umd #ignore #main
component git component.json umd #files #main
spm git package.json#spm umd .spmignore #output #main
packagist git composer.json umd
ender npm package.json cjs .npmignore #ender
dojo ??? package.json#dojoBuild umd #dojoBuild
jspm npm/git package.json#jspm any #ignore #files #main
var momento = moment(556095600000); // 1987-08-16T07:00:00.000Z
var day = momento.date(); // 16
var month = momento.month() + 1; // 8
var year = momento.year(); // 1987
var timeperiods = {
year : moment(year, "YYYY").toISOString(), // 1987-01-01T08:00:00.000Z
month : moment(month + "-" + year, "MM-YYYY").toISOString(), // 1987-08-01T07:00:00.000Z
day : moment(day + "-" + month + "-" + year, "DD-MM-YYYY").toISOString() // 1987-08-16T07:00:00.000Z
}
@timrwood
timrwood / moment-immutable.js
Created September 16, 2014 17:16
Immutable Moments
(function (root, factory) {
"use strict";
if (typeof define === 'function' && define.amd) {
define(['moment'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('moment'));
} else {
factory(root.moment);
}
}(this, function (moment) {
@timrwood
timrwood / dirty-helpers.js
Created November 9, 2014 00:13
Ember Data Dirty Relationships Mixins
import Ember from 'ember';
export { dirtyHasMany, dirtyBelongsTo, dirtyMixin };
var dirty = 'relationshipIsDirty';
function dirtyMixin (obj) {
var args = Object.keys(obj);
var comp = Ember.computed;
args.push('isDirty');
obj[dirty] = comp.any.apply(comp, args);
* { outline: 1px solid red; }
*:before { outline: 1px dotted #800000; }
*:after { outline: 1px dashed #ff8080; }
* * { outline: 1px solid #ff4d00; }
* *:before { outline: 1px dotted #802600; }
* *:after { outline: 1px dashed #ffa680; }
* * * { outline: 1px solid #ff9900; }
* * *:before { outline: 1px dotted #804d00; }
* * *:after { outline: 1px dashed #ffcc80; }
* * * * { outline: 1px solid #ffe500; }
@timrwood
timrwood / grouped-by-offsets.js
Last active August 29, 2015 14:21
Alternate moment timezone current timezone filters.
}
function matchesAtIndex (zone, i) {
var aDay = 50 * 24 * 60 * 60 * 1000;
if (i < zone.offsets.length - 1 && new Date(zone.untils[i] + aDay).getTimezoneOffset() !== zone.offsets[i + 1]) {
// console.log(zone.name, new Date(zone.untils[i] + aDay).getTimezoneOffset(), zone.offsets[i + 1], '+1');
// console.log(zone.name, zone.untils[i + 1], aDay, zone.untils[i + 1] + aDay);
return false;
}
// console.log(zone.name, new Date(zone.untils[i] - aDay).getTimezoneOffset(), zone.offsets[i]);