Skip to content

Instantly share code, notes, and snippets.

@sangheestyle
sangheestyle / run_sssp.sh
Last active August 29, 2015 14:06
Run SSSP
#!/bin/bash
mkdir sssp
cd sssp
curl "https://dl.dropboxusercontent.com/u/7571776/facebook100_txt_only.zip" -o "facebook100_txt_only.zip"
unzip facebook100_txt_only.zip
curl https://gist.githubusercontent.com/sangheestyle/6335b209b4779dddc5ac/raw/47a803d6ccfa727efb80d5c32f5e7361d32c861a/ps16c.py > ps16c.py
mkdir out
python ps16c.py facebook100txt $1 $2
cd ..
@sangheestyle
sangheestyle / summary.py
Last active August 29, 2015 14:06
Summary sp
import sys
import json
from os import listdir
from os.path import isfile, join, basename
def get_file_paths(root):
file_paths = []
for f in listdir(root):
if isfile((join(root, f))):
@sangheestyle
sangheestyle / grand_sum.py
Last active August 29, 2015 14:06
Results
import os
import json
summary_folder = "summary"
summary = {}
for path in os.listdir(summary_folder):
path_summary = json.load(open(os.path.join(summary_folder, path), "r"))
if not len(summary):
summary = path_summary
else:
@sangheestyle
sangheestyle / scratch
Created September 8, 2014 07:01
Scratch
nothing
@sangheestyle
sangheestyle / medici.py
Last active August 29, 2015 14:06
ps2-6.py
# Reference:
# http://networkx.github.io/documentation/networkx-1.9.1/
# reference/algorithms.centrality.html
import operator
import networkx as nx
import pandas as pd
import matplotlib.pyplot as plt
import itertools
@sangheestyle
sangheestyle / howto.txt
Last active August 29, 2015 14:07
How to install Debian and some Python data science tools.
OK, here is what you should do to use python pandas on Debian Wheezy,
Step 1: Make a bootable image with usb key
a. Get a usb key
b. Download debian live ISO image (recommend xfce integrated image)
c. Make a usb key as a ISO boot image (recommend using dd)
Step 2: Install & Boot
d. Boot up your machine with Debian usb key (recommend UEFI)
e. Do configuration
@sangheestyle
sangheestyle / coloring_my_graph.py
Created October 8, 2014 06:49
snippets for Networkx
# 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()
import csv
with open('ps03-4.csv','rb') as file:
contents = csv.reader(file)
matrix = list()
for row in contents:
matrix.append(row)
@sangheestyle
sangheestyle / p1-2.py
Last active August 29, 2015 14:07
nlp hw5
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]
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 = []