Skip to content

Instantly share code, notes, and snippets.

View horodchukanton's full-sized avatar

Anton Horodchuk horodchukanton

  • Python microservice backends for Shipping@Glopal
  • Odessa
View GitHub Profile
@horodchukanton
horodchukanton / simple_tasks_queue.py
Last active September 24, 2022 11:13
FastAPI Background tasks queue
import logging
from concurrent.futures import ThreadPoolExecutor
from datetime import timedelta, datetime
from typing import Any, Dict
class SimpleStorageEntry:
_counter: int = 0
id: int
@horodchukanton
horodchukanton / smartctl_test.md
Created October 28, 2021 16:59 — forked from meinside/smartctl_test.md
For checking health of usb hdd on raspberry pi with smartctl.

for testing external hdd with smartctl,

install smartmontools

$ sudo apt-get install smartmontools

start test,

@horodchukanton
horodchukanton / gist:9ca868de0788a7dd8f6162d27fd6e873
Last active February 10, 2023 08:41
FastAPI generic CRUD router
import codecs
import csv
import logging
from typing import List, Type, Union, Dict
from fastapi import (
HTTPException, APIRouter, Request, Response, File,
UploadFile, )
from fastapi.responses import StreamingResponse
from pydantic import ValidationError, BaseModel
@horodchukanton
horodchukanton / serve_dir.sh
Last active May 8, 2018 19:36
Adds a function to ~/.bashrc to run nginx docker container with root in given directory
RC_FILE=~/.bashrc
PORT=8080
NAME=nginx
# Check function is already defined
grep 'servedir' $RC_FILE > /dev/null && (echo "Function definition already exists in $RC_FILE" && exit);
read -d '' func <<- FUNCTION
servedir() {
docker stop $(docker ps -f Name=${NAME} -q)
@horodchukanton
horodchukanton / ufw_cheatsheat.txt
Created September 9, 2017 11:11
UFW (uncomplicated firewall) Cheatsheat
ufw enable
ufw disable
ufw allow 8080/tcp
ufw status verbose
ufw status numbered
ufw delete 15
@horodchukanton
horodchukanton / abills-backend.service
Last active December 31, 2016 08:08
SystemD Unit for ABillS websocket backend server
[Unit]
Description=ABillS Websocket Server
After=network.target
After=mysql.service
Requires=mysql.service
[Service]
Type=forking
PIDFile=/usr/abills/var/log/websocket_backend.pid
CONF_FILE="/etc/chilli/main.conf"
INTERFACE=`cat \${CONF_FILE} | grep dhcpif | awk '{ print \$2 }'`;
MAC=`ifconfig \${INTERFACE} | grep HWaddr | awk '{ print \$5 }' | sed s/:/-/g`
@horodchukanton
horodchukanton / ZoneminderAPI_debug.txt
Created November 16, 2016 12:31
Result of change "Orientation" request
<pre class="cake-error"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr582c5144a6bb9-trace').style.display = (document.getElementById('cakeErr582c5144a6bb9-trace').style.display == 'none' ? '' : 'none');"><b>Notice</b> (8)</a>: Undefined index: Type [<b>APP/Controller/MonitorsController.php</b>, line <b>242</b>]<div id="cakeErr582c5144a6bb9-trace" class="cake-stack-trace" style="display: none;"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr582c5144a6bb9-code').style.display = (document.getElementById('cakeErr582c5144a6bb9-code').style.display == 'none' ? '' : 'none')">Code</a> <a href="javascript:void(0);" onclick="document.getElementById('cakeErr582c5144a6bb9-context').style.display = (document.getElementById('cakeErr582c5144a6bb9-context').style.display == 'none' ? '' : 'none')">Context</a><pre id="cakeErr582c5144a6bb9-code" class="cake-code-dump" style="display: none;"><code><span style="color: #000000"><span style="color: #0000BB">&nbsp;&nbsp;&nbsp;&nbsp;&
@horodchukanton
horodchukanton / events.js
Created September 17, 2016 13:19
Simple JS event PubSub implementation
/**
Events, v2.0.0
Created by Anton Horodchuk for the ABillS Framework, http://abills.net.ua/
MIT License
Simple JavaScript Event PubSub implementation
One can install listener for event with 'on'
events.on('eventhappened', function(data){ console.log(data) });
@horodchukanton
horodchukanton / Fill_last_ip.sql
Created August 4, 2016 11:49
Automatic fill of last range ip address
UPDATE dhcphosts_networks SET ip_range_last = INET_ATON(INET_NTOA(ip_range_first + (INET_ATON('255.255.255.255') - INET_ATON(INET_NTOA(mask))) - 2 ))