Skip to content

Instantly share code, notes, and snippets.

View shivendrasoni's full-sized avatar
💭
Grinding

Shivendra Soni shivendrasoni

💭
Grinding
View GitHub Profile
import json
import dateutil.parser
from datetime import date
import numpy as np
import pandas as pd
import dateutil.parser
import streamlit as st
class Message:
def __init__(self, content):
self.content = content
self.read_by = set()
class Topic:
def __init__(self, name):
self.name = name
self.messages = []
self.consumer_groups = {}
@shivendrasoni
shivendrasoni / CardGame.py
Last active August 27, 2018 10:14
An object oriented implementation of a card deck (configurable to different kinds of cards) and a card game simulation
import random
class Card(object):
def __init__(self, suit, rank):
self.suit = suit
self.rank = rank[0]
self.name = rank[1]
@shivendrasoni
shivendrasoni / flatten.js
Created July 20, 2017 14:05
An array of arbitrarily nested arrays of integers into a flat array of integers
/*
Deep Flatten a nested array.
Reduce if the child is an array, else concattenate the element to the the parent array.
*/
var deepFlatten = (r, a) => Array.isArray(a) ? a.reduce(deepFlatten, r) : r.concat(a)
@shivendrasoni
shivendrasoni / roles_invesitgation.md
Created January 6, 2016 21:35 — forked from facultymatt/roles_invesitgation.md
Roles and permissions system for Nodejs
@shivendrasoni
shivendrasoni / setup.sh
Last active October 13, 2015 16:10
Build Setup bash
# IMPORTANT SHIT : A cat will die unless you read this.
# generate your ssh public key and add it to gitlab, github and your to your body as a tattoo
# ssh-keygen // to Generate ssh key
# cat ~/.ssh/id_rsa.pub // to print it to console
# fucking copy the above key and add it to ur git repo etc.
#
# sudo apt-get install autoconf automake autoheader -y;
sudo apt-get install build-essential -y;
@shivendrasoni
shivendrasoni / Natural Sort
Created September 3, 2014 08:50
A natural sort comparator function to be used with Javascript's sort API.
function naturalSort(a, b) {
var NUMBER_GROUPS = /(-?\d*\.?\d+)/g;
var aa = String(a).split(NUMBER_GROUPS),
bb = String(b).split(NUMBER_GROUPS),
min = Math.min(aa.length, bb.length);
for (var i = 0; i < min; i++) {
var x = parseFloat(aa[i]) || aa[i].toLowerCase(),
y = parseFloat(bb[i]) || bb[i].toLowerCase();
if (x < y) return -1;