Skip to content

Instantly share code, notes, and snippets.

View PaulisMatrix's full-sized avatar
🏠
Working from home

rushikesh PaulisMatrix

🏠
Working from home
View GitHub Profile
@PaulisMatrix
PaulisMatrix / last_n_lines.py
Last active March 4, 2024 17:16 — forked from AlexWaygood/last_n_lines.py
Script to find the last `n` lines of a file
import os
from collections import deque
from collections.abc import Iterator, Sequence
from typing import Final, Protocol
# Protocol is much like interfaces in go where you have objects implementing the methods
# defined under a class inherting the Protocol class.
class SeekableBytesFile(Protocol):
def seek(self, position: int, whence: int = ..., /) -> int: ...
@PaulisMatrix
PaulisMatrix / primes.go
Last active March 9, 2024 04:51
prime finding algorithms
// Finding primes upto N
// From this video: https://www.youtube.com/watch?v=fwxjMKBMR7s
package snippets
import (
"container/heap"
"fmt"
"time"
)
@PaulisMatrix
PaulisMatrix / lru.py
Last active December 23, 2023 15:42
Different implementations of LRU in python
from __future__ import annotations
import time
from heapq import heapify, heappush, heappop
import math
from io import StringIO
class NotFound(Exception):
def __init__(self, *args: object, msg: str) -> None:
super().__init__(*args, msg)
@PaulisMatrix
PaulisMatrix / System Design.md
Created March 21, 2023 15:16 — 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?
@PaulisMatrix
PaulisMatrix / telepresence log
Created January 10, 2023 14:01
telepresence log [10-1-2023]
0.0 TEL | Telepresence 0.73-1694-g146d6ec launched at Tue Jan 10 19:15:06 2023
0.0 TEL | ./usr/local/bin/telepresence --mount=false --also-proxy=10.0.0.0/8 --run zsh
0.0 TEL | Using images version 0.73 (dev)
0.0 TEL | uname: uname_result(system='Darwin', node='192.168.1.2', release='21.5.0', version='Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101', machine='x86_64')
0.0 TEL | Platform: darwin
0.0 TEL | WSL: False
0.0 TEL | Python 3.9.6 (v3.9.6:db3ff76da1, Jun 28 2021, 11:49:53)
0.0 TEL | [Clang 6.0 (clang-600.0.57)]
0.0 TEL | BEGIN SPAN main.py:40(main)
0.0 TEL | BEGIN SPAN startup.py:83(set_kube_command)
@PaulisMatrix
PaulisMatrix / readme.md
Created January 8, 2023 13:39 — forked from pawl/readme.md
test to see if psycogreen is necessary to run sqlalchemy + gevent + psycopg2 concurrently

This is a test to see if psycogreen is necessary to run sqlalchemy + gevent + psycopg2 concurrently.

benchmark command (concurrency of 10)

ab -n 10 -c 10 127.0.0.1:8080/wait

psychopg2 - sync worker (expecting concurrency of 2)

gunicorn -b 127.0.0.1:8080 -w 2 test:app

@PaulisMatrix
PaulisMatrix / celery.sh
Last active April 18, 2023 07:42 — forked from amatellanes/celery.sh
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@PaulisMatrix
PaulisMatrix / main.go
Created October 13, 2022 10:37 — forked from julz/main.go
containersched minicontainer
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {