Skip to content

Instantly share code, notes, and snippets.

@neerajkanhere
neerajkanhere / twisted.md
Created November 18, 2021 15:49 — forked from michaellihs/twisted.md
Write your own ssh Server with the Python Twisted library

SSH Server with the Python Twisted Library

Installing the library

Assuming you have Python installed on your system:

pip install twisted
pip install pyOpenSSL
pip install service_identity
@neerajkanhere
neerajkanhere / locked_open.py
Created July 13, 2021 20:17 — forked from lonetwin/locked_open.py
Simple python file locking context manager example on linux using python stdlib's `fcntl.flock`
import logging
import fcntl
from contextlib import contextmanager
@contextmanager
def locked_open(filename, mode='r'):
"""locked_open(filename, mode='r') -> <open file object>
Context manager that on entry opens the path `filename`, using `mode`
(default: `r`), and applies an advisory write lock on the file which
@neerajkanhere
neerajkanhere / kerberos.py
Created April 22, 2021 20:38 — forked from om2c0de/kerberos.py
Kerberos + JWT + Basic + Negotiate authentications using tornado web framework.
import base64
import json
import logging
import os
import sys
from abc import ABC
import jwt
import tornado.escape
import tornado.httpserver
@neerajkanhere
neerajkanhere / gist:30559100be4c564bb34bfe45ba92e86f
Created September 26, 2018 22:17 — forked from obiltschnig/gist:dc2e90643e6fabe7d938
Poco::Net::HTTPRequestHandler subclass for sending file ranges, as needed for HTTP-based streaming.
class MediaRequestHandler: public Poco::Net::HTTPRequestHandler
{
public:
enum
{
BUFFER_SIZE = 8192
};
MediaRequestHandler(const std::string& mediaPath):
_mediaPath(mediaPath)