Skip to content

Instantly share code, notes, and snippets.

View mayurbhangale's full-sized avatar

Mayur Bhangale mayurbhangale

View GitHub Profile
@mayurbhangale
mayurbhangale / ant_killer.py
Last active September 24, 2019 11:35
Kills ants stuck inside your laptop
from multiprocessing import Pool
from multiprocessing import cpu_count
def f(x):
while True:
x*x
if __name__ == '__main__':
processes = cpu_count()
pool = Pool(processes)
@mayurbhangale
mayurbhangale / docker-compose.yml
Created July 13, 2019 05:28
Janusgraph, Scylla and Elasticsearch
version: '4'
# As of JanusGraph 0.4.0, up to Cassandra 3.11 and Elasticsearch 6.x
# are supported.
#
# Here's the compatibility matrix:
# https://docs.janusgraph.org/latest/version-compat.html
#
# Here's the compatibility data for ScyllaDB:
# http://docs.scylladb.com/using-scylla/cassandra-compatibility/
import xml.etree.ElementTree as ET
import pandas as pd
tree = ET.parse('Restaurants_Train.xml')
root = tree.getroot()
labeled_reviews = []
for sentence in root.findall("sentence"):
entry = {}
if sentence.find("aspectTerms"):
@mayurbhangale
mayurbhangale / init_nlp.sh
Created May 8, 2019 06:01
Initialize Conda NLP Environment with absolutely necessary packages
# curl -L mini.conda.ml | bash
source ~/.bash_profile
conda create --name nlp python=3.6
source ~/.bash_profile
conda activate nlp
pip install spacy
conda install tensorflow
conda install -c pandas
conda install -c jupyter
pip install textacy
SELECT ?PermID ?hasPermId ?rank ?prefLabel ?hasReportedTitle ?hasHolder ?hasPositionType ?hasPublicationStatus ?isPositionIn ?to ?familyName ?givenName ?holdsPosition ?hasTenureInOrganization ?additionalName ?hasGender ?bday ?honorificPrefix ?from ?hasQualification ?preferredName ?honorificSuffix ?withDegree ?fromInstitutionName ?inSubject ?isTenureIn ?dateOfDeath
WHERE { OPTIONAL { ?PermID <http://permid.org/ontology/common/hasPermId> ?hasPermId }
OPTIONAL { ?PermID <http://permid.org/ontology/person/rank> ?rank }
OPTIONAL { ?PermID <http://www.w3.org/2004/02/skos/core#prefLabel> ?prefLabel }
OPTIONAL { ?PermID <http://permid.org/ontology/person/hasReportedTitle> ?hasReportedTitle }
OPTIONAL { ?PermID <http://permid.org/ontology/person/hasHolder> ?hasHolder }
OPTIONAL { ?PermID <http://permid.org/ontology/person/hasPositionType> ?hasPositionType }
OPTIONAL { ?PermID <http://permid.org/ontology/common/hasPublicationStatus> ?hasPublicationStatus }
OPTIONA
@mayurbhangale
mayurbhangale / csv2libsvm.py
Created November 20, 2018 16:05
Convert data to LibSVM format, supports string labels too! This is a python3 port of phraug csv2libsvm.
#!/usr/bin/env python
"""
Convert CSV file to libsvm format. Works only with numeric variables.
Put -1 as label index (argv[3]) if there are no labels in your file.
Expecting no headers. If present, headers can be skipped with argv[4] == 1.
"""
import sys
@mayurbhangale
mayurbhangale / drawing-canvas-by-sketch-js.markdown
Created November 15, 2018 11:18
Drawing canvas by sketch.js
@mayurbhangale
mayurbhangale / wiki_process.pl
Created September 10, 2018 09:18
Raw Wikipedia dump contains a lot of HTML / XML data. We pre-process it with the wiki_process.pl script.
#!/usr/bin/perl
# Program to filter Wikipedia XML dumps to "clean" text consisting only of lowercase
# letters (a-z, converted from A-Z), and spaces (never consecutive).
# All other characters are converted to spaces. Only text which normally appears
# in the web browser is displayed. Tables are removed. Image captions are
# preserved. Links are converted to normal text. Digits are spelled out.
# Written by Matt Mahoney, June 10, 2006. This program is released to the public domain.

Audio

Make some noise and record your voice! Deep Learning models will analyze and build a drum kit, then start generating drum patterns infinitely with your sound.

Convolutional Neural Network is used to analyze and classify audio segments based on spectrograms (demo codepen) and Recurrent Neural Network(LSTM) for generating drum sequences. Shout-out to Tero Parviainen! Rhythm generation part of this codepen is based on his amazing Neural Drum Machine

Built with magenta.js, tensorflow.js and p5.js by @naotokui_en

@mayurbhangale
mayurbhangale / birthday_corpus.py
Created April 25, 2018 10:32 — forked from wpm/birthday_corpus.py
Generate a corpus of texts mentioning birthdays that can be used to train a Prodigy named entity recognizer.
import json
import re
import time
from random import choice, random
from typing import TextIO, Callable, Sequence, Tuple, Optional
import click
NAME = DATE = str
SPAN_OFFSET = Tuple[int, int]