Skip to content

Instantly share code, notes, and snippets.

View rahularity's full-sized avatar
🎈
I may be slow to respond.

Rahul Pandey rahularity

🎈
I may be slow to respond.
View GitHub Profile
@rahularity
rahularity / latency.txt
Created October 20, 2022 16:17 — 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
@rahularity
rahularity / AggresiveCows.cpp
Created August 3, 2020 12:31
Algorithms and Data Structure Revision
/*
Read the problem statement from here: https://www.spoj.com/problems/AGGRCOW/
*/
#include<bits/stdc++.h>
using namespace std;
bool isPossible(int arr[], int n, int interval, int C){
C--;
int start = arr[0];
@rahularity
rahularity / dfs.md
Created July 24, 2020 18:19
Midnight Code: Day 3

Depth First Search

Used to traverse a tree or a graph in depth first manner

// globally we have a Graph G of lets say 100 nodes
vector<int>* G = new vector<int>[100];
// globally we also have a vector to store weather or not a node has been visited
vector<bool> visited(100, false);
@rahularity
rahularity / EditDistance.cpp
Last active July 24, 2020 09:59
Midnight Code: learn before you sleep. (Day 2)
/*
Given two words Word1 and Word2 find minimum number of operations required to convert Word1 to Word2.
You have the following 3 operations permitted on a word:
Insert a character
Delete a character
Replace a character
*/
// minimum of three numbers
int min(int x, int y, int z)
@rahularity
rahularity / GCD.md
Last active July 24, 2020 18:26
Midnight Code: learn before you sleep. (DAY 1)
/*
	===================== GCD (GREATEST COMMON DIVISOR) =====================
	
	FINDING THE GREATEST COMMON DIVISOR EFFICIENTLY USING EUCLID'S FORMULA.
				GCD(a,b) = GCD(b, a%b)
	
*/

int GCD (int a, int b){
@rahularity
rahularity / Angular-Essentials.md
Last active May 13, 2024 11:01
This gist will let you get started with angular and it teaches all the key components of Angular. We are covering modules, components, data binding, directives, routing etc.

Angular

Angular uses TypeScript

Typescript is basically the superset of Javascript which gives (Classes, Interfaces, Types etc.). It is strongly typed language. It cannot be run in the browser, it gets compiled to javascript.

Module Introduction:

Angular serves the index.html page as the single page for the project

@rahularity
rahularity / kotlin-null-safety.md
Last active May 23, 2024 09:04
Kotlin Null Safety
@rahularity
rahularity / work-with-multiple-github-accounts.md
Last active December 29, 2024 14:59
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent