Skip to content

Instantly share code, notes, and snippets.

View maksadbek's full-sized avatar


View GitHub Profile
sets = [[i] for i in range(len(nums))]
parent = [i for i in range(len(nums))]
def union(a, b):
set_a = parent[a]
set_b = parent[b]
if set_a == set_b:
maksadbek / nginx.conf
Created January 3, 2017 17:51
nginx configuration for HLS live video streaming
worker_processes 1;
error_log logs/error.log debug;
events {
worker_connections 1024;
rtmp {
server {
listen 1935;
allow play all;

Geo sharding

Shard Space

Like redis cluster, we'll use a shard space of 2^14 = 16384. Essentially what this means is that we'll take our entire geo area, and split it into 16384 segments of approximately equal entries.

Each instance will be responsible for any number of segments, typically a cluster of segments that are geographically close.


maksadbek / golang-linked-list.go
Created April 27, 2016 21:43
golang linked list implementation
package main
import "fmt"
type Node struct {
prev *Node
next *Node
key interface{}
maksadbek /
Created January 19, 2022 17:22 — forked from gerrymanoim/
Code from Modern "Python Dictionaries A confluence of a dozen great ideas - Raymond Hettinger"
import array
import collections
import itertools
# Placeholder constants
FREE = -1
DUMMY = -2
class Dict(collections.MutableMapping):
'Space efficient dictionary with fast iteration and cheap resizes.'
maksadbek / lisp.cpp
Created August 30, 2021 19:36 — forked from ofan/lisp.cpp
Lisp interpreter in 90 lines of C++
Lisp interpreter in 90 lines of C++
I've enjoyed reading Peter Norvig's recent articles on Lisp. He implements a Scheme interpreter in 90 lines of Python in the first, and develops it further in the second.
Just for fun I wondered if I could write one in C++. My goals would be
1. A Lisp interpreter that would complete Peter's test cases correctly...
2. no more than 90 lines of C++.
Although I've been thinking about this for a few weeks, as I write this I have not written a line of the code. I'm pretty sure I will achieve 1, and 2 will be... a piece of cake!
maksadbek / primes.go
Created March 13, 2021 23:46
Calculate primes using Doug McIlroy's idea:
package main
import "sync"
func primes() {
var recur func(ch chan int)
wg := sync.WaitGroup{}
recur = func(ch chan int) {
p := <-ch
package main
import (
func web() string {
maksadbek /
Created December 12, 2020 03:25 — forked from dmmeteo/
SOLID Principles explained in Python with examples.
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
class Animal:
def __init__(self, name: str):
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>