Skip to content

Instantly share code, notes, and snippets.

@mobz
mobz / isdst.md
Last active November 22, 2017 10:46

Investigations show that ALL timezones that observe DST are in DST

  • Jan 1st (southern hemisphere) or
  • July 1st (northern hemisphere)

No binary search is required to simply know if a given moment is observing dst.

This allows us to imagine the following algorithm

var getTimezoneOffset = require('get-timezone-offset');
@mobz
mobz / getTimeZone.js
Last active February 26, 2020 09:08
You can scrape the timezone database in javascript using the Intl object [ licensed CC0 ]
function getTimeZone( tz_str, date ) {
const utc_c = {
timeZone: "UTC",
hour12: false,
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "numeric",
@mobz
mobz / watchify browserlfy babelify
Created March 17, 2015 23:05
one line build system for browserify babeljs and watch ( watchify / babelify )
./node_modules/watchify/bin/cmd.js -v -t babelify src -o dist
@mobz
mobz / keybase.md
Created July 15, 2014 23:29
keybase.md

Keybase proof

I hereby claim:

  • I am mobz on github.
  • I am mobz (https://keybase.io/mobz) on keybase.
  • I have a public key whose fingerprint is 2EBE 8869 018A 03E6 7E59 034F D6A4 BEF4 A2AF B241

To claim this, I am signing this object:

@mobz
mobz / gist:6522629
Created September 11, 2013 12:02
Generating touch events for hammerjs tests
// === Generated Events === //
function customEvent( el, type ) {
var evt = document.createEvent("UIEvent");
evt.initUIEvent( type , true, true );
evt.touches = [ {} ];
el.dispatchEvent( evt );
}
function mouseEvent( el, type ) {
var evt = document.createEvent("MouseEvents");
@mobz
mobz / pre-commit
Created July 26, 2013 03:15
Don't commit jasmine specs containing iit or ddescribe
#!/bin/sh
# don't commit jasmine specs containing a ddescribe or iit
if git diff --cached --name-only | xargs egrep --include "*Spec.js" "\b(iit|ddescribe)\b"
then
echo "found Spec with iit or ddescribe"
exit 1
fi
@mobz
mobz / api.js
Created June 24, 2013 01:05
localStorage api
this.api = (function() {
var key = localStorage.getItem("_key") || 0;
return {
put: function( o, cb ) {
localStorage.setItem("_key", key++ );
localStorage.setItem( "squares:" + key, JSON.stringify( o ) );
setTimeout( function() {
cb(key);
}, 250 );
},
@mobz
mobz / DOMj.mdown
Created May 28, 2012 05:53
DOM transport via JSON (DOMj)

DOM transport via JSON (DOMj)

move to repo mobz/domj

@mobz
mobz / jstestrunner.html
Created May 6, 2012 09:10
Standalone Test Runner for JSTestDriver
<!DOCTYPE html>
<html>
<head>
<title>Standalone JSTestRunner</title>
<!-- source scripts -->
<script src="../../main/webapp/www/core/jquery.js"></script>
<script src="../../main/webapp/www/core/core.js"></script>
<script src="../../main/webapp/www/core/widgets.js"></script>
@mobz
mobz / gist:2602772
Created May 5, 2012 14:13 — forked from petermichaux/gist:2593030
Golfing Maria Views
// The following is sugar for writing out in full a view constructor function, its prototype, and the boilerplate
// for inheriting from maria.ElementView. This sugar uses naming conventions to wire together
// the view with its model, controller, and their methods.
//
// A checkit.TodoView will observe a checkit.TodoModel. When the model changes, the update method below is called.
// When a user clicks on the todo element, the handling is delegated to the checkit.TodoController's
// handleRootClick method.
//
maria.ElementView.declareConstructor(checkit, 'TodoView', {
template: '<li><span class="todo-content"></span></li>', // the template can live elsewhere, of course