Skip to content

Instantly share code, notes, and snippets.

View Priyansh2's full-sized avatar
🎯
Focusing

Priyansh Agrawal Priyansh2

🎯
Focusing
View GitHub Profile
@walkermatt
walkermatt / debounce.py
Created June 4, 2012 21:44
A debounce function decorator in Python similar to the one in underscore.js, tested with 2.7
from threading import Timer
def debounce(wait):
""" Decorator that will postpone a functions
execution until after wait seconds
have elapsed since the last time it was invoked. """
def decorator(fn):
def debounced(*args, **kwargs):
def call_it():
@preshing
preshing / sort1mb.cpp
Created October 25, 2012 11:28
Sort one million 8-digit numbers in 1MB RAM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
import marisa_trie
from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer
# hack to store vocabulary in MARISA Trie
class _MarisaVocabularyMixin(object):
def fit_transform(self, raw_documents, y=None):
super(_MarisaVocabularyMixin, self).fit_transform(raw_documents)
self._freeze_vocabulary()
import numpy as np
import marisa_trie
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.externals import six
class MarisaCountVectorizer(CountVectorizer):
# ``CountVectorizer.fit`` method calls ``fit_transform`` so
# ``fit`` is not provided
def fit_transform(self, raw_documents, y=None):
import numpy as np
import scipy.sparse as sp
import hat_trie
from sklearn.feature_extraction.text import CountVectorizer, _make_int_array
class HatTrieCountVectorizer(CountVectorizer):
def _count_vocab(self, raw_documents, fixed_vocab):
"""Create sparse feature matrix, and vocabulary where fixed_vocab=False
@kartikkukreja
kartikkukreja / IterativeDeepeningAlphaBetaSearch.py
Created July 11, 2015 18:13
Iterative Deepening Alpha Beta Search
def iterativeDeepeningAlphaBeta(state, evaluationFunc):
startTime = time()
def alphaBetaSearch(state, alpha, beta, depth):
def maxValue(state, alpha, beta, depth):
val = -MaxUtility
for successor in state.getSuccessors():
val = max(val, alphaBetaSearch(successor, alpha, beta, depth))
if val >= beta: return val
alpha = max(alpha, val)
@mbejda
mbejda / Indian-Male-Names.csv
Created November 3, 2015 14:27
Dataset of ~14,000 Indian male names for NLP training and analysis. The names have been retrieved from public records. (name,gender,race)
name gender race
barjraj m indian
ramdin verma m indian
sharat chandran m indian
birender mandal m indian
amit m indian
kushal m indian
kasid m indian
shiv prakash m indian
vikram singh m indian
@mbejda
mbejda / Indian-Female-Names.csv
Created November 3, 2015 15:12
Dataset of ~14,000 Indian female names for NLP training and analysis. The names have been retrieved from public records. (name,gender,race)
name gender race
shivani f indian
isha f indian
smt shyani devi f indian
divya f indian
mansi f indian
mazida f indian
pooja f indian
kajal f indian
meena f indian
if __name__ == "__main__":
if len(sys.argv) < 3 or len(sys.argv) > 4:
print "usage: {0} TRAIN TEST VAL".format(sys.argv[0])
sys.exit(1)
train = np.loadtxt(sys.argv[1])
test = np.loadtxt(sys.argv[2])
val = np.loadtxt(sys.argv[3])
@Dayjo
Dayjo / install-poppler-ubuntu.md
Last active February 20, 2024 23:49
How to install Poppler on Ubuntu

First install all these prerequisites for compiling:

sudo apt install g++ autoconf libfontconfig1-dev pkg-config libjpeg-dev libopenjpeg-dev gnome-common libglib2.0-dev gtk-doc-tools libyelp-dev yelp-tools gobject-introspection libsecret-1-dev libnautilus-extension-dev

First download the encoding files (no need to compile these) to the current working directory

wget https://poppler.freedesktop.org/poppler-data-0.4.7.tar.gz