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 connect = require('connect'); | |
var cookieParser = require('cookie-parser'); | |
var cookieSession = require('cookie-session') | |
app.use(connect()).use(cookieParser()); | |
app.use(cookieSession({ | |
name: 'session', | |
keys: ['key1', 'key2'], | |
// Cookie Options | |
maxAge: 24 * 60 * 60 * 1000 // 24 hours | |
})); |
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
// An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7] (elements are shifted right by one index and 6 is moved to the first place). | |
// The goal is to rotate array A K times; that is, each element of A will be shifted to the right K times. | |
// Write a function: | |
// function solution(A, K); | |
// that, given an array A consisting of N integers and an integer K, returns the array A rotated K times. |
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
app.get('/:pageNum', function (req, res) { | |
try { | |
// how many to items to load everytime | |
const perPage = 12; | |
// which page is current? | |
const page = req.params.pageNum || 1; | |
// find all | |
ClientModel.find({}) | |
// skip number of items (number of pages we passed * number of items per page) minus one of that number of | |
// items per page (to get the current one we get as param) |
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 = [ | |
{ | |
name: 'Sydney', | |
rank: 1392 | |
}, | |
{ | |
name: 'London', | |
rank: 1992 | |
}, | |
{ |
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
find app/src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \; |