Skip to content

Instantly share code, notes, and snippets.

View vladimirmyshkovski's full-sized avatar
🎯
Focusing

Vladimir Myshkovski vladimirmyshkovski

🎯
Focusing
View GitHub Profile
@vladimirmyshkovski
vladimirmyshkovski / nuxt-axios-cache.js
Created October 3, 2021 21:28 — forked from Tuarisa/nuxt-axios-cache.js
Nuxt axios cache plugin
import hash from 'object-hash'
import sizeof from 'object-sizeof'
import lruCache from 'lru-cache'
const cacheEnabled = true
const cacheMaxAge = 30 * 60 * 1000
const cacheMaxSize = 128 * 1000 * 1000
const getCacheKey = obj => hash(obj)
@vladimirmyshkovski
vladimirmyshkovski / index.d.ts
Created September 29, 2021 13:11 — forked from ixtgorilla/index.d.ts
web3 typescript memo
/*
This file is part of web3.js.
web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
@vladimirmyshkovski
vladimirmyshkovski / gena.js
Created September 24, 2021 12:09 — forked from livoras/gena.js
Genetic Algorithm in JavaScript
class Gena {
constructor(config) {
this.currentGeneration = 0
this.populations = []
this.fitnesses = []
this.mutateProbability = config.mutateProbability || 0.5 // 0 ~ 1
this.generationsSize = config.generationsSize || 100
this.populationSize = config.populationSize || 100
this.doneFitness = config.doneFitness || 1 // 0 ~ 1
@vladimirmyshkovski
vladimirmyshkovski / index.html
Last active August 23, 2021 08:12 — forked from chrisvfritz/index.html
Simplest possible HTML template
sINKK2vpkhC1+2sLwG02ZY38bCQv+n+1G06lBY7Dm/p4cKqTJKpM2ZImCOhhJCkTosOCLTqh0gYoY5HR25NZPz1K
@vladimirmyshkovski
vladimirmyshkovski / argprint.py
Created January 11, 2021 10:42 — forked from DarwinAwardWinner/argprint.py
Print a Python function's arguments every time it is called
# This file defines a decorator '@log_to()' that logs every call to a
# function, along with the arguments that function was called with. It
# takes a logging function, which is any function that accepts a
# string and does something with it. A good choice is the debug
# function from the logging module. A second decorator '@logdebug' is
# provided that uses 'logging.debug' as the logger.
from __future__ import print_function
from functools import wraps
from inspect import getcallargs, getargspec
@vladimirmyshkovski
vladimirmyshkovski / README.md
Created December 17, 2020 09:37 — forked from eunomie/README.md
How to send containers log to ELK using gelf log driver

Send docker logs to ELK through gelf log driver

There's so many way to send logs to an elk... logspout, filebeat, journalbeat, etc.

But docker has a gelf log driver and logstash a gelf input. So here we are.

Here is a docker-compose to test a full elk with a container sending logs via gelf.

@vladimirmyshkovski
vladimirmyshkovski / redis-cache-service.js
Created December 9, 2020 20:48 — forked from StarpTech/redis-cache-service.js
Simple Redis Cache Client for Node.js
'use strict';
const assert = require('assert');
/**
* The redis client is https://github.com/luin/ioredis
*/
/*
const redisClient = new Redis({
@vladimirmyshkovski
vladimirmyshkovski / drf_logger.py
Created November 29, 2020 00:53 — forked from Karmak23/drf_logger.py
Django Rest Framework logger mixin
class DRFLoggerMixin(object):
"""
Allows us to log any incoming request and to know what's in it.
Usage:
class MyOwnViewSet(DRFLoggerMixin,
mixins.ListModelMixin,
viewsets.GenericViewSet):
@vladimirmyshkovski
vladimirmyshkovski / log.py
Created November 29, 2020 00:52 — forked from Bernix01/log.py
drf LogEntry viewset Mixin
'''
Extracted and modified from django-model-logging
It used it's own LogEntry model but since django
has it's own LogEntry maybe someone would want to
register in the same model instead of creating a
new one.
'''
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE, ContentType, DELETION
from django.utils.translation import gettext as _
@vladimirmyshkovski
vladimirmyshkovski / idsentence.py
Created October 15, 2020 18:30 — forked from prschmid/idsentence.py
Implement a memorable ID string. The original idea for this comes from Asana where it is documented on their blog: http://blog.asana.com/2011/09/6-sad-squid-snuggle-softly/
"""Implement a memorable ID string.
The original idea for this comes from Asana where it is documented on their
blog:
http://blog.asana.com/2011/09/6-sad-squid-snuggle-softly/
There are other partial implementations of this and can be found here:
Node.js: https://github.com/linus/greg
Java: https://github.com/PerWiklander/IdentifierSentence