Skip to content

Instantly share code, notes, and snippets.

View hoge.py
def hoge():
print "hogehoge"
View MyLWMA.mq4.c
#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 Aug 29, 2015
doc2vec most_similar_labels and most_similar_words sample
View gist:efce940c067ee962d4e5
>>> 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
View gist:f72326c61304d90ca52c
# 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 Aug 29, 2015
Yahoo!競馬の情報から直近5走のデータを取得して縦馬柱をipythonで表示する
View gist:0d0cc58e3bbcaea68148
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 Apr 15, 2015
条件を満たす要素をまとめて変える
View gist:29690c651cbfc0cd23d7

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
View README.md
set_index <-> reset_index
View hello.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
if __name__ == '__main__':
print "Hello, world!"
@satomacoto
satomacoto / gist:1400302
Created Nov 28, 2011
A Blogger HTML/JavaScript gadget to add line number to gists, requires jQuery
View gist:1400302
<!-- 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 Dec 21, 2011
Linear Programming w/ OpenOpt, FuncDesigner, GLPK, CVXOPT
View lp.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from FuncDesigner import *
from openopt import LP
# 変数の定義
x1,x2 = oovars(2)
# 目的関数
f = 3*x1 + 2*x2
# 初期解
You can’t perform that action at this time.