Skip to content

Instantly share code, notes, and snippets.

View reddragon's full-sized 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 April 21, 2017 00:59
List of Possible Pet Projects
  1. embeddings.js: word2vec in Javascript
@reddragon
reddragon / linear_regression.py
Created April 5, 2017 08:31
Linear Regression in Python
'''
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
#include <iostream>
using namespace std;
struct Node {
int val;
Node *next;
};
void print(Node* n) {
@reddragon
reddragon / unordered_map.cpp
Created December 22, 2016 03:06
Hash Function for unordered_map
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 December 8, 2016 05:43
A util file for misc algo problems
#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 December 8, 2016 05:28
First node in a cycle in a Linked List
#include <iostream>
#include <cassert>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdio>
#include <limits>
#include <bitset>
#include <iostream>
#include <cassert>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdio>
#include <limits>
#include <bitset>
@reddragon
reddragon / djikstra-slow.cpp
Created December 30, 2014 18:13
O(|V||E|) Djikstra
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
struct Edge {
int src, dst;
int w;
};
@reddragon
reddragon / libevent-demo.cpp
Last active November 24, 2023 10:32
A demo for libevent usage
#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 August 29, 2015 14:11
Interesting Companies
Delivery/Logistics:
Instacart
Munchery
Lyft
Sidecar
Uber
Thumbtack
DoorDash
Grubhub
Seamless