This file contains hidden or 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
| /* jslint node: true */ | |
| 'use strict'; | |
| var express = require('express'); | |
| var app = express(); | |
| global.url = 'http://jqapp.azurewebsites.net'; | |
| global.smtpUsername = process.env.smtpUsername || 'jobquerybeta@gmail.com'; | |
| global.smtpPassword = process.env.smtpPassword || 'l0jxZWuRXZ9j'; |
This file contains hidden or 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
| Use foreground service to protect your progress being killed. | |
| use startService to start service | |
| use startForeground(NOTIFICATION_ID, notification); to prevent from desctroying. | |
| use your lib. | |
| PROFIT! |
This file contains hidden or 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 { cpus } = require('os') | |
| const log = require('./modules/log') | |
| const isMaster = cluster.isMaster | |
| const numWorkers = cpus().length | |
| if (isMaster) { | |
| log(`Forking ${numWorkers} workers`) |
This file contains hidden or 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
| import * as mongoose from 'mongoose'; | |
| export let Schema = mongoose.Schema; | |
| export let ObjectId = mongoose.Schema.Types.ObjectId; | |
| export let Mixed = mongoose.Schema.Types.Mixed; | |
| export interface IHeroModel extends mongoose.Document { | |
| name: string; | |
| power: string; |
This file contains hidden or 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
| Файл worker.js должен содержать обработчик события message для получения входных данных. | |
| process.on('message', function(m) { | |
| var output; | |
| // здесь делаем все тяжёлые вычисления, не заботясь о том, что можем заблокировать | |
| // основной поток, ведь это процесс специально предназначен для выполнения одной большой задачи | |
| var output = doComputationWorkSync(m.input); | |
| process.send(output); | |
| }); |
This file contains hidden or 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 computecluster = require('compute-cluster'); | |
| // создаём вычислительный кластер | |
| var cc = new computecluster({ module: './worker.js' }); | |
| // запускаем параллельные вычисления | |
| cc.enqueue({ input: "foo" }, function (error, result) { | |
| console.log("foo done", result); | |
| }); | |
| cc.enqueue({ input: "bar" }, function (error, result) { |
This file contains hidden or 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 { fork } = require('child_process'); | |
| const cache = require('node-shared-cache'); | |
| let childCache = new cache.Cache('children', 524288); | |
| let child; | |
| function startWorker(ready) { | |
| child = fork(require.resolve('./worker'), { | |
| cwd: process.cwd(), | |
| silent: true | |
| }); |
This file contains hidden or 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
| require('dotenv').load(); | |
| const { driver } = require('@rocket.chat/sdk'); | |
| let BotID; | |
| start(); | |
| async function start() { | |
| const rooms = process.env.ROOMS.split(","); | |
| console.log(`Connecting to ${process.env.HOST} with ${process.env.USER}:${process.env.PASS}`) | |
| await driver.connect({host:process.env.HOST,username:process.env.USER,password:process.env.PASS,rooms,}); | |
| const bot = await driver.login({username:process.env.USER,password:process.env.PASS}); |
This file contains hidden or 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
| threadModel | |
| .find( | |
| {board: boardId, is_deleted: false}, | |
| {posts: {$slice: -5}} | |
| ) | |
| .sort({last_updated: 1, is_sticky: 1}) | |
| .skip(settings.threadsOnPage * parseInt(pagePointer, 10)) | |
| .limit(settings.threadsOnPage) | |
| .populate('board') | |
| .exec(function(err, threads){ |
This file contains hidden or 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 ClusterService = function() { | |
| var printer = new ClusterPrinterModule(); | |
| var connector = new ClusterConnectorModule(); | |
| var filter = new ClusterFilterModule(); | |
| var clusterList; | |
| var config; // fullClusterContainer filterDirectBtn filterStopsBtn filterAllBtn | |
| // clusterListContainer warningMessageBox |
NewerOlder