This file contains hidden or 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
#!/bin/bash | |
# Get the scope of given class in a given file | |
# Then show the evelution of the class via git log -L | |
# usage: show_scope [classname] [filename] | |
# cname='class HttpAuthHandler' | |
# fname='HttpAuthHandler.java' | |
cname=$1 | |
fname=$2 | |
begin=$(grep -n ".*$cname.*" $fname | grep -Eo "^[0-9]{1,5}") |
This file contains hidden or 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
import numpy as np | |
import scipy as sc | |
import networkx as nx | |
from matplotlib.colors import LogNorm | |
from pylab import * | |
def sample(n): | |
m = sc.misc.comb(n, 2) | |
r_vals = np.random.random(m) |
This file contains hidden or 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
CREATE KEYSPACE unittest WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; | |
USE unittest; | |
CREATE TABLE commits ( | |
id text, | |
path text, | |
author_email text, | |
author_name text, | |
subject text, |
This file contains hidden or 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 pylab import * | |
import pandas as pd | |
df =pd.read_csv("PS04_1a.dat", names=range(1,35)) | |
p1 = pd.DataFrame({'max': df.max(), 'mean':df.mean()}) | |
p1.plot(marker='.', markersize=10, title='') |
This file contains hidden or 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
2 1 | |
3 1 | |
3 2 | |
4 1 | |
4 2 | |
4 3 | |
5 1 | |
6 1 | |
7 1 | |
7 5 |
This file contains hidden or 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
authors=(`git log --format='%ae' | sort -u`) | |
for author in ${author[*]} | |
do | |
files=(`git log --no-merges --stat --author="$author" --name-only --pretty=format:"" | sort -u`) | |
for file in ${files[*]} | |
do | |
echo $author $file | |
done | |
done |
This file contains hidden or 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
words1 = "pa’Daq ghah taH tera’ngan ’e".replace("’","'").split() | |
tags1 = "N PRO V N PRO".split() | |
words2 = "ja’chuqmeH rojHom neH tera’ngan".replace("’","'").split() | |
tags2 = "V N V N".split() | |
words3 = "tera’ngan qIp puq ’eg puq qIp tera’ngan".replace("’","'").split() | |
tags3 = "N V N CONJ N V N".split() | |
train = [] |
This file contains hidden or 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 defaultdict | |
from nltk.corpus import brown | |
print ">>> Procssing" | |
word_tag = defaultdict(set) | |
for word, tag in brown.tagged_words(): | |
word_tag[word].add(tag) | |
num_words_by_num_tags = defaultdict(int) | |
words_with_max_tags = [None, 0] |
This file contains hidden or 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
import csv | |
with open('ps03-4.csv','rb') as file: | |
contents = csv.reader(file) | |
matrix = list() | |
for row in contents: | |
matrix.append(row) |
This file contains hidden or 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
# origin: http://stackoverflow.com/questions/24662006/python-networkx-graph-different-colored-nodes-using-two-lists | |
## assign a node attribute, which I am going to color according to | |
for node in G.nodes(): | |
G.node[node]['category'] = my_category_dict[node] | |
## put together a color map, one color for a category | |
color_map = {'type_A':'b', 'type_B':'#FF0099', 'type_C':'#660066'} | |
## construct a list of colors then pass to node_color | |
nx.draw(G, node_color=[color_map[G.node[node]['category']] for node in G]) | |
plt.show() |