This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# history options | |
export HISTCONTROL=erasedups | |
export HISTSIZE=10000 | |
export HISTIGNORE='&:ls:[bf]g:' | |
shopt -s histappend | |
export COMMAND_MODE=unix2003 | |
# colors for misc things |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// audio-levels.js | |
// https://github.com/bgrins/devtools-snippets | |
// Print out audio levels for all video / audio elements on the page. | |
// Watch out for: "MediaElementAudioSource outputs zeroes due to CORS access restrictions" ...for x-origin media urls | |
(function() { | |
[].forEach.call(document.querySelectorAll("video,audio"), function(media) { | |
var splitPath = media.src.split('/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extend JW Player instance with Backbone Events | |
// binds jw events to trigger using lowercase names 'ready', 'play', 'time', etc... | |
// allows us to add and remove listers using 'on', 'off', 'once', etc... | |
// Requires jwplayer.js and Backbone.js (which includes underscore) | |
// For more info see: http://backbonejs.org/#Events | |
// and http://support.jwplayer.com/customer/portal/articles/1413089-javascript-api-reference | |
// IMPORTANT: define listeners in the same scope as the new jw instance returned by setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var r = 19, Robot = function(e) { | |
this.data = {}, this.time = 0, this.arenaTopLeft = {x: r,y: r}, this.arenaTopRight = {x: e.arenaWidth - r,y: r}, this.arenaBottomLeft = {x: r,y: e.arenaHeight - r}, this.arenaBottomRight = {x: e.arenaWidth - r,y: e.arenaHeight - r}, this.arenaCenter = {x: e.arenaWidth / 2,y: e.arenaHeight / 2}, this.target1 = null, this.target2 = null | |
}, p = Robot.prototype; | |
(function() { | |
var e = r, t = r * r, n = 20, i = 2, s = 50, o = 50; | |
p.sub = function(e, t) { | |
return {x: e.x - t.x,y: e.y - t.y} | |
}, p.add = function(e, t) { | |
return {x: e.x + t.x,y: e.y + t.y} | |
}, p.neg = function(e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(jwplayer) { | |
var utils = jwplayer.utils; | |
var _ = jwplayer._; | |
var TIMEOUT_MS = 25; | |
var TIMEOUT_SEC = TIMEOUT_MS/1000; | |
var TIMER = 'timer'; | |
function formatTime(t) { | |
t *= 1000; // seconds to milliseconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(jwplayer) { | |
const container = jwplayer().getContainer(); | |
const elements = Array.prototype.slice.call(container.querySelectorAll('*')) | |
.filter(element => element.tagName !== 'path'); | |
elements.unshift(container); | |
const listeners = elements.reduce((accumulator, element) => { | |
const listenersObj = getEventListeners(element); | |
return accumulator.concat(Object.keys(listenersObj).reduce((accumulator2, name) => { | |
listenersObj[name].forEach(eventListener => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (video) { | |
function toString() { | |
return ((video.parentNode ? ('<' + video.parentNode.nodeName + '>') : '') + '<' + video.nodeName + '>') | |
.toLowerCase(); | |
} | |
function videoEventHandler(e) { | |
console.warn(toString() + ' >> "' + e.type + '"'); | |
} | |
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | |
if (MutationObserver) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// playbackrate.js | |
// https://github.com/bgrins/devtools-snippets | |
// Increase playbackRate for all video / audio elements on the page. | |
(function() { | |
console.group('playbackRate'); | |
[].forEach.call(document.querySelectorAll("video,audio"), function(media) { | |
var splitPath = media.src.split('/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use WebAudio API to detect audio playback with volume | |
// Returns early with false when audio could not be playing | |
// Returns null if WebAudio API cannot be used while media is in a playing state | |
function isMediaPlayingAudio(mediaElement) { | |
if (media.paused || media.muted || media.volume === 0 || media.played.length < 1) { | |
return false; | |
} | |
let analyser = media.audioAnalyser; | |
let audioCtx = media.audioCtx; | |
if (!analyser) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
mkdir -p variant_source | |
ffmpeg -y -i tearsofsteel_4k.mov -vcodec libx264 -preset veryfast -crf 18 -profile:v baseline -s 480x212 -aspect 9/4 -acodec aac -strict experimental -ac 2 -b:a 96k -ar 44100 -bufsize 360K -maxrate 360K variant_source/ld.mp4 | |
ffmpeg -y -i tearsofsteel_4k.mov -vcodec libx264 -preset veryfast -crf 18 -profile:v main -s 640x288 -aspect 9/4 -an -bufsize 720K -maxrate 720K variant_source/sd.mp4 | |
ffmpeg -y -i tearsofsteel_4k.mov -vcodec libx264 -preset veryfast -crf 18 -profile:v high -s 1280x572 -aspect 9/4 -an -bufsize 2400K -maxrate 2400K variant_source/hd.mp4 | |
ffmpeg -y -i tearsofsteel_4k.mov -vcodec libx264 -preset veryfast -crf 18 -profile:v high -s 1920x856 -aspect 9/4 -an -bufsize 3200K -maxrate 3200K variant_source/fullhd.mp4 | |
ffmpeg -y -i tearsofsteel_4k.mov -vcodec libx264 -preset veryfast -crf 18 -profile:v high -s 2560x1142 -aspect 9/4 -an -bufsize 4800K -maxrate 4800K variant_source/quadhd.mp4 |