Skip to content

Instantly share code, notes, and snippets.

def hoge():
print "hogehoge"
@satomacoto
satomacoto / MyLWMA.mq4.c
Last active August 29, 2015 14:05
MyLWMA
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
// 指標バッファ
double BufMA[];
// パラメータ
extern int MA_Period = 20;
@satomacoto
satomacoto / gist:efce940c067ee962d4e5
Last active August 29, 2015 14:14
doc2vec most_similar_labels and most_similar_words sample
>>> import gensim
>>> sentences = [
... ['human', 'interface', 'computer'], #0
... ['survey', 'user', 'computer', 'system', 'response', 'time'], #1
... ['eps', 'user', 'interface', 'system'], #2
... ['system', 'human', 'system', 'eps'], #3
... ['user', 'response', 'time'], #4
... ['trees'], #5
... ['graph', 'trees'], #6
... ['graph', 'minors', 'trees'], #7
@satomacoto
satomacoto / gist:f72326c61304d90ca52c
Last active August 29, 2015 14:15
month iteration
# https://labix.org/python-dateutil
from dateutil import rrule, parser
dt = parser.parse('2014-01-01')
for x in rrule.rrule(rrule.MONTHLY, dtstart=dt, count=3):
print(x)
@satomacoto
satomacoto / gist:0d0cc58e3bbcaea68148
Last active August 29, 2015 14:16
Yahoo!競馬の情報から直近5走のデータを取得して縦馬柱をipythonで表示する
import pandas as pd
from lxml import html
# 出馬表
denma_url = 'http://keiba.yahoo.co.jp/race/denma/1405040911/'
xpath = '//table'
denma_tree = html.parse(denma_url)
denma_table = denma_tree.xpath(xpath)[2]
denma_html = html.tostring(denma_table)
denma_html = denma_html.decode('utf-8').replace('<br>', '\\n')
@satomacoto
satomacoto / gist:29690c651cbfc0cd23d7
Created April 15, 2015 01:49
条件を満たす要素をまとめて変える

python, pandas

In [1]: df
Out[1]:
  apple banana cherry
0     0      3   good
1     1      4    bad
2     2      5   good
In [2]: df.loc[df.cherry == 'bad', ['apple', 'banana']] = np.nan
@satomacoto
satomacoto / README.md
Created May 14, 2015 10:04
pandas tips

set_index <-> reset_index

@satomacoto
satomacoto / hello.py
Created November 28, 2011 12:29
Hello, world!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
if __name__ == '__main__':
print "Hello, world!"
@satomacoto
satomacoto / gist:1400302
Created November 28, 2011 12:57
A Blogger HTML/JavaScript gadget to add line number to gists, requires jQuery
<!-- add line number to gist -->
<script type="text/javascript">
$('.gist').each(function() {
$('.line',this).each(function(i, e) {
$(this).prepend(
$('<div/>').attr('unselectable','on').css({
'float' : 'left',
'width': '30px',
'font-weight' : 'bold',
'color': 'grey',
@satomacoto
satomacoto / lp.py
Created December 21, 2011 16:52
Linear Programming w/ OpenOpt, FuncDesigner, GLPK, CVXOPT
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from FuncDesigner import *
from openopt import LP
# 変数の定義
x1,x2 = oovars(2)
# 目的関数
f = 3*x1 + 2*x2
# 初期解