Skip to content

Instantly share code, notes, and snippets.

View montmanu's full-sized avatar

Chris Montoro montmanu

  • New York Times
  • New York, NY
View GitHub Profile
@montmanu
montmanu / visibility.html
Last active December 17, 2015 19:59
Page Visibility
<!DOCTYPE html>
<title>Page Visibility</title>
<meta name="viewport" content="width=device-width">
<script>
var eventName = "visibilitychange";
if (document.webkitHidden!=undefined) {
eventName = "webkitvisibilitychange";
document.write("<h2>webkit prefix detected</h2>");
} else if (document.mozHidden!=undefined) {
@montmanu
montmanu / wake.html
Last active December 17, 2015 19:59
Detect Wake from Sleep
<!DOCTYPE html>
<title>Page Visibility</title>
<meta name="viewport" content="width=device-width">
<script>
// The time, in ms, that must be "missed" before we
// assume the app has been put to sleep.
var THRESHOLD = 10000;
var lastTick_;
@montmanu
montmanu / zombie.html
Created May 28, 2013 17:06
Zombie Window iOS
<!DOCTYPE html>
<title>Original title</title>
<meta http-equiv="refresh" content="1" id="metarefresh">
<script>
// iPad background tab notification trick
var mr = document.getElementById("metarefresh");
setInterval(function() {
mr.content=mr.content; // Shift the reload operation
}, parseInt(mr.content)/2);
@montmanu
montmanu / thumbs.js
Created May 30, 2014 19:27
Generate a thumbnail image from a video at a given frame
/**
* Generates an image from a video at a given frame
* @param {object} $video - The $(video) from which to extract a frame.
* @param {object} $canvas - The $(canvas) target used for generating the image.
* @param {number} frame - The time at which the frame should be captured.
* @param {function} cb - A node-style callback function.
*/
var getThumbnailAtFrame = function ($video, $canvas, frame, cb){
var video, canvas;
@montmanu
montmanu / colorbox-reset.scss
Created June 2, 2014 20:29
Reset default bootstrap box-sizing rules; for ESPN auth #colorbox and related content only.
#colorbox,
#colorbox *,
#colorbox *:before,
#colorbox *:after,
[id^="cbox"],
[id^="cbox"] *,
[id^="cbox"] *:before,
[id^="cbox"] *:after, {
@include box-sizing(content-box);
}
function loadScript(url, callback){
var script = document.createElement("script");
script.type = "text/javascript";
if (script.readyState){
// IE
script.onreadystatechange = function(){
if (script.readyState == "loaded" || script.readyState == "complete"){
script.onreadystatechange = null;
callback();
@montmanu
montmanu / concat.sh
Created August 15, 2014 23:00
bootstrap-sass-official.js
# assuming PWD == ${PROJECT_PATH}/app/bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap
PROJECT_PATH=~/Projects/espn/promo/disney/cheer
OUTPUT_PATH="${PROJECT_PATH}/app/scripts/vendor/bootstrap.js"
uglifyjs affix.js alert.js button.js carousel.js collapse.js dropdown.js tab.js transition.js scrollspy.js modal.js tooltip.js popover.js -o $OUTPUT_PATH
@montmanu
montmanu / onsiteVotesByAthlete.js
Created September 9, 2014 23:37
Map votes by medium to athlete
var onsiteVotesByAthlete = {};
votes.forEach(function (vote){
if ( vote.athlete._id in onsiteVotesByAthlete ){
onsiteVotesByAthlete[vote.athlete._id] += 1;
} else {
onsiteVotesByAthlete[vote.athlete._id] = 1;
}
});
@montmanu
montmanu / mp42webm.sh
Created February 6, 2015 21:37
mp4 to webm
ffmpeg -i input.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output.webm
@montmanu
montmanu / mp42ogv.sh
Created February 6, 2015 21:40
mp4 to ogv
# -q 5 sets the desired quality.
ffmpeg -i input.mp4 -q 5 -pix_fmt yuv420p -acodec libvorbis -vcodec libtheora output.ogv