Skip to content

Instantly share code, notes, and snippets.

View c4x1's full-sized avatar
๐ŸŒ€
home->work->home->work;

CSpornov c4x1

๐ŸŒ€
home->work->home->work;
  • Russian
View GitHub Profile
@c4x1
c4x1 / showForegroundNotification.java
Last active August 8, 2019 18:43 — forked from kristopherjohnson/showForegroundNotification.java
Shows a foreground notification for an Android service. Tapping the notification will display the app as if it was tapped in application launcher
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!
@c4x1
c4x1 / hero.ts
Created August 4, 2019 23:53 — forked from brennanMKE/hero.ts
Example of Mongoose with TypeScript and MongoDb
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;
@c4x1
c4x1 / master.js
Created August 4, 2019 03:40 — forked from DeMoorJasper/master.js
child_process ipc & shared memory experiment
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
});
@c4x1
c4x1 / ClusterService.js
Created August 3, 2019 12:34 — forked from rodrisouto/ClusterService.js
Mรณdulos javascript
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
@c4x1
c4x1 / gist:770460d21d24dbea9306ec01b6ae4f6f
Created August 3, 2019 12:14 — forked from alekseydreval/gist:21a8c89c9f7f3519a477
Node.js cluster recursive startup
# clustering
cluster = require "cluster"
process.execPath = "coffee"
os = require("os")
numCPU = os.cpus().length
platform = os.platform()
# logger
winston = require("./lib/utils/logger.coffee")("server.coffee")
@c4x1
c4x1 / cluster.js
Created August 3, 2019 11:48 — forked from bennadel/cluster.js
Hello World: Concurrency In Node.js Using The Cluster Module
// Require the core node modules.
var chalk = require( "chalk" );
var cluster = require( "cluster" );
var os = require( "os" );
// ----------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------- //
// The cluster module in Node.js works by executing the application entry-point
// multiple and sharing the master ports with the worker ports. As such, this code
@c4x1
c4x1 / back.ts
Created August 3, 2019 10:58 — forked from syuilo/back.ts
AI
/**
* -AI-
* Botใฎใƒใƒƒใ‚ฏใ‚จใƒณใƒ‰(ๆ€่€ƒใ‚’ๆ‹…ๅฝ“)
*
* ๅฏพ่ฉฑใจๆ€่€ƒใ‚’ๅŒใ˜ใƒ—ใƒญใ‚ปใ‚นใง่กŒใ†ใจใ€ๆ€่€ƒๆ™‚้–“ใŒ้•ทๅผ•ใ„ใŸใจใใซใ‚นใƒˆใƒชใƒผใƒ ใ‹ใ‚‰
* ๅˆ‡ๆ–ญใ•ใ‚Œใฆใ—ใพใ†ใฎใงใ€ๅˆฅใ€…ใฎใƒ—ใƒญใ‚ปใ‚นใง่กŒใ†ใ‚ˆใ†ใซใ—ใพใ™
*/
import Othello, { Color } from '../core';
@c4x1
c4x1 / 000-server.js
Created July 28, 2019 14:48 — forked from netroy/000-server.js
Using cluster to scale existing Express/Connect apps
var cluster = require('cluster'),
app = require('./app');
var workers = {},
count = require('os').cpus().length;
function spawn(){
var worker = cluster.fork();
workers[worker.pid] = worker;
return worker;
@c4x1
c4x1 / app.js
Created July 28, 2019 14:47 — forked from Ajido/app.js
nodejs express4 cluster graceful restart / shutdown
...
app.use(function(req, res, next){
if (app.get('graceful_shutdown') === true) {
res.set('Connection', 'close');
}
next();
});
app.set('graceful_shutdown_start', function() {
@c4x1
c4x1 / server.js
Created July 28, 2019 14:44 — forked from tbranyen/server.js
backbone/node.js pushState enabled server
// Require libraries
var os = require("os");
var fs = require("fs");
var readline = require("readline");
var cluster = require("cluster");
var express = require("express");
var site = express();
// Var up, bro
var i, read;