Skip to content

Instantly share code, notes, and snippets.

View h0rn3t's full-sized avatar
🏠
Working from home

Eugene h0rn3t

🏠
Working from home
  • Ukraine
View GitHub Profile
@h0rn3t
h0rn3t / test.service
Created December 23, 2020 12:19 — forked from circa10a/test.service
A Simple Systemd Service
#/etc/systemd/system/test.service
[Unit]
Description=Test Systemd Service
[Service]
ExecStartPre=/usr/bin/echo -e "\033[0;33m Pre start \033[0m"
ExecStart=/usr/bin/sleep 10
ExecStartPost=/usr/bin/echo -e "\033[0;33m Post start \033[0m"
@h0rn3t
h0rn3t / redis-delallbykey
Created August 22, 2020 13:32 — forked from mattweyant/redis-delallbykey
Delete all keys from Redis matching a regular expression
# All credit: http://stackoverflow.com/questions/4006324/how-to-atomically-delete-keys-matching-a-pattern-with-redis
redis-cli [options] KEYS "prefix:*" | xargs redis-cli [options] DEL
#!/usr/bin/env python3
'''
@desc Simple MongoDB Client class. Offers the entire API
of AsyncioMotorCollection.
@author SDQ <[email protected]>
@version 1.0.0
@date 2020-02-17
@note 1.0.0 (2020-02-17) : First functional version
'''
from typing import Any, Optional
@h0rn3t
h0rn3t / LICENSE
Created July 14, 2020 12:59 — forked from mepcotterell/LICENSE
Simple Python Plugin Manager
The MIT License (MIT)
Copyright (c) 2013 Michael E. Cotterell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@h0rn3t
h0rn3t / plugin_module.py
Created July 9, 2020 06:38 — forked from BradWhittington/plugin_module.py
Plugin pattern for python classes
plugins = {}
def get_input_plugins():
return plugins['input'].items()
class Plugin(object):
plugin_class = None
@classmethod
def register(cls, name):
plugins[cls.plugin_class][name] = cls
@h0rn3t
h0rn3t / uvicorn_starlette_socketio.py
Last active July 2, 2020 07:12
uvicorn starlette socketio
import logging
import asyncio
import uvicorn
from uvicorn.loops.uvloop import uvloop_setup
from starlette.applications import Starlette
from starlette.responses import JSONResponse
import socketio
# Set some basic logging
logging.basicConfig(
@h0rn3t
h0rn3t / bobp-python.md
Created December 10, 2019 10:29 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@h0rn3t
h0rn3t / execute_insert_statement.py
Created September 6, 2019 10:38 — forked from mariuz/execute_insert_statement.py
new fdb firebird driver example :execute insert statement
# $ pip install fdb
# use this documentation for the moment http://www.firebirdsql.org/file/documentation/drivers_documentation/python/3.3.0/tutorial.html#connecting-to-a-database
import fdb as kinterbasdb
con = kinterbasdb.connect(dsn='/var/lib/firebird/2.5/data/rdbgraph.fdb', user='sysdba', password='masterkey')
cur = con.cursor()
# Execute the insert statement:
name="name"
@h0rn3t
h0rn3t / mongo_backup.sh
Created March 7, 2019 09:16 — forked from sheharyarn/mongo_backup.sh
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"