Skip to content

Instantly share code, notes, and snippets.

View voznik's full-sized avatar
🤔
Open for opportunities

Vadym Parakonnyi voznik

🤔
Open for opportunities
View GitHub Profile
@voznik
voznik / app.py
Created June 24, 2019 07:52 — forked from calderonroberto/app.py
Flask Redis Example
#!/bin/python
# Dependencies:
# pip install flask
# pip install redis
from flask import Flask
from flask import request
import flask
import redis
@voznik
voznik / clean-old-snaps.sh
Created April 10, 2019 07:04 — forked from jdatti/ubuntu18-clean-old-snaps.sh
Ubuntu clean old snaps
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@voznik
voznik / angular_code_review_checklist.md
Last active August 4, 2022 19:23 — forked from mrmeku/CODING_GUIDELINES.md
angular_code_review_checklist

Coding guidelines

This document is split into three sections

  1. On General Code Health. This section contains guidelines intended encourage patterns which produce more maintainable, less bug prone, code.
  2. On Angular Best Practices. This section outlines the practices related to Angular, Typescript, RxJs and @ngrx/store. Following these general coding guidelines will help make the application cleaner.
  3. On Angular Performance. This section contains guidelines intended to make an Angular app trigger change detection less often and on less entities.

@voznik
voznik / docker-cleanup-resources.md
Created February 21, 2019 18:40 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@voznik
voznik / getFiles.js
Created February 13, 2019 16:17 — forked from qwtel/getFiles.js
[node.js 8+] Recursively get all files in a directory
const { promisify } = require('util');
const { resolve } = require('path');
const fs = require('fs');
const readdir = promisify(fs.readdir);
const rename = promisify(fs.rename);
const stat = promisify(fs.stat);
async function getFiles(dir) {
const subdirs = await readdir(dir);
const files = await Promise.all(subdirs.map(async (subdir) => {
@voznik
voznik / iframeResizer.directive.ts
Created December 17, 2018 10:55 — forked from drakkein/iframeResizer.directive.ts
iframe resizer directive for Angular 4 (No CORS)
import { Directive, ElementRef, OnDestroy, OnInit, Renderer2 } from '@angular/core';
@Directive({
selector: '[iframeResize]',
})
export class IframeResizeDirective implements OnInit, OnDestroy {
private listener: () => void;
private observer: MutationObserver;
get element() {
@voznik
voznik / lazylibs.service.ts
Created November 6, 2018 11:40 — forked from JohannesRudolph/lazylibs.service.ts
Angular lazy library loader
import { Injectable, Inject } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { ReplaySubject } from 'rxjs/ReplaySubject';
import { DOCUMENT } from '@angular/platform-browser';
@Injectable()
export class LazylibsService {
private chartJs?: ReplaySubject<any>;
@voznik
voznik / MultiTenantFlask.py
Created July 3, 2018 23:36 — forked from TonyFrancis/MultiTenantFlask.py
Creating multi Tenant system with multiple Database. Switching between databases based on subdomain related to tenant
from functools import wraps
from flask import Flask, g, session, request, abort, jsonify
from flask_migrate import MigrateCommand, Migrate
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
flask_app = Flask(__name__, static_folder='./static')
db = SQLAlchemy()
migrate = Migrate()
@voznik
voznik / runserver.py
Last active June 30, 2018 15:47 — forked from mozz100/runserver.py
Change default port for django runserver
# Put this at <yourapp>/management/commands/runserver.py.
# Override the value of the constant coded into django...
import django.core.management.commands.runserver as runserver
runserver.DEFAULT_ADDR="0.0.0.0"
runserver.DEFAULT_PORT="8080"
# ...and then just import its standard Command class.
# Then manage.py runserver behaves normally in all other regards.
from django.core.management.commands.runserver import Command
{
"autocomplete": true,
"autoimport": true,
"enable_auto_align": false,
"format_on_save": true,
"ignore": "Parent",
"indent_with_space": 4,
"passes":
[
"ReindentSwitchBlocks",