Skip to content

Instantly share code, notes, and snippets.

View krrishd's full-sized avatar
🤯

Krish Dholakiya krrishd

🤯
View GitHub Profile
# Assume connections are sorted by date
# Calculate score at each month in time since the year 2005.
# This means you have (2014-2005) * 12 + 1 = 109 months of data
# Assume connection array is your sorted list of connections by date
# This creates an array where the value of the index is corresponds to the number of months
# that has passed since Jan. 2005 (arbitrary date, not much social data before then)
# Algorithm is upper-bounded by O(i+j), but average runtime will be more like O(max(i, j))
var i = 0; # Keeps track of number of months that has passed since Jan. 2005
@krrishd
krrishd / asyncLs
Created January 11, 2014 04:57 — forked from nstadigs/asyncLs
(function(exports) {
var mod = function (databaseName, saveInterval) {
var self;
saveInterval = saveInterval || 2000;
databaseName = databaseName || 'unnamed';
this.hasChanged = false;
this.store = {};
@krrishd
krrishd / sub.js
Created November 8, 2013 15:58 — forked from jiaaro/sub.js
function replace(txt) {
txt = txt.replace(/witnesses/gi, "dudes I know");
txt = txt.replace(/allegedly/gi, "kinda probably");
txt = txt.replace(/new study/gi, "tumblr post");
txt = txt.replace(/rebuild/gi, "avenge");
txt = txt.replace(/space/gi, "spaaace");
txt = txt.replace(/google glass/gi, "virtual boy");
txt = txt.replace(/smartphone/gi, "pokédex");
txt = txt.replace(/electric/gi, "atomic");
txt = txt.replace(/senator/gi, "elf-lord");