Skip to content

Instantly share code, notes, and snippets.

@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)
@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 / 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 / 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 / sshd.go
Created November 18, 2021 16:40 — forked from jpillora/sshd.go
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@neerajkanhere
neerajkanhere / session.py
Created December 6, 2021 13:50 — forked from viyatb/session.py
Session Handling in Tornado thanks to @milan Cermak
# -*- coding: utf-8 -*-
"""
Sessions module for the Tornado framework.
Milan Cermak <[email protected]>
This module implements sessions for Tornado. It can store
session data in files or MySQL databse, Memcached, Redis
and MongoDB.
@neerajkanhere
neerajkanhere / yolov4.py
Created February 25, 2022 16:02 — forked from YashasSamaga/yolov4.py
YOLOv4 on OpenCV DNN
import cv2
import time
CONFIDENCE_THRESHOLD = 0.2
NMS_THRESHOLD = 0.4
COLORS = [(0, 255, 255), (255, 255, 0), (0, 255, 0), (255, 0, 0)]
class_names = []
with open("classes.txt", "r") as f:
class_names = [cname.strip() for cname in f.readlines()]
@neerajkanhere
neerajkanhere / Install_OpenCV4_CUDA11_CUDNN8.md
Created May 31, 2022 21:38 — forked from raulqf/Install_OpenCV4_CUDA12.6_CUDNN8.9.md
How to install OpenCV 4.5 with CUDA 11.2 in Ubuntu 20.04

How to install OpenCV 4.5.2 with CUDA 11.2 and CUDNN 8.2 in Ubuntu 20.04

First of all install update and upgrade your system:

    $ sudo apt update
    $ sudo apt upgrade

Then, install required libraries:

@neerajkanhere
neerajkanhere / README.md
Created July 1, 2022 00:19 — forked from jasonblanchard/README.md
Watching build mode on Create React App

Create React App does not provide watching build mode oficially (#1070).

This script provides watching build mode for an external tool such as Chrome Extensions or Firebase app.

How to Use

Create a React app.

Put the script into scripts/watch.js.

@neerajkanhere
neerajkanhere / lit-element-in-browser.html
Created August 4, 2022 13:41 — forked from mcmoe/lit-element-in-browser.html
Using Lit Element without npm directly in the browser
<!-- From: https://gist.githubusercontent.com/sorvell/48f4b7be35c8748e8f6db5c66d36ee29/raw/67346e4e8bc4c81d5a7968d18f0a6a8bc00d792e/index.html -->
<!doctype html>
<html>
<head>
<!-- Polyfills only needed for Firefox and Edge. -->
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@latest/webcomponents-loader.js"></script>
</head>
<body>
<!-- Works only on browsers that support Javascript modules like
Chrome, Safari, Firefox 60, Edge 17 -->