This file contains hidden or 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 eventLib = require('eventLib'); | |
var self = this; | |
eventLib.on('foo', function() { | |
self.gotFoo(); | |
}); | |
eventLib.on('bar', this.gotBar.bind(this)); | |
eventLib.on('log', console.log.bind(console)); |
This file contains hidden or 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 angular from 'angular'; | |
import MyService from './myService'; | |
import myDirective from './myDirective'; | |
angular.module('myApp', []) | |
.service('myService', MyService) | |
.directive('myDirective', myDirective); |
This file contains hidden or 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 poll(fn, timeout, interval) { | |
var endTime = Number(new Date()) + (timeout || 2000); | |
interval = interval || 100; | |
return new Promise(function(resolve, reject) { | |
(function p() { | |
// If the condition is met, we're done! | |
if (fn()) { | |
resolve(); | |
} |
This file contains hidden or 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 wrap(orig, newDef) { | |
return function(...args) { | |
return newDef.apply(this, [orig].concat(args)); | |
}; | |
} | |
myLib.getTotal = wrap(myLib.getTotal, function(orig, ...args) { | |
let total = orig.apply(this, args) * 0.8; | |
return total + this.getTax(); | |
}); |
This file contains hidden or 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 *fibonacci(n) { | |
const infinite = !n && n !== 0; | |
let current = 0; | |
let next = 1; | |
while (infinite || n--) { | |
yield current; | |
[current, next] = [next, current + next]; | |
} | |
} |
This file contains hidden or 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
#!/bin/bash | |
# git diff a file and then be presented with the option to stage | |
# the file with "y" or stage a portion with patch via "p" | |
filepath="${1-.}" | |
git diff "$filepath" | |
[[ $? -ne 0 ]] && exit |
This file contains hidden or 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
const nats = stream(n => n + 1, 1); | |
const evenNumbers = map(n => n * 2, nats); | |
console.log(take(10, evenNumbers)); | |
// [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] |
This file contains hidden or 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
// Question: Explain the difference in how x is defined in these three examples | |
// Sample A | |
function a(){ | |
x = 1; | |
} | |
// Sample B | |
function b(){ | |
var x = 1; |
This file contains hidden or 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
[ | |
{ | |
"id": 1, | |
"name": "The Hateful Eight", | |
"director": "Quentin Tarantino", | |
"released": "December 25, 2015", | |
"image": "http://resizing.flixster.com/TnduRpSjWsBCj88PlUV5Q2dZX0I=/320x474/v1.bTsxMTI4NTM1NDtqOzE3MjE0OzIwNDg7ODEwMDsxMjAwMA", | |
"description": "Set six or eight or twelve years after the Civil War, a stagecoach hurtles through the wintry Wyoming landscape. The passengers, bounty hunter John Ruth and his fugitive Daisy Domergue, race towards the town of Red Rock where Ruth, known in these parts as The Hangman, will bring Domergue to justice. Along the road, they encounter two strangers: Major Marquis Warren, a black former union soldier turned infamous bounty hunter, and Chris Mannix, a southern renegade who claims to be the town's new Sheriff. Losing their lead on the blizzard, Ruth, Domergue, Warren and Mannix seek refuge at Minnie's Haberdashery, a stagecoach stopover on a mountain pass. When they arrive at Minnie's, they are greeted not by the propr |
This file contains hidden or 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
body { | |
margin: 0; | |
padding: 0; | |
font-family: sans-serif; | |
color: #212121; | |
} | |
.App-header { | |
background: #F44336; | |
} |
OlderNewer