Skip to content

Instantly share code, notes, and snippets.

View who-you-me's full-sized avatar

Hisao Soyama who-you-me

View GitHub Profile
domain,count
portal.nifty.com,303
trafficnews.jp,277
kabumatome.doorblog.jp,196
blog.livedoor.jp/vitaminw,125
honz.jp,77
mag.japaaan.com,69
dhanow.ldblog.jp,66
reki.hatenablog.com,52
delete-all.hatenablog.com,52
# coding: utf-8
import csv
import networkx as nx
g = nx.read_pajek("russians.net")
f = open("nodes.csv", "w")
writer = csv.writer(f)
# coding: utf-8
import networkx as nx
import py2neo
g = nx.read_gml("netscience.gml")
db = py2neo.Graph("http://192.168.33.11:7474/db/data")
db.delete_all()
for n, data in g.nodes(data=True):
MATCH (n) WITH count(n) AS ncount MATCH (m)-[r:COAUTH]-(b) RETURN m, toFloat(count(r)) / ncount AS d ORDER BY d DESC LIMIT 100
@who-you-me
who-you-me / hatena.py
Created March 29, 2015 09:45
はてなトップのホットエントリリストからURLとタイトルを取得する
# coding: utf-8
from pyquery import PyQuery as pq
doc = pq("http://www.hatena.ne.jp/")
for box in doc.items("div#p2 div.box"):
category = box.attr("class").split(" ")[0]
print("[{}]".format(category))
for li in box.items("li.js-bookmark-item"):
def func(ll):
ave_ll = 1.0 * sum(ll) / len(ll)
sum_ll = 1.0 * sum([abs(i - j) for i in ll for j in ll])
md = sum_ll / (len(ll) ** 2)
gini = sum_ll / (2 * (len(ll) ** 2) * ave_ll)
print("Mean difference: {}".format(md))
print("Gini coefficient: {}".format(gini))
@who-you-me
who-you-me / adapter1.py
Last active August 29, 2015 14:09
Adapter
# coding: utf-8
from abc import ABCMeta, abstractmethod
class Banner(object):
def __init__(self, string):
self.__string = string
def show_with_paren(self):
print("(" + self.__string + ")")
@who-you-me
who-you-me / iterator1.py
Created November 19, 2014 16:34
Iterator
# coding: utf-8
from abc import ABCMeta, abstractmethod
class Aggregate(object, metaclass=ABCMeta):
@abstractmethod
def iterator(self):
pass
class Iterator(object, metaclass=ABCMeta):
<source>
type tail
format apache
time_format %d/%b/%Y:%T %z
path /var/log/nginx/access.log
pos_file /var/log/td-agent/nginx.access.pos
tag nginx.access
</source>
<match nginx.access>