Skip to content

Instantly share code, notes, and snippets.

View pyldin601's full-sized avatar

Román Lakhtadyr pyldin601

View GitHub Profile
Dim TMPX As Long
Dim TMPX2 As Long
Const nrg1 As Integer = 100
Dim ampl As Currency
Dim phase As Currency
Dim currPh As Currency
Dim li As Currency
Dim spd As Currency
Dim R As Integer
Dim MeMovX, MeMovY
class BinanceExchange {
@memoize({ maxAge: 2000 })
@throttle({ weight: 120 })
@binanceFailSafe()
private static async fetchTickerMemoized() {
log('Fetching 24hr ticker');
const ticker = await BinanceMarket.performPublicRequest<any>('GET', 'v1/ticker/24hr', {});
return ticker.reduce((acc, market) => ({ ...acc, [decodeSymbol(market.symbol)]: market }), {});
}
}
@pyldin601
pyldin601 / compose.ts
Last active January 30, 2019 09:28
Examples of strongly-typed HOCs written on Typescript
export type IComponentEnhancer<I, O> = (
Component: React.ComponentType<I>,
) => React.ComponentType<O>;
export function compose<A>(): IComponentEnhancer<A, A>;
export function compose<A, B>(hoc1: IComponentEnhancer<A, B>): IComponentEnhancer<A, B>;
export function compose<A, B, C>(
hoc1: IComponentEnhancer<B, C>,
hoc2: IComponentEnhancer<A, B>,
): IComponentEnhancer<A, C>;
const strategy = {
id: '00000000-0000-0000-0000-000000000001',
type: 'CHAIN',
payload: {
actions: [
{
id: '00000000-0000-0000-0000-000000000002',
type: 'TRAILING_SELL',
payload: {
exchange: 'binance',
@pyldin601
pyldin601 / hideToastOnTimeoutEpic.ts
Created January 18, 2019 15:01
Why redux-observable is better than promises, sagas and thunks
export type IHideToastOnTimeoutEpic = IEpic<
IToastShowAction | IToastDismissAction,
IToastDismissAction
>;
const hideToastOnTimeoutEpic: IHideToastOnTimeoutEpic = (action$, state$) => {
const showAction$ = action$.ofType<IToastShowAction>(TOAST_SHOW);
const dismissAction$ = action$.ofType<IToastDismissAction>(TOAST_DISMISS);
git reset --soft HEAD~3 &&
git commit
@pyldin601
pyldin601 / database.test.ts
Created September 27, 2018 12:29
Test that embeds database and executes query on it.
import * as knex from 'knex';
import * as Docker from 'dockerode';
import { sleep } from '../util/time';
import { waitForDatabase } from '../test/waitForDatabase';
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
let dbContainer: Docker.Container;
let knexClient: knex;
@pyldin601
pyldin601 / AbstractRouterController.ts
Created September 25, 2018 08:00
inversify + koa + router
import * as Application from 'koa';
import * as KoaRouter from 'koa-router';
import { IRegistrableController } from './RegistrableController';
import { injectable } from 'inversify';
@injectable()
export abstract class AbstractRouterController implements IRegistrableController {
public abstract prefix: string;
public abstract setup(router: KoaRouter);
@pyldin601
pyldin601 / bitbucket-pipelines.yml
Created September 20, 2018 14:22
Bitbucket pipelines for docker swarm service with deploy via SSH.
image: node
pipelines:
branches:
staging:
- step:
script:
- docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- make TAG=staging docker-build docker-push
- step:
@pyldin601
pyldin601 / Makefile
Last active September 21, 2018 09:53
Generic Makefile for docker swarm service
IMAGE_NAME := superorder/superorder-datafeed
CONTAINER_NAME := superorder-datafeed
SERVICE_NAME := superorder_datafeed
TAG := latest
docker-build:
docker build -t $(IMAGE_NAME):$(TAG) .
docker-start:
docker run -it --name $(CONTAINER_NAME) --rm $(IMAGE_NAME):$(TAG)