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
import { MongoClient } from 'mongodb'; | |
import promisify from 'es6-promisify'; | |
let _connection; | |
const connect = () => { | |
if (!process.env.MONGO_CONNECTION_STRING) { | |
throw new Error(`Environment variable MONGO_CONNECTION_STRING must be set to use API.`); | |
} |
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
// get nearest parent element matching selector | |
var closest = (function() { | |
var el = HTMLElement.prototype; | |
var matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector; | |
return function closest(el, selector) { | |
return matches.call(el, selector) ? el : closest(el.parentElement, selector); | |
}; | |
})(); |
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
// Deep Equality comparison example | |
// | |
// This is an example of how to implement an object-comparison function in | |
// JavaScript (ES5+). A few points of interest here: | |
// | |
// * You can get an array of all an object's properties in ES5+ by calling | |
// the class method Object.keys(obj). | |
// * The function recursively calls itself in the for / in loop when it | |
// compares the contents of each property | |
// * You can hide a "private" function inside a function of this kind by |
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 $activeEpisodes = $(".episodecell"); | |
var episodesReversedElements = $activeEpisodes.toArray().reverse(); | |
var lastPodcastName; | |
episodesReversedElements.forEach(function (elem) { | |
var $activeEpisode = $(elem); | |
var podcastName = $activeEpisode.find(".titlestack div:first-child").text(); | |
var podcastImgSrc = $activeEpisode.find(".art").attr("src"); | |
if (podcastName !== lastPodcastName) { |
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
// | |
// <button> reset | |
// | |
// 1. Remove default browser appearance for buttons. | |
// 2. Remove margins. | |
// 3. Remove borders for IE. | |
// 4. Normalize font and color not inherited by `button`. | |
// 5. Address `overflow` in IE | |
// 6. Normalize cursor style |
NewerOlder