Skip to content

Instantly share code, notes, and snippets.

public class AutoSuggestion {
private static final int TEN_THOUSAND_REQUESTS = 10000;
private static final int START = 0;
private static final String SEPARATOR = "--------------------------------------------------------------------" +
"---------------------------------------------------------------";
public static void main(String[] args) {
/*
@sahilalipuria
sahilalipuria / System Design.md
Created January 31, 2023 12:27 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
import java.util.SortedMap;
import java.util.TreeMap;
public class ConsistentHashing {
// Consistent Hashing with Ring having 50 buckets.
final static int LIMIT = 50;
// Sorted Map.
final static SortedMap<Integer, String> bucketIdToServer = new TreeMap<>();
@sahilalipuria
sahilalipuria / PythonSimpleWebsocket
Created May 18, 2016 05:07 — forked from rich20bb/PythonSimpleWebsocket
Simple websocket server in Python. Echos back whatever is received. Works with Chome, Firefox 16, IE 10.
import time
import struct
import socket
import hashlib
import base64
import sys
from select import select
import re
import logging
from threading import Thread
@sahilalipuria
sahilalipuria / index.html
Created May 17, 2016 05:59 — forked from piatra/index.html
Record stream from getUserMedia() stream
<!DOCTYPE HTML>
<html>
<head>
<title>Video recording demo</title>
<link rel="stylesheet" type="text/css" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
@sahilalipuria
sahilalipuria / websocketserver.py
Created May 11, 2016 10:23 — forked from mumrah/websocketserver.py
Simple WebSockets in Python
import time
import struct
import socket
import hashlib
import sys
from select import select
import re
import logging
from threading import Thread
import signal
@sahilalipuria
sahilalipuria / .gitignore
Created May 5, 2016 10:11 — forked from zed/.gitignore
WebSocket Echo :python:twisted:txws:jquery:
/twistd.pid
/_trial_temp/