Skip to content

Instantly share code, notes, and snippets.

💭
🤔

ymtky

💭
🤔
Block or report user

Report or block ymtky

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ymtky
ymtky / google_finance.py
Last active Sep 8, 2018
google financeのAPI使用サンプル
View google_finance.py
import requests
from datetime import datetime, timedelta
import pandas as pd
url = "https://www.google.com/finance/getprices"
code = 7203
lsat_date = datetime.now() #データの取得開始日
interval = 86400 #データの間隔(秒)。1日 = 86400秒
market = "TYO" #取引所のコード TYO=東京証券取引所
period = "1Y" #データを取得する期間
View gist:55d131138e259dfe77aa6d8a2f0f2e52
//モックを宣言
@Mocked
Hoge hoge;
//フィールドへの差込み
Deencapsulation.setField(hoge, "field" ,"hugahuga");
//メソッドへの差込み
when(hoge.get()).thenReturn("hugahuga"));
@ymtky
ymtky / pandas
Created Jun 9, 2017
pandasメモ
View pandas
#DataFrameから2次元配列
dataframe.values.toList()
#列名で選択
dataframe.loc[:,['A','B']]
@ymtky
ymtky / bot.js
Last active Sep 16, 2017
株価bot
View bot.js
const fetch = require('node-fetch');
module.exports = ( robot => {
robot.respond(/(.*)\s(.*)/, msg => {
Promise.all([fetchCurrentStockData(msg.match[2]), fetchDailyStockData(msg.match[2])]).then(values => {
const current = values[0]
//日次データから最新の前日のデータを取り出す
const dailyLatest = values[1][values[1].length - 1]
const dailyOneBefore = values[1][values[1].length - 2]
const yesterday = dailyLatest['DATE'].getMonth() == current['DATE'].getMonth()
View gist:24fdc4bac3c918783fd8f4b0c1b9a5d7
\数値で正規表現にマッチした文字列を参照する
:%s/hogehoge: \(\"[^\"]*\"\)/hugahuga: \1
改行を挿入する時は\r
:%s/\(hogehoge: \"[^\"]*\"\)/\1\r
View gist:cd9b9c6fd59186b6d53ec74705fa2b6a
タイポを置換で直す
git grep -l 'hogehoge' | xargs sed -i '' -e 's/hogehoge/hugahuga/g'
コミットのauthor dateを現在時刻にする
git commit --amend --date "`date`"
@ymtky
ymtky / gist:1a39a6f61c8d830f6c46a8402618f3c1
Created Jan 11, 2018
json schemaで外のファイルを参照する場合の指定
View gist:1a39a6f61c8d830f6c46a8402618f3c1
// httpで
"$ref": "http://schema/hogehoge.json"
// 絶対パス
"$ref": "file:///schema/hogehoge.json"
// mavenプロジェクトのresources下の相対パス
"$ref": "resource:/schema/hogehoge.json"
@ymtky
ymtky / ReosurcesGetter.java
Last active Jan 16, 2018
Javaでresources化のファイルを取得する
View ReosurcesGetter.java
public final class ReosurcesGetter {
public List<File> get(String path, String extension) {
File rootFile = new File(getClass().getResource(path).getPath());
return getRecursiveFiles(rootFile, extension);
}
// ファイルを再帰的に取得
private List<File> getRecursiveFiles(File file, String extension) {
Optional<File[]> maybeFiles = Optional.ofNullable(file.listFiles());
List<File> result = new ArrayList<>();
@ymtky
ymtky / border.swift
Created Sep 17, 2018
[Swift] UIViewの1辺にボーダーを設定
View border.swift
let bottomBorder = CALayer()
bottomBorder.frame = CGRect(x: 0, y: view.frame.height - 1, width: view.frame.width, height: 1.0)
bottomBorder.backgroundColor = UIColor.lightGray.cgColor
view.layer.addSublayer(bottomBorder)
View gist:d64281fd123d11b9e52ca7c3ae9b526f
import optuna
from functools import partial
import xgboost as xgb
from sklearn.metrics import f1_score
def objective(dtrain, dtest, trial):
max_depth = trial.suggest_int('max_depth',1,10)
eta = trial.suggest_uniform('eta',0.0,1)
subsample = trial.suggest_uniform('subsample', 0.5, 1)
colsample_bytree = trial.suggest_uniform('colsample_bytree', 0.5, 1)
You can’t perform that action at this time.