Function of migration
to populate data in database with reference data.
- up and down functions uploads and removes data from database respectively
let o = 0, l = 10; | |
let fetchAddress = (offset = 0, limit= 10) => { | |
let addresses = [...Array(100).keys()]; | |
return Promise.resolve(addresses.slice(offset, offset + limit)) | |
} | |
let task = (data) => { | |
// Process with data here; | |
let log = console.log.bind(console, "task: ") | |
log(data); | |
// increment iteration |
var mongoose = require('mongoose'); | |
var hitSchema = mongoose.Schema({ | |
text: String, | |
music: String | |
}); | |
hitSchema.statics.bulkInsert = function(models, fn) { | |
if (!models || !models.length) | |
return fn(null); |
let tasks = [ /* ... */ ] | |
let promise = tasks.reduce((prev, task) => { | |
return prev.then(() => { | |
return task(); | |
}); | |
}, Promise.resolve()); | |
promise.then(() => { | |
//All tasks completed | |
}); |
In this demonstration I will show you how to read data in Angular2 final release before application startup. You can use it to read configuration files like you do in other languages like Java, Python, Ruby, Php.
This is how the demonstration will load data:
a) It will read an env file named 'env.json'. This file indicates what is the current working environment. Options are: 'production' and 'development';
b) It will read a config JSON file based on what is found in env file. If env is "production", the file is 'config.production.json'. If env is "development", the file is 'config.development.json'.
Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)
Alter the port the script talks to from 8000 to 80:
}).listen(80);
function redirect(location) { | |
var iframe = document.createElement('iframe'); | |
iframe.setAttribute('src', location); | |
iframe.setAttribute('width', '1px'); | |
iframe.setAttribute('height', '1px'); | |
iframe.setAttribute('position', 'absolute'); | |
iframe.setAttribute('top', '0'); | |
iframe.setAttribute('left', '0'); | |
document.documentElement.appendChild(iframe); | |
iframe.parentNode.removeChild(iframe); |
/** | |
* Determine the mobile operating system. | |
* This function returns one of 'iOS', 'Android', 'Windows Phone', or 'unknown'. | |
* | |
* @returns {String} | |
*/ | |
function getMobileOperatingSystem() { | |
var userAgent = navigator.userAgent || navigator.vendor || window.opera; | |
// Windows Phone must come first because its UA also contains "Android" |
function resetSeller(box, oldbox) { | |
var iconClassName = '.expander.class.name'; | |
if (box === null) { | |
box = oldbox.parentElement; | |
console.log(box); | |
} | |
var expander = box.querySelector(iconClassName); | |
if (expander) { | |
expander.click(); | |
setTimeout(() => { |
<script type="text/javascript"> | |
(function() { | |
var appPath = '{{{appPath}}}'; | |
var pageType = { | |
CART: '/cart/', | |
PRODUCT: '/d/', | |
CATALOG: '/c/', | |
WISHLIST: '/w/', | |
LOGIN: '/l/', | |
REGISTER: '/r/', |