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
const gulp = require('gulp'), | |
uglify = require('gulp-uglify'), | |
pump = require('pump'), | |
sass = require('gulp-sass'), | |
nodemon = require('gulp-nodemon'), | |
livereload = require('gulp-livereload'); | |
gulp.task('serve', function(){ | |
nodemon({ | |
script: 'server.js', |
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
const express = require('express'); | |
const passport = require('passport'); | |
const Strategy = require('passport-facebook').Strategy; | |
const CLIENT_ID = process.env.CLIENT_ID || require('./config/facebook.json').ClientId; | |
const CLIENT_SECRET = process.env.CLIENT_SECRET || require('./config/facebook.json').ClientSecret; | |
const PORT = process.env.PORT || 3000; | |
const app = express(); |
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
for (var i = 0;i < 10;i++) { | |
(function(i) { | |
setTimeout(function(){ | |
console.log(i); | |
}, 1000 * i); | |
})(i); | |
} |
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
if (!!window.EventSource) { | |
const source = new EventSource('/api/bubble-sort'); | |
source.onmessage = (e) => { | |
const data = JSON.parse(e.data); | |
// data parsed | |
}; | |
source.onopen = () => { | |
console.log('connected!'); | |
}; |
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
const cleanRoom = () => { | |
return new Promise((resolve, reject) => { | |
resolve('Clean room,'); | |
}); | |
} | |
const takeTrash = (message) => { | |
return new Promise((resolve, reject) => { | |
resolve(message + ' Take out trash,'); | |
}) |
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
# Created by https://www.gitignore.io | |
.Python | |
bin/ | |
include/ | |
lib/ | |
pip-selfcheck.json | |
*.py[cod] | |
*.DS_Store |
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
const arr = ['mom', 'dad', 'abcde', 'racecar', 'momom']; | |
function namePalindrome(arr) { | |
return arr.filter((curr, idx, arr) => { | |
const splitArr = curr.split(''); | |
const reversedString = splitArr.reduceRight((prev, curr) => ( prev + curr ), ''); | |
if (curr === reversedString) return curr; | |
}) | |
} |
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
const cluster = require('cluster'); | |
const http = require('http'); | |
const numCPUs = require('os').cpus().length; | |
if (cluster.isMaster) { | |
console.log(`Master ${process.pid} is running`); | |
// Fork workers. | |
for (let i = 0; i < numCPUs; i++) { |
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
const got = require('got'); | |
const querystring = require('querystring'); | |
const Promise = require('bluebird'); | |
let url = [ | |
"https://newsapi.org/v1/articles?source=cnn&sortBy=top&apiKey=9f3b3102ab704b7c9a874ee92cdb288f", | |
"https://newsapi.org/v1/articles?source=abc-news-au&sortBy=top&apiKey=9f3b3102ab704b7c9a874ee92cdb288f", | |
"https://newsapi.org/v1/articles?source=associated-press&sortBy=top&apiKey=9f3b3102ab704b7c9a874ee92cdb288f", | |
"https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=9f3b3102ab704b7c9a874ee92cdb288f", | |
"https://newsapi.org/v1/articles?source=bloomberg&sortBy=top&apiKey=9f3b3102ab704b7c9a874ee92cdb288f", | |
"https://newsapi.org/v1/articles?source=business-insider&sortBy=top&apiKey=9f3b3102ab704b7c9a874ee92cdb288f", |
OlderNewer