Skip to content

Instantly share code, notes, and snippets.

View alex-oleshkevich's full-sized avatar

Alex Oleshkevich alex-oleshkevich

View GitHub Profile
@alex-oleshkevich
alex-oleshkevich / mqtt_backend.py
Last active June 6, 2024 08:54
MQQT backend for Broadcaster
# Depends on aiomqtt
# pip install aiomqtt
# Based on work done in https://github.com/encode/broadcaster/pull/117
import asyncio
import typing
from urllib.parse import urlparse
import aiomqtt
├── libs
│   ├── module1_src
│   │   ├── namespace
│   │   └── pyproject.toml
│   ├── module2_src
│   │   ├── namespace
│   │   └── pyproject.toml
│   ├── module3_src
│   │   ├── namespace
│   │   └── pyproject.toml
@alex-oleshkevich
alex-oleshkevich / connection.py
Created August 6, 2020 22:10
[medium] websockets, two
import json
import typing as t
from urllib import parse
class State:
CONNECTING = 1
CONNECTED = 2
DISCONNECTED = 3
@alex-oleshkevich
alex-oleshkevich / middleware.py
Last active August 28, 2020 16:35
[medium] django 3 websockets. middleware
from django.urls import resolve
from .connection import WebSocket
def websockets(app):
async def asgi(scope, receive, send):
if scope["type"] == "websocket":
match = resolve(scope["raw_path"])
await match.func(WebSocket(scope, receive, send), *match.args, **match.kwargs)
return
await app(scope, receive, send)
FROM python:3.8-slim
RUN pip install httpx
WORKDIR /code
ADD ./main.py /code/main.py
CMD python /code/main.py
@alex-oleshkevich
alex-oleshkevich / forge.sh
Created April 19, 2020 23:05
Laravel Forge Setup Script
#
# REQUIRES:
# - server (the forge server instance)
# - event (the forge event instance)
# - sudo_password (random password for sudo)
# - db_password (random password for database user)
# - callback (the callback URL)
#
@alex-oleshkevich
alex-oleshkevich / ru-cities.json
Created September 9, 2018 17:36
Города России
[
{
"name": "Россия",
"regions": [
{
"name": "Москва и Московская обл.",
"cities": [
{
"name": "Москва",
"lat": 55.4537528,
@alex-oleshkevich
alex-oleshkevich / ua-cities.json
Created September 9, 2018 16:57
Города Украины
[
{
"name": "Украина",
"regions": [
{
"name": "Автономная Республика Крым",
"cities": [
{
"name": "Алупка",
"lat": "44.4197222",
@alex-oleshkevich
alex-oleshkevich / by-cities.json
Created September 9, 2018 16:47
Города Беларуси (json)
[
{
"name": "Беларусь",
"regions": [
{
"name": "Брестская обл.",
"cities": [
{
"name": "Антополь",
"lat": 52.2041343,
#!/bin/bash
DIR=`pwd`
echo "Making SSL files in $DIR"
echo ""
openssl genrsa -des3 -out server.key 2048
openssl rsa -in server.key -out server.key.insecure
mv server.key server.key.secure
mv server.key.insecure server.key
openssl req -new -key server.key -out server.csr