Skip to content

Instantly share code, notes, and snippets.

const step = 24 * 60 * 60 * 1000;
function findMissed(values) {
const dates = values.map(x => new Date(x.date).getTime());
const sum = dates.reduce((acc, x) => acc + x);
const min = Math.min(...dates);
return new Date((min * (dates.length + 1) + step * (dates.length + 1) * dates.length / 2) - sum).toISOString().split('T')[0];
}
const dates = [{date: '2018-01-02'}, {date: '2018-01-03'}];
function findMissed(values) {
let arr = values.map(x => new Date(x).getTime());
const step = 24 * 60 * 60 * 1000;
while (arr.length >= 2) {
const randomIndex = Math.floor(Math.random() * arr.length + 1);
const randomItem = arr[randomIndex];
let leftBucket = [];
let rightBucket = [];
let rightBucketMin = Infinity;
import socketIo = require('socket.io-client')
const client = socketIo.connect('http://localhost:8080')
setInterval(() => {
client.emit('custom_stream', Buffer.from('aaaa'))
}, 1000)
// polyfill
if (Symbol["asyncIterator"] === undefined) ((Symbol as any)["asyncIterator"]) = Symbol.for("asyncIterator")
const enum TokenTypes {
value,
bracket,
operation,
}
interface Token {
@maximelkin
maximelkin / users.ts
Last active March 30, 2018 21:11 — forked from TripleMap/users.ts
export class users_layers extends Model<users_layers> {
@AutoIncrement
@PrimaryKey
@Column(DataType.INTEGER)
id: number;
@ForeignKey(() => users)
@Column(DataType.CHAR(100))
user_id: string;
// ==UserScript==
// @name Fanfics auto refresh
// @version 0.1
// @match http://fanfics.me/message*
// @grant none
// ==/UserScript==
(function(window) {
'use strict';
window.setInterval(function() {
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define gen_time 1000
#define sum_time 2000
#define prin_time 3000
// Размерность матриц