Skip to content

Instantly share code, notes, and snippets.

Avatar

Kohki YAMAGIWA tamanobi

  • OLTA Inc.
  • Shibuya, Tokyo
View GitHub Profile
@tamanobi
tamanobi / main.js
Created Apr 28, 2021
Google フォームの回答時に回答コピーと、別のフォームURLを送信する機能
View main.js
function getHeaders(sheet) {
var last_col = sheet.getLastColumn();
var range = sheet.getRange(1, 1, 1, last_col);
var headers = range.getValues();
return headers[0];
}
function getColumnNumByHeader(sheet, header) {
var n = getHeaders(sheet).indexOf(header);
if (n < 0) {
throw Error("ヘッダーが見つからなかった");
@tamanobi
tamanobi / register.js
Last active Apr 28, 2021
Google フォームに連番紹介コードを付与できる
View register.js
function getHeaders(sheet) {
var last_col = sheet.getLastColumn();
var range = sheet.getRange(1, 1, 1, last_col);
var headers = range.getValues();
return headers[0];
}
function getColumnNumByHeader(sheet, header) {
var n = getHeaders(sheet).indexOf(header);
if (n < 0) {
throw Error("ヘッダーが見つからなかった");
View register.js
function getHeaders(sheet) {
var last_col = sheet.getLastColumn();
var range = sheet.getRange(1, 1, 1, last_col);
var headers = range.getValues();
return headers[0];
}
function getColumnNumByHeader(sheet, header) {
var n = getHeaders(sheet).indexOf(header);
if (n < 0) {
throw Error("ヘッダーが見つからなかった");
@tamanobi
tamanobi / go.mod
Created Jul 1, 2020
goqueryの使い方を教えるためのスニペット
View go.mod
module goquerytrial
go 1.14
require github.com/PuerkitoBio/goquery v1.5.1
@tamanobi
tamanobi / matmu.py
Created Apr 13, 2020
行列と行列の積
View matmu.py
from typing import List, Union
import unittest
from operator import mul
Matrix = List[List[Union[int, float]]]
def matmul(mat1: Matrix, mat2: Matrix) -> Matrix:
return [[sum(map(mul, row, column)) for column in zip(*mat2)] for row in mat1]
@tamanobi
tamanobi / get_predictor.py
Last active Nov 20, 2019
AWS SageMakerをローカルで使うときに便利なスクリプト
View get_predictor.py
from sagemaker.estimator import Estimator
from sagemaker.predictor import RealTimePredictor
def get_predictor(training_job_name: str) -> RealTimePredictor:
"""
ジョブ名から RealTimePredictor を取得して返す
すでに訓練ジョブ名と同名のエンドポイントがある場合には、エンドポイントから RealTimePredictor を返す
Args:
@tamanobi
tamanobi / di.go
Last active Nov 15, 2019
依存を注入できるようにしてテストする
View di.go
package di
import (
"fmt"
"time"
)
func Hogehoge(fn func()) error {
// Do something(Heavy process)
time.Sleep(2 * time.Second)
View deployment.yml
apiVersion: v1
kind: ConfigMap
metadata:
name: vscode-settings-configmap
data:
settings.json: |
{
"terminal.integrated.shell.linux": "/bin/bash"
}
@tamanobi
tamanobi / enlarging-pixiv-discovery.js
Last active Sep 24, 2019
pixivのdiscoveryをより快適に楽しむ。このコードを使うときは連絡をください。
View enlarging-pixiv-discovery.js
let backgroundImageToUrl = bgImage => {
const url = bgImage.replace('url(', '').replace(')','').replace(';','').replace('"','').replace('"','');
return url.replace(/c\/[^/]+\//,'');
}
let setupEnlarging = (btn, panel) => {
document.getElementsByTagName('figure').forEach(figureElement => {
let imageContainer = Array.from(figureElement.getElementsByTagName('div')).filter(e => e.classList.length > 0 && e.style.backgroundImage)[0];
if (imageContainer) {
@tamanobi
tamanobi / train_test_split.py
Created Mar 7, 2019
ディレクトリに入ったjpg, xml, txtを一定の割合でtrain、testディレクトリに移動する(inspired by https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html)
View train_test_split.py
# coding:utf-8
from pathlib import Path
import sys
import argparse
from shutil import move
import random
from logging import getLogger, DEBUG, INFO, StreamHandler
logger = getLogger(__name__)
logger.setLevel(level=DEBUG)