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 / no-template.html
Last active February 17, 2016 20:21
amp-user-notification + amp-access
<div class="growl-container" amp-access="v = 2" amp-access-hide>
<amp-user-notification layout="nodisplay" id="amp-user-notification-growl-at-2" data-show-if-href="https://cdn1.nyt.com/amp/show-growl?_=TIMESTAMP" data-dismiss-href="https://cdn1.nyt.com/amp/dismiss-growl?_=TIMESTAMP">
<section class="growl-main">
<header class="growl-header">
<a class="growl-dismiss" on="tap:amp-user-notification-growl-at-2.dismiss">
<i class="growl-dismiss-icon"><span>close</span></i>
</a>
<h4 class="growl-headline">
You have <strong>8</strong> free articles left this month
</h4>
@montmanu
montmanu / force_hbnobid.js
Last active November 30, 2015 17:53
log selected DFP data on `slotRenderEnded`
// logged from /2015/12/01/business/international/china-renminbi-reserve-currency.html?force_hbnobid=1
var loggedDfpData = {
"creativeId": 82156847918,
"lineItemId": 47347838,
"elementId": "dfp-ad-top",
"targetingMap": {
"pos": ["top"]
}
};
@montmanu
montmanu / existential.coffee
Created November 14, 2015 02:42
Why so many ?'s
region = 'bar'
foo = (data) ->
msg = 'I *really* hope all this junk exists.. '
if data.regions?[region]?.modules?[0]?.modules?
msg = 'phew.. that was close!'
else
msg = 'we have an existential crisis!'
console.log msg
@montmanu
montmanu / pre-commit
Last active November 14, 2015 02:20
Naive pre-commit hook to prevent committing new CoffeeScript files into a repo
#!/bin/sh
#
# Naive pre-commit hook to prevent committing new CoffeeScript files into a repo.
git diff --cached --name-status --diff-filter=A | while read st file; do
if [[ "$file" =~ ".coffee" ]] ; then
echo "No new CoffeeScript! Please rewrite $file as ES6+."
exit 1
fi
done
@montmanu
montmanu / js2json-keys
Created October 29, 2015 14:44
(Naive) regex for replacing unquoted object keys with quoted object keys
(?<!\")(\w)(?<!\")(\:)
@montmanu
montmanu / asf2mp4.sh
Created March 12, 2015 20:02
asf to mp4
ffmpeg -i path/to/input.asf -strict -2 path/to/output.mp4
@montmanu
montmanu / .bash_profile
Created February 10, 2015 18:07
Git BASH Utilities
# your stuff
# ...
# ...
# source these git related commands
source ~/.git_completion.sh
source ~/.git_prompt.sh
source ~/.git_prompt_colors.sh
# more of your stuff
@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
@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 / 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;
}
});