Skip to content

Instantly share code, notes, and snippets.

View RahulJyala7's full-sized avatar
🎯
Focusing

Rahul Jyala RahulJyala7

🎯
Focusing
View GitHub Profile
@RahulJyala7
RahulJyala7 / System Design.md
Created September 3, 2022 13:26 — 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?
@RahulJyala7
RahulJyala7 / latency.txt
Created December 10, 2021 09:53 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@RahulJyala7
RahulJyala7 / semaphore.js
Last active June 6, 2022 14:36 — forked from gregkorossy/semaphore.js
A simple implementation of a semaphore in JS
Mutex: exclusive-member access to a resource
Semaphore: n-member access to a resource
That is, a mutex can be used to syncronize access to a counter, file, database, etc.
A sempahore can do the same thing but supports a fixed number of simultaneous callers. For example, I can wrap my database calls in a semaphore(3) so that my multithreaded app will hit the database with at most 3 simultaneous connections. All attempts will block until one of the three slots opens up. They make things like doing naive throttling really, really easy.
function Semaphore(max) {
@RahulJyala7
RahulJyala7 / mongo-notes.js
Created March 12, 2021 07:57 — forked from thoragio/mongo-notes.js
Mongo Notes
// MONGO COMMAND LINE
// start mongod
ulimit -n 2048 && mongod
// ctrl-c ends in same window, but can also use
killall mongod
// start mongod with data directory in another location
mongod -dbpath /path/to/data/dir
// open command line interface (mongo shell)
mongo
// restore a DB dump from a binary (BSON) dump file
version: "3"
services:
mongo1:
hostname: mongo1
container_name: localmongo1
image: mongo:4.0-xenial
expose:
- 27017
ports:
- 27011:27017
@RahulJyala7
RahulJyala7 / a-mongodb-replica-set-docker-compose-readme.md
Created December 30, 2020 15:48 — forked from harveyconnor/a-mongodb-replica-set-docker-compose-readme.md
MongoDB Replica Set / docker-compose / mongoose transaction with persistent volume

This will guide you through setting up a replica set in a docker environment using.

  • Docker Compose
  • MongoDB Replica Sets
  • Mongoose
  • Mongoose Transactions

Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!

@RahulJyala7
RahulJyala7 / event-loop.md
Created November 7, 2020 15:31 — forked from EryouHao/event-loop.md
Depth in Event Loop, both browser and Node.js.

Depth in Event Loop

For those JavaScript programmers, event loop is an important concept, inevitably.

Literally, event loop is what JavaScritp uses to implement non-blocking execution. Understanding how the event loops works internally would benefit you a lot when programming in JavaScript.

There are two major environments JavaScript runs in: browser and Node.js.

Browser

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@RahulJyala7
RahulJyala7 / enzyme_render_diffs.md
Created November 25, 2019 07:04 — forked from fokusferit/enzyme_render_diffs.md
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@RahulJyala7
RahulJyala7 / bitwise-operators.md
Last active July 23, 2024 05:40 — forked from dideler/bitwise-operators.md
Bitwise tricks

Inspired by this article. Neat tricks for speeding up integer computations.

Note: cin.sync_with_stdio(false); disables synchronous IO and gives you a performance boost. If used, you should only use cin for reading input (don't use both cin and scanf when sync is disabled, for example) or you will get unexpected results.

Multiply by a power of 2

x = x << 1; // x = x * 2