Skip to content

Instantly share code, notes, and snippets.

View deepanshululla's full-sized avatar
👋
holla

Deepanshu Lulla deepanshululla

👋
holla
View GitHub Profile
import selectors
import socket
import types
class ServerWithSelect:
def __init__(self, host_name="localhost", port_num=6379, reuse_port=True):
self.host_name = host_name
self.port_num = port_num
self.reuse_port = reuse_port
import socket
import threading
class ThreadedServer:
def __init__(self, host_name="localhost", port_num=6379, reuse_port=True):
self.host_name = host_name
self.port_num = port_num
self.reuse_port = reuse_port
self.init_server()
import asyncio
import socket
from asyncio import AbstractEventLoop
class AsyncSocketServer:
def __init__(self, host_name="localhost", port_num=6379, reuse_port=True):
self.host_name = host_name
self.port_num = port_num
self.reuse_port = reuse_port
import asyncio
class AsyncIOServer:
def __init__(self, host_name="localhost", port_num=6379, reuse_port=True):
self.host_name = host_name
self.port_num = port_num
self.reuse_port = reuse_port
async def __start_server(self):
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. It is optional.
(setq user-full-name "Deepanshu lulla"
user-mail-address "deepanshu.lulla@gmail.com")
;;; init.el -*- lexical-binding: t; -*-
;; This file controls what Doom modules are enabled and what order they load
;; in. Remember to run 'doom sync' after modifying it!
;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's
;; documentation. There you'll find a link to Doom's Module Index where all
;; of our modules are listed, including what flags they support.
;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or
#include <iostream>
#include <string>
template <class T>
class Array2D {
public:
Array2D(int dim1, int dim2) :d_container(new Array1D(dim1)) {
for (int i=0; i< dim1; ++i) {
Array1D array1(dim2);
@deepanshululla
deepanshululla / thread_safe_queue.cpp
Last active April 27, 2022 09:42
thread_safe_queue.cpp
#include <exception>
#include <memory>
#include <mutex>
#include <queue>
struct EmptyQueueException : std::exception {
const char * what() const throw() {
return "Empty queue";
}
};
@deepanshululla
deepanshululla / MyString.h
Last active August 11, 2021 04:29
Custom string class implementation in C++
#include<iostream>
#include <cstring>
using namespace std;
template <typename T=char>
class MyString {
public:
MyString();//default constructor
// Type your code here, or load an example.
#include <string>
#include <iostream>
using namespace std;
template<typename T, size_t N>
constexpr size_t arraySize(T (&)[N]) noexcept {
return N;