Skip to content

Instantly share code, notes, and snippets.

View imbcmdth's full-sized avatar

Jon-Carlos Rivera imbcmdth

View GitHub Profile
/**
* @file time-ranges.js
*
* Should create a fake TimeRange object
* Mimics an HTML5 time range instance, which has functions that
* return the start and end times for a range
* TimeRanges are returned by the buffered() method
*
* @param {(Number|Array)} Start of a single range or an array of ranges
* @param {Number} End of a single range
@imbcmdth
imbcmdth / fast_math.js
Last active June 26, 2021 05:54
Fast Approximate Functions for JavaScript based on https://code.google.com/p/fastapprox/
var Approx = {
fastlog2: (function () {
var a = new ArrayBuffer(4),
i = new Int32Array(a),
f = new Float32Array(a);
return function fasterLog2 (number) {
f[0] = number;
var t = i[0] * 1.1920928955078125e-7;
return t - 126.94269504;
The meadowlark and the chim-choo-ree and the sparrow
Set to the sky in a flying spree, for the sport of the pharaoh
A little while later the Pharisees dragged a comb through the meadow
Do you remember what they called up to you and me in our window?
There is a rusty light on the pines tonight
Sun pouring wine, lord, or marrow
Down into the bones of the birches
And the spires of the churches
Jutting out from the shadows
// http://codepen.io/incompl/pen/KwOqYx
var games = [["PP","Pianissimo"],
["Fairy","Tale"],
["Fork","Tale"],
["Game","Thrones","Genesis"],
["Hat","Time"],
["Mind","Forever","Voyaging"],
["Ace","Spades"],
["Aces","Pacific"],
["Act","War","Direct","Action"],
// Return a function that allows the passed-in function to be called
// at most `times` times
let numTimes = (cb, times) => (...args) => {
if (times) {
time--;
return cb(...args);
}
}
// Allow a function to be called only once
enum CanPlayTypeEnum { "" /* empty string */, "maybe", "probably" };

interface HTMLMediaElement : HTMLElement {
  // error state
  readonly attribute MediaError? error;
  // network state
           attribute DOMString src;
  readonly attribute DOMString currentSrc;
           attribute DOMString crossOrigin;
ffprobe C2.ts -show_frames | ./frames_to_json.js > C2.json
@imbcmdth
imbcmdth / saveTA.js
Created March 22, 2016 15:43
Save a typed array as a file from the console (add as a snippet in chrome dev tools)
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs=saveAs||function(view){"use strict";if(typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var doc=view.document,get_URL=function(){return view.URL||view.webkitURL||view},save_link=doc.createElementNS("http://www.w3.org/1999/xhtml","a"),can_use_save_link="download"in save_link,click=function(node){var event=new MouseEvent("click");node.dispatchEvent(event)},is_safari=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),webkit_req_fs=view.webkitRequestFileSystem,req_fs=view.requestFileSystem||webkit_req_fs||view.mozRequestFileSystem,throw_outside=function(ex){(view.setImmediate||view.setTimeout)(function(){throw ex},0)},force_saveable_type="application/octet-stream",fs_min_size=0,arbitrary_revoke_timeout=500,revoke=function(file){var revoker=function(){if(typeof file==="string"){get_URL().revokeObjectURL(file)}else{file.remove()}};if(view.chrome){revoker()}else{setTimeout(revoker,arbitrar

CHANGELOG


2.0.1 (2016-03-11)

  • First release of the ES6 version of the SourceHandler
  • All new lint/build/test setup via the generator-videojs-plugin project

var x = event.pageX - screen.offsetLeft;
var y = event.pageY - screen.offsetTop;
function distance(x, y) {
return Math.sqrt(x * x + y * y);
}
var d = distance(x - targetX, y - targetY);
if (d <= tolerance) {