Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
Too much to do, too little time.

Gaurav Menghani reddragon

🤖
Too much to do, too little time.
View GitHub Profile
@reddragon
reddragon / pet-projects.md
Created Apr 21, 2017
List of Possible Pet Projects
View pet-projects.md
  1. embeddings.js: word2vec in Javascript
@reddragon
reddragon / linear_regression.py
Created Apr 5, 2017
Linear Regression in Python
View linear_regression.py
'''
Linear Regression From First Principles
Author: Gaurav Menghani (gaurav.menghani@gmail.com)
'''
import numpy as np
import matplotlib.pyplot as plt
def linear_sum(X, W, b):
return X.dot(W) + b
View reverse-nodes.cpp
#include <iostream>
using namespace std;
struct Node {
int val;
Node *next;
};
void print(Node* n) {
@reddragon
reddragon / unordered_map.cpp
Created Dec 22, 2016
Hash Function for unordered_map
View unordered_map.cpp
struct Slope {
int n, d;
Slope(int nn, int dd) {
int g = gcd(abs(nn), abs(dd));
// cout << "gcd of " << nn << ", " << dd << " is: " << g << endl;
n = (g > 0 ? nn/g : nn);
d = (g > 0 ? dd/g : dd);
}
};
@reddragon
reddragon / util.h
Created Dec 8, 2016
A util file for misc algo problems
View util.h
#pragma once
#include <iostream>
#include <cassert>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdio>
@reddragon
reddragon / linked-list-cycle-first-node.cpp
Created Dec 8, 2016
First node in a cycle in a Linked List
View linked-list-cycle-first-node.cpp
#include <iostream>
#include <cassert>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdio>
#include <limits>
#include <bitset>
View linked-list-cyle.cpp
#include <iostream>
#include <cassert>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdio>
#include <limits>
#include <bitset>
View djikstra-slow.cpp
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
struct Edge {
int src, dst;
int w;
};
@reddragon
reddragon / libevent-demo.cpp
Last active Jun 11, 2021
A demo for libevent usage
View libevent-demo.cpp
#include <iostream>
#include <cstdio>
#include <vector>
#include <event2/event.h>
#include <glog/logging.h>
#include <cassert>
#include <string>
#include <cstring>
#include <sys/socket.h>
#include <netinet/in.h>
@reddragon
reddragon / gist:bca9be25e50a475044a7
Last active Aug 29, 2015
Interesting Companies
View gist:bca9be25e50a475044a7
Delivery/Logistics:
Instacart
Munchery
Lyft
Sidecar
Uber
Thumbtack
DoorDash
Grubhub
Seamless