This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Extremely simple script to cleanup the conversation data that WhatsApp generates | |
#You can email yourself the conversation from your WhatsApp mobile application, run this script and use any popular word cloud generator like http://www.wordle.net/create. | |
#TO DO: Include code to create wordcloud as well. Possibly https://github.com/atizo/PyTagCloud or https://github.com/amueller/word_cloud | |
#Usage: python WhatsAppCleaner.py Foo.txt | |
from sys import argv | |
script, filename = argv | |
f = open(filename,'r') | |
for line in f: | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple script to count number of words and lines in a document using only map and reduce functions (No Loops) | |
# Usage: cat foobar.txt | python LineWordCounter.py | |
import sys | |
DataToRead = sys.stdin.read() | |
print "Document has " + str(sum(map(lambda x: x=='\n',DataToRead))) + " lines" | |
print "Document has " + str(len(map(len, DataToRead.split()))) + " words" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try | |
A=[-1 -2; -4 -3; 1 0 ; 0 1]; | |
b = [ -40; -120; 0; 0]; | |
plotregion(A,b); | |
hold on; | |
x=1:30; | |
y = (100 - 4*x)/5; | |
plot(x,y,'k--','LineWidth',2) | |
y = (136 - 4*x)/5; | |
plot(x,y,'k','LineWidth',2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import OrderedDict | |
import numpy as np | |
import theano | |
import theano.tensor as T | |
from theano.ifelse import ifelse | |
def cg(loss, params, x0=None, max_iters=100, precondition=None, tol=1e-3, | |
conv_crit='cg'): | |
"""(Preconditioned) Conjugate Gradient (CG) updates |