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 isNotPM2 = (process.env.PM2_HOME === undefined); | |
if (isNotPM2) { | |
const fs = require('fs'); | |
const appDir = config.getAppDir(); | |
const pidPath = `${appDir}/pid-backup/node.pid`; | |
const newPid = process.pid; | |
const writer = () => { | |
fs.writeFile(pidPath, newPid, async () => { | |
}); |
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
private void logHandler(String template, Object... parameters) { | |
String text = EMPTY; | |
try { | |
text = String.format(template, parameters); | |
} | |
catch (Exception e) { | |
log.error("logHandler ==> ", e); | |
} | |
log.info(text); | |
} |
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
function getUserName() { | |
const theme = Liferay.ThemeDisplay; | |
const payload = {userId: theme.getUserId()}; | |
userName = EMPTY_CHAR; | |
Liferay.Service(USER_ID_URL, payload) | |
.done((response) => { | |
userName = response.screenName; | |
}) | |
.fail(() => { | |
userName = EMPTY_CHAR; |
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 buildingObject = (building) => { | |
return { | |
building_number_suggest: [building.alpha, building.number], | |
building_number_suggest_show: building.alpha, | |
}; | |
}; | |
const buildingNumbers = require('./building_numbers'); | |
const bulk = buildingNumbers.map(building => buildingObject(building)); | |
const fs = require('fs'); |
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
/** building.json | |
{ | |
"results" = [ { | |
"attributes": { | |
"BUILDING": "B041", | |
..... | |
} | |
}, | |
{ | |
"attributes": { |
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
/** | |
* @function groupBucketsByDate | |
* @desc This takes an array of objects and a date key to group off of. | |
* It then will group all of the objects by that date key and will a distinct list | |
* of dates and an array of counts for each date | |
* @param {Object[]} buckets - An array of date buckets/objects | |
* @param {string} key - The key to group the items off of | |
* @param {Object} buckets[].bucket - A single date bucket in the array | |
* @param {number} bucket.doc_count - The count of items for this particular bucket | |
* @example const groups = groupBucketsByDate(buckets, 'key_as_string'); |
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
class Player { | |
constructor() { | |
this.maxHealth = 20; | |
this.roomLength = 7; | |
this.hitWall = false; | |
} | |
playTurn(warrior) { | |
warrior.think(`wall: ${this.hitWall}`); | |
this.warrior = warrior; |
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
class Player { | |
constructor() { | |
this.maxHealth = 20; | |
} | |
playTurn(warrior) { | |
this.warrior = warrior; | |
this.health = warrior.health(); | |
this.takeAction(); | |
} |
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
class Player { | |
constructor() { | |
this.maxHealth = 20; | |
} | |
playTurn(warrior) { | |
this.warrior = warrior; | |
this.health = warrior.health(); | |
this.takeAction(); | |
} |
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 fizzBuzz = (start, end) => { | |
const range = [...Array(end).keys()].slice(start, end); | |
range.forEach(indx => { | |
if (indx % 15 === 0) { | |
console.log(`fizzbuzz ${indx}`); | |
} else if (indx % 5 === 0) { | |
console.log(`buzz ${indx}`); | |
} else if (indx % 3 === 0) { | |
console.log(`fizz ${indx}`); | |
} else { |