Jest Mock Any Property on Window Utility - with automatic cleanup.
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 React from 'react'; | |
import styled from 'styled-components'; | |
const Button = styled.a` | |
line-height: 2; | |
height: 5rem; | |
text-decoration: none; | |
display:inline-flex; | |
color: #FFFFFF; | |
background-color: #FF813F; |
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
/* This is intentionally blank just and exists to secure a decent gist name */ |
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
/* | |
* I saw this thread: http://stackoverflow.com/questions/840781/easiest-way-to-find-duplicate-values-in-a-javascript-array | |
* The solutions from gist:1305056 were elegant, but wrong. So here's mine: | |
*/ | |
Array.prototype.unique = function(test) { | |
/* returns a new, sorted Array without duplicates */ | |
if (!Array.isArray(this)) | |
throw new TypeError("Array.prototype.unique must be called on an Array"); | |
return this.slice(0).sort().filter( typeof test == "function" | |
? function(v, i, a) { return !i || !test(v, a[i-1]); } |
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 request = require("request"), | |
cheerio = require("cheerio"), | |
url = "https://www.google.com/search?q=data+mining", | |
corpus = {}, | |
totalResults = 0, | |
resultsDownloaded = 0; | |
function callback () { | |
resultsDownloaded++; |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.