This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Link to article: https://vmois.dev/python-flask-background-thread/ | |
import os | |
import logging | |
import signal | |
from flask import Flask, request, jsonify | |
from background_thread import BackgroundThreadFactory, TASKS_QUEUE | |
logging.basicConfig(level=logging.INFO, force=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pubsub using channels. Subscribe, Unsubscribe, Publish and Close methods are present. | |
// Code is taken from this article https://eli.thegreenplace.net/2020/pubsub-using-channels-in-go/ and Unsubscribe method added by VMois | |
import "sync" | |
type Pubsub struct { | |
mu sync.RWMutex | |
subs map[string][]chan string | |
closed bool | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM rabbitmq:3.9-management | |
RUN apt-get -o Acquire::Check-Date=false update && apt-get install -y curl | |
RUN curl -L https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/3.9.0/rabbitmq_delayed_message_exchange-3.9.0.ez > $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez | |
RUN chown rabbitmq:rabbitmq $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez | |
RUN rabbitmq-plugins enable rabbitmq_delayed_message_exchange | |
RUN rabbitmq-plugins enable rabbitmq_management |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dis | |
source_py = 'my_best_code.py' | |
stack = [] | |
namespace = { | |
'print': print, | |
} | |
with open(source_py) as f_source: | |
source_code = f_source.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_things(a: int, b: int) -> int: | |
return a + b | |
print(do_things(2, 3)) | |
print(do_things("hello", " world!")) | |
# print(do_things(2, " world!")) # this will throw an exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from utils.vector import UnsafeFixedVector | |
from tensor import Tensor | |
from algorithm import vectorize, parallelize | |
from math import sqrt | |
from time import now | |
from python import Python | |
def main(): | |
Python.add_to_path(".") | |
let ed = Python.import_module("euclidian_distance") |