Skip to content

Instantly share code, notes, and snippets.

View napsternxg's full-sized avatar
🎯
Focusing

Shubhanshu Mishra napsternxg

🎯
Focusing
View GitHub Profile
import nltk
import string
from collections import Counter
def untokenize(ngram):
tokens = list(ngram)
return "".join([" "+i if not i.startswith("'") and \
i not in string.punctuation and \
i != "n't"
else i for i in tokens]).strip()
@napsternxg
napsternxg / logit_scale.ipynb
Last active August 29, 2015 14:27 — forked from pierre-haessig/logit_scale.ipynb
Logit scale, for plotting cumulated probability distributions (matplotlib implementation). Better visualization of the tails
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@napsternxg
napsternxg / UIUC Library Proxy Bookmarklet.md
Last active March 12, 2019 00:07
UIUC Library Proxy Bookmarklet

UIUC Library Proxy Bookmarklet

What it does

This bookmarklet allows you to access content like papers, reports from scientific sites or any other website which can be opened easily when you are in UIUC network. The bookmarklet removes the hassle of finding the library proxy URL and then opening the site through that. It does that part automatically.

NOTE: You need to have an illinois.net account to use this bookmark.

Installation

  • Right click your bookmarks bar.
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013
@napsternxg
napsternxg / Decrypt.vb
Last active August 28, 2023 13:43
Decrypt the passwords saved by Totroise SVN
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' SAMPLE: Encryption and decryption using DPAPI functions.
'
' To run this sample, create a new Visual Basic.NET project using the Console
' Application template and replace the contents of the Module1.vb file with
' the code below.
'
' Go to the folder %APPDATA%\Subversion\auth\svn.simple
' Copy the Encrypted Value of the password denoted by the line below 2 lines below the line saying password
' Compile the code and put this value in a new file called InputFile.txt and in the same location where you are executing the code.
@napsternxg
napsternxg / linearReg.py
Created July 31, 2015 16:22
Implementing linear regression in keras
"""
Author: Shubhanshu Mishra
Posted this on the keras issue tracker at: https://github.com/fchollet/keras/issues/108
Implementing a linear regression using Keras.
"""
from keras.models import Sequential
from keras.layers.core import Dense, Activation
model = Sequential()
@napsternxg
napsternxg / genplot.py
Last active April 17, 2018 21:27
Make publication quality plots using matplotlib as described in http://nipunbatra.github.io/2014/08/latexify/
df = pd.DataFrame(np.random.randn(10,2))
df.columns = ['Column 1', 'Column 2']
latexify()
ax = df.plot()
ax.set_xlabel("X label")
ax.set_ylabel("Y label")
ax.set_title("Title")
plt.tight_layout()
format_axes(ax)
@napsternxg
napsternxg / anagram.py
Created June 1, 2015 08:12
Anagram Generator
import logging
logger = logging.getLogger('anagram')
logger.setLevel(logging.DEBUG)
def anagram(string_set):
if len(string_set) == 1:
logger.info("Reached Length 1")
return string_set # If the set has only one element then return that element.
logger.debug("Input: %s" % string_set)
temp = set() # Use a set to store all the possible anagrams.
@napsternxg
napsternxg / toy_dict.py
Created June 1, 2015 07:57
Toy demo for demostrating the implementation of a dictionary in python
"""
This code snippet explains the implementation of a dictionary using a hashing function.
Problem: Store the marks of student with given roll numbers in a data structure for quick access of marks based on roll number.
Concept: Use a dictionary data structure.
"""
roll_numbers = [9,8,7,2,1,3,4,5]
marks = [10,20,5,13,77,33,2,99]
HASH_CONST=11 # Constant used for hashing. For practical purposes more sophesticated and optimized hash functions are used.
@napsternxg
napsternxg / gen10power_range.py
Last active August 29, 2015 14:21
Generate 10 power range like 1,2,3,..10,20,30,...90,100,200,300...
max_n = 1200
[k for k in range(1,max_n) if k % 10**int(np.log10(k)) == 0]
"""
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
"""
#More computationally effective solution for large max_n