Create and initialize your a directory for your Express application.
$ mkdir node-knex-demo
$ cd node-knex-demo
$ npm init
Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex
command line tool.
To learn more about migrations, check out this article on the different types of database migrations!
A regular expression is a sequence of characters that forms a search pattern. The search pattern can be used for text search and text replace operations.
When you search for data in a text, you can use this search pattern to describe what you are searching for. A regular expression can be a single character, or a more complicated pattern. Regular expressions can be used to perform all types of text search and text replace operations.
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", |
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++) { |
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; | |
}) | |
} |
# Created by https://www.gitignore.io | |
.Python | |
bin/ | |
include/ | |
lib/ | |
pip-selfcheck.json | |
*.py[cod] | |
*.DS_Store |
const cleanRoom = () => { | |
return new Promise((resolve, reject) => { | |
resolve('Clean room,'); | |
}); | |
} | |
const takeTrash = (message) => { | |
return new Promise((resolve, reject) => { | |
resolve(message + ' Take out trash,'); | |
}) |
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!'); | |
}; |
for (var i = 0;i < 10;i++) { | |
(function(i) { | |
setTimeout(function(){ | |
console.log(i); | |
}, 1000 * i); | |
})(i); | |
} |