Skip to content

Instantly share code, notes, and snippets.

View new-village's full-sized avatar

new-village new-village

  • Tokyo, Japan
View GitHub Profile
@new-village
new-village / apply_function_2_dataframe.py
Last active May 4, 2018 08:38
データフレームの各行にファンクションの結果をインサートする方法
# ジョッキーの複勝率の計算
def cal_jockey(jid, rdt):
query = Result.objects.filter(jockey_id=jid, race__race_dt__lt=rdt).exclude(rank=0)
run_all = query.count()
run_t3 = query.filter(rank__lte=3).count()
ratio = round(run_t3 / run_all, 2) if run_all != 0 else 0
return ratio
@new-village
new-village / get_data.py
Created January 7, 2018 04:30
netkeiba.com login
import sys
from requests import Session, HTTPError
from django.core.management.base import BaseCommand, CommandError
session = Session()
class Command(BaseCommand):
can_import_settings = True
def handle(self, *args, **options):
login_netkeiba()
@new-village
new-village / setting_local.py
Last active January 7, 2018 04:11
netkeiba.com login variables
# NETKEIBA Login Information (LOCAL)
# http://www.netkeiba.com/
NETKEIBA_USER = "<YOUR_EMAIL>"
NETKEIBA_PASS = "<YOUR_PASSOWRD>"
LOGIN_INFO = {
'pid': 'login',
'action': 'auth',
'login_id': NETKEIBA_USER,
'pswd': NETKEIBA_PASS
@new-village
new-village / tests.py
Last active November 8, 2015 04:52
Sample Code of "Test-Driven Django Tutorial Part 1"
from django.test import LiveServerTestCase
from selenium import webdriver
class PollsTest(LiveServerTestCase):
def setUp(self):
self.browser = webdriver.PhantomJS()
self.browser.implicitly_wait(3)
def tearDown(self):
@new-village
new-village / custom.css.scss
Last active August 29, 2015 14:24
decrease Bootstrap 3.3 Navbar height
/* universal */
body {
padding-top: 45px;
}
/* header */
.navbar {
min-height: 40px !important
}
<header class="navbar navbar-fixed-top navbar-inverse" role="navigation">
<div class="container">
<!-- ページタイトル -->
<%= link_to "mypage", root_path, class: "navbar-brand" %>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<!-- リンク -->
<ul class="nav navbar-nav navbar-left">
<li><%= link_to "画面1", root_path %></li>
</ul>
/*
GetDate: 2015/04/07
Site: http://j1.ax.xrea.com/l.j?id=300012781
Referer: http://lists.clean-mx.com/pipermail/viruswatch/20100102/012754.html
*/
function sCk(key, c, p) {
d = 365;
path = "";
e = new Date();
@new-village
new-village / settings.py
Last active August 29, 2015 14:16
djangoチュートリアル(その1) - モデルの作成より v2
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls'
)
@new-village
new-village / admin.py
Created March 5, 2015 10:58
djangoチュートリアル(その1)
from django.contrib import admin
from polls.models import Choice, Question
class ChoiceInline(admin.StackedInline):
model = Choice
extra = 3
class QuestionAdmin(admin.ModelAdmin):
@new-village
new-village / settings.py
Last active August 29, 2015 14:16
djangoチュートリアル(その1) - モデルの作成より
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls'