Skip to content

Instantly share code, notes, and snippets.

@mugenen
mugenen / python-2-7-pip-21-0.ipynb
Created February 1, 2021 14:16
Python 2.7 で pip 21.0 のインストールで失敗する例
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mugenen
mugenen / test.csv
Last active May 13, 2017 14:44
テスト用のcsv
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 5.
test,1
test,2
test,=1+2
test,4
test,=IMAGE("https://www.google.com/images/srpr/logo3w.png")
@mugenen
mugenen / narouData.txt
Created July 25, 2013 19:23
小説家になろうから作品タイトルと最初の投稿日時をクロールした結果
十字の時計 2004-10-22 20:21:04
柳沢呉服店 2004-06-07 01:53:19
僕が居なくなる 2004-08-10 16:15:31
リセットボタン 2004-10-15 01:27:52
卒業旅行戦国記 ー珠緒の恋ー 2004-06-23 19:02:17
みえるモノ・みえないモノ 2004-08-07 15:42:27
総合調査会社アジディックファイル1ジャッジメント 2004-04-20 01:51:31
キャリアウト〜Hold over operation 2004-05-21 22:29:13
傲慢なる少年の傀儡 2004-05-02 01:40:21
海の音 2004-07-19 08:02:24
@mugenen
mugenen / speed.py
Created December 24, 2012 16:28
日記ネタ: list, array, numpy.arrayの処理時間
import timeit
common_for = """
for d in data:
s += d
"""
common_sum = """
sum(data)
"""
common_numpy_sum = """
@mugenen
mugenen / sim.py
Created November 30, 2012 04:03
(Context) Similarity
# -*- coding: utf-8 -*-
import math
def jaccard(v1, v2):
numerator = sum([c in v2 for c in v1])
denominator = len(v1) + len(v2) - numerator
return float(numerator) / denominator if denominator != 0 else 0
def dice(v1, v2):
@mugenen
mugenen / qualC.py
Created April 15, 2012 09:52
Google Code Jam 2012 Qualification C
import sys
def count(MIN, MAX):
s = set()
L = len(str(MAX))
for i in xrange(MIN, MAX + 1):
for j in xrange(1, L):
div = 10**j
h = i / div
l = i % div
@mugenen
mugenen / qualB.py
Created April 15, 2012 09:51
Google Code Jam 2012 Qualification B
import sys
T = sys.stdin.readline()
i = 0
for l in sys.stdin:
count = 0
i += 1
data = map(int, l.split())
N, S, p = data[0:3]
G = data[3:]
def fib_recursive(n):
if n == 1:
return 1
if n == 2:
return 1
return fib_recursive(n - 1) + fib_recursive(n - 2)
memo = {}
def fib_memo(n):
if n == 1:
@mugenen
mugenen / wn.py
Created March 4, 2012 11:48 — forked from yanbe/wn.py
A frontend of WordNet-Ja database file (sqlite3 format) which is available on http://nlpwww.nict.go.jp/wn-ja/
#!/usr/bin/env python
# encoding: utf-8
import sys
import sqlite3
from collections import namedtuple
conn = sqlite3.connect("wnjpn.db")
Word = namedtuple('Word', 'wordid lang lemma pron pos')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
u"""人生を24時間換算したときの今日の時間を表示
This is released under the MIT License(http://www.opensource.org/licenses/mit-license.php).
Copyright (c) 2012 Satoru Ogasawara