(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width;height=device-height; user-scalable=no" /> | |
<meta http-equiv="Content-type" content="text/html;charset=utf-8"> | |
<title>PhoneGap Reverse Geolocation Lookup</title> | |
<script type="text/javascript" src="cordova-1.7.0.js"></script> | |
<script type="text/javascript" src="jquery-1.7.2.min.js"></script> | |
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script> | |
var bb, reader; | |
var meta = { | |
"title": "mozilla.png", | |
"mimeType": "image/png", | |
"description": "Mozilla Official logo" | |
}; | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', 'https://developer.mozilla.org/media/img/mdn-logo-sm.png', true); |
/* | |
THIS GIST IS OUT OF DATE AND NOT MONITORED | |
PLEASE SEE https://github.com/leecrossley/cordova-plugin-shake-detection | |
*/ | |
var shake = (function () { | |
var shake = {}, | |
watchId = null, | |
options = { frequency: 300 }, | |
previousAcceleration = { x: null, y: null, z: null }, |
( function( window, undefined ) { | |
'use strict'; | |
// helper function | |
function capitalize( str ) { | |
return str.charAt(0).toUpperCase() + str.slice(1); | |
} | |
// ========================= getStyleProperty by kangax =============================== |
var __slice = Array.prototype.slice; | |
(function($) { | |
var Sketch; | |
$.fn.sketch = function() { | |
var args, key, sketch; | |
key = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | |
if (this.length > 1) { | |
$.error('Sketch.js can only be called on one element at a time.'); | |
} | |
sketch = this.data('sketch'); |
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>jQuery Animate() Step Demo</title> | |
<script type="text/javascript" src="../jquery-1.4.1.js"></script> | |
<script type="text/javascript"> | |
// When the DOM is ready, initialize. | |
jQuery(function( $ ){ |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
// a modification from http://goo.gl/tLbLXr | |
var attachEvent = function(element, event, fn) { | |
if (element.addEventListener) | |
element.addEventListener(event, fn, false); | |
else if (element.attachEvent) // if IE | |
element.attachEvent('on' + event, fn); | |
} | |
var onReady = function(func) { |
// Below are some useful Flow utility type functions, some I've written and some I've found on the web. | |
// All contributions welcome! | |
// Extracting a data type from a maybe type, e.g. getting `string` from `?string` | |
type _ExtractFromMaybe<T, M: ?T> = T | |
export type ExtractFromMaybe<M> = _ExtractFromMaybe<*, M> | |
// FROM https://hackernoon.com/redux-flow-type-getting-the-maximum-benefit-from-the-fewest-key-strokes-5c006c54ec87 | |
// Extracting the type of a function's return value | |
type _ExtractReturn<R, F: (...args: any[]) => R> = R |
let cache = new Map(); | |
let pending = new Map(); | |
function fetchTextSync(url) { | |
if (cache.has(url)) { | |
return cache.get(url); | |
} | |
if (pending.has(url)) { | |
throw pending.get(url); | |
} |