Skip to content

Instantly share code, notes, and snippets.

View teux's full-sized avatar

Andrei Koperskii teux

View GitHub Profile
@teux
teux / machine.js
Last active March 31, 2021 09:55
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
function pow(x, n) {
let result = x;
for (let i = 1; i < n; i++) {
result *= x;
}
return result;
}
function fractionMutable(parts, accuracy = 3) {
if (parts.length > 5e6) {
@teux
teux / fraction1.js
Last active December 27, 2019 14:10
function fractionMutable(parts) {
let acc1 = 0;
let acc2 = 0;
let acc3 = 0;
let correction = 0;
let part;
// Сумма долей в acc1
for (let i = 0; i < parts.length; i += 1) {
part = parseFloat(parts[i], 10);
@teux
teux / cache.js
Last active December 26, 2019 18:04
const cache = new Map();
const getBondsData = async ({ date, isins }) => {
const cacheKey = isin => `${date}_${isin}`;
const requestIsins = isins.filter(
isin => !cache.has(cacheKey((isin))
);
const request = http.post({
@teux
teux / logger.js
Last active December 21, 2017 08:43
const getLogger = () => {
debugger
document.body.innerHTML = `<div id='console'></div>`
const console = document.getElementById('console');
return (message) => {
const d = document.createElement('<pre>');
d.innerHTML = JSON.stringify(message, null, 2);
console.appendChild(d);
}
$(node).animateCustom('move', {duration, stageDelay})
.active(t => {
this.css({
top: Math.round(fromTop + (toTop - fromTop) * t) + 'px',
left: Math.round(fromLeft + (toLeft - fromLeft) * t) + 'px',
});
return true;
}).done(() => {
this.css({
top: toTop + 'px',
/**
* Модуль анимации
*/
(function (window, $, irr) {
var layout = irr.Tools.Layout;
var extend = irr.Tools.extend;
var MIN_DELAY = 30; // минимальная задержка между стадиями анимации, мс
// [Функции затухания](https://github.com/danro/jquery-easing/blob/master/jquery.easing.js):
var path = require('path');
var cluster = require('cluster');
var bootable = require('bootable');
var bootableEnv = require('bootable-environment');
var spdy = require('spdy');
var keys = require('spdy-keys');
var koa = require('koa');
var app;
if (cluster.isMaster) {
/**
* Auto propagate fixup in descendant branches.
* Created by a.koperskiy on 18.06.15.
*/
require('colors');
var co = require('co');
var nodegit = require("nodegit");
var Repository = nodegit.Repository;