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
requestAnimationFrame = window.requestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.msRequestAnimationFrame || | |
window.oRequestAnimationFrame || | |
function(callback) { setTimeout(callback, 1000 / 60); }; |
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 test() { | |
var evts = 'loadstart canplaythrough canplay loadeddata loadedmetadata abort emptied error stalled suspend waiting pause play volumechange playing seeked seeking durationchange progress ratechange timeupdate ended webkitbeginfullscreen webkitendfullscreen'; | |
var url = 'http://i3.ihaveu.net/image/auction/video/000/007/603/swf/000ab24b8d49a3331e6f7be30af7de1f.swf.mm320x232.mp4'; | |
var p = document.createElement('video'), | |
$p = $(p); | |
$('body').append(p); | |
$p.bind(evts, 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
/** | |
* Removes JavaScript comments from a string by replacing | |
* everything between block comments and everything after | |
* single-line comments in a non-greedy way. | |
* | |
* English version of the regex: | |
* match '/*' | |
* then match zero or more instances of any character (incl. \n) | |
* except for instances of '* /' (without a space, obv.) | |
* then match '* /' (again, without a space) |
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
//dateFormat(new Date(), '%Y-%m-%d %H:%M:%S'); | |
var dateFormat = function(date, fstr) { | |
return fstr.replace (/%[YmdHMS]/g, function (m) { | |
switch (m) { | |
case '%Y': return date.getFullYear(); | |
case '%m': m = date.getMonth() + 1; break; | |
case '%d': m = date.getDate(); break; | |
case '%H': m = date.getHours(); break; | |
case '%M': m = date.getMinutes(); break; | |
case '%S': m = date.getSeconds(); break; |
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
-- connected to AirPods by name | |
function connectToAirPods(name) | |
local current = hs.audiodevice.defaultInputDevice() | |
if current and current:name() == name then return true end | |
local device = hs.audiodevice.findOutputByName(name) | |
if device == nil then | |
hs.alert.show(name.." is not connected") | |
else | |
return device:setDefaultOutputDevice() |
OlderNewer