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
bash <(curl -Ls http://git.io/eUx7rg) |
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
select | |
turn_id, | |
sum(case when life >= 0 and life <= 5 then 1 else 0 end) as life_from0to5, | |
sum(case when life > 5 and life <= 10 then 1 else 0 end) as life_from5to10, | |
sum(case when life > 10 and life <= 15 then 1 else 0 end) as life_from10to15, | |
sum(case when life > 15 and life <= 20 then 1 else 0 end) as life_from15to20, | |
sum(case when life > 20 and life <= 25 then 1 else 0 end) as life_from20to25, | |
sum(case when life > 25 and life <= 30 then 1 else 0 end) as life_from25to30 | |
from log_life | |
group by turn_id |
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
# -*- coding: utf-8 -*- | |
from sklearn.svm import LinearSVC | |
from sklearn.ensemble import AdaBoostClassifier,ExtraTreesClassifier ,GradientBoostingClassifier, RandomForestClassifier | |
from sklearn.decomposition import TruncatedSVD | |
from sklearn import datasets | |
from sklearn.cross_validation import cross_val_score | |
# 学習データを用意する | |
iris = datasets.load_iris() #ライブラリ付属のサンプルデータ |
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
import multiprocessing | |
def score4abc(a,b): | |
score = a,b | |
return score | |
def wrapper_score4multi(args): | |
return score4abc(*args) | |
def main(a,foo): |
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
import sqlite3 | |
DATABASE = "unko" | |
def sql4execute(sql,params=[]): | |
db = sqlite3.connect(DATABASE) | |
db.text_factory = str | |
cur = db.execute(sql,params) | |
db.commit() | |
db.close() |
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
def levenshtein(s1, s2): | |
if len(s1) < len(s2): | |
return levenshtein(s2, s1) | |
# len(s1) >= len(s2) | |
if len(s2) == 0: | |
return len(s1) | |
previous_row = range(len(s2) + 1) | |
for i, c1 in enumerate(s1): |
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
#! /usr/local/bin/python | |
# -*- coding:utf-8 | |
import multiprocessing | |
from time import sleep | |
def foo(): | |
def f(j,k): | |
l = j + k | |
print "no:%s" % i |
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
# zen2han.awk | |
# 全角 英数字記号 を半角文字に変換する | |
# 全角カタカナ等も対象とする。 | |
BEGIN{ | |
split("0123456789", az, ""); | |
split("0123456789", ah, ""); | |
split("ABCDEFGHIJKLMNOPQRSTUVWXYZ", bz, ""); | |
split("ABCDEFGHIJKLMNOPQRSTUVWXYZ", bh, ""); |
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 threading import Thread | |
from django.core.mail import send_mail | |
subject = 'Hello!' | |
msg = '\n \n Hello World!' | |
sender = settings.DEFAULT_FROM_EMAIL | |
to = 'x...@xx.com | |
t = Thread(target=send_mail, args=[subject, msg, sender, to], kwargs={'fail_silently': False}) | |
t.setDaemon(True) |
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
import unittest | |
from google.appengine.ext import testbed, ndb | |
from mock import patch, Mock | |
class MyTestCase(unittest.TestCase): | |
def setUp(self): | |
self.testbed = testbed.Testbed() | |
self.testbed.activate() | |
self.testbed.init_urlfetch_stub() |
NewerOlder