Skip to content

Instantly share code, notes, and snippets.

View kazuhito-m's full-sized avatar

Kazuhito Miura kazuhito-m

View GitHub Profile
@kazuhito-m
kazuhito-m / AlertStockQuotations.gs
Last active January 25, 2024 11:21
AlertStockQuotations.gs
/**
* 設定した前週比の下落幅パーセントを下回った場合、チャットにアラートするGASスクリプト。
*
* 決まった形式のGoogleSpreadSheetの情報を元に、指定銘柄の前週比(スケジューリングで一週間ごとに実行)を記録、
* 指定した比率以下に下落した場合、Discordのチャンネルに通知する。
*
* 環境変数(スクリプトプロパティに設定する)
* - SPREAD_SHEET_URL: データ&設定を仕込んだGoogleSpreadSheetのURL
* - DISCORD_ENDPOINT: Discordの特定チャンネルへのWebHook URL
*/
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class FizzBuzzSourceGenerator {
public static void main(String[] args) throws FileNotFoundException {
String sourceText = "public class FizzBuzz {\n\tpublic static void main(String[] args) {"
+ generateOutputPart()
+ "\n\t}\n}";
@kazuhito-m
kazuhito-m / charset_comvert.sh
Created September 3, 2022 13:46
charset_comvert.sh
#!/bin/bash
for i in $(find ./ -name '*.cs') ; do
nkf --overwrite -d --oc=UTF-8-BOM $i
done
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.UUID;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@kazuhito-m
kazuhito-m / ReadMultipartFileMultipleTimesController.java
Last active January 25, 2024 11:19
org.springframework.web.multipart.MultipartFile の getInputStream() メソッドは何回呼んでも読み出せる、という例。
package com.kazuhitom.demo.presentation.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
@kazuhito-m
kazuhito-m / WebSpeechAPISpeechSynthesis.html
Last active January 25, 2024 11:19
WebSpeechAPISpeechSynthesis.html
<!DOCTYPE html>
<html>
<head>
<title>Web Speech API Speech Synthesis の基本的なサンプル</title>
</head>
<body>
<h1> Web Speech API Speech Synthesis の基本的なサンプル</h1>
<p><textarea id="speachText">日本語でしゃべります。ro-majidemo,ikemasu.</textarea></p>
<p>
rate:
@kazuhito-m
kazuhito-m / KaraokeTweet.gs
Last active September 24, 2020 15:54
KaraokeTweet.gs
/**
* JoySoundの歌唱履歴ページを定期的にポーリングし、追加があればSpreadSheetに書きつつ、TwitterへつぶやくGASスクリプト。
*
* Usage
* 1. GoogleAppScriptに新たにスクリプトを作り、このソースを貼る。
* 2. ファイル->プロジェクトのプロパティ->スクリプトのプロパティを開き、以下の変数を設定する。
* - joysound_id : JoySoundの「うたスキ(https://www.joysound.com/utasuki)」にログインするためのID
* - joysound_password : 上記のパスワード
* - spreadsheet_id : GoogleSpreadSheetのID
* - twitter_api_key : TwitterのAPI key
export default class Sreializer {
private readonly constructors: ObjectConstructor[];
constructor(...constructors: any) {
this.constructors = constructors;
}
public serialize(target: any): string {
this.addClassNameProperty(target); // TODO 元のオブジェクトを上書きまくるのでなんとかしたい
return JSON.stringify(target, null, 4);
@kazuhito-m
kazuhito-m / test_of_ping_ip_range.sh
Last active December 24, 2022 05:30
同一ネットワーク内で応答のあるIPをシュッと調べる
#!/bin/bash
IP_HEAD='192.168.1.'
echo ${IP_HEAD}{1..254} \
| xargs -P256 -n1 ping -s1 -c1 -W1 \
| grep ttl
exit 0
@kazuhito-m
kazuhito-m / configmap-environment-template.yaml
Last active February 28, 2020 11:22
gke/k8sのマニフェスト例
# k8sのアプリケーション群に与える環境変数のテンプレート
#
# 各環境ではこれを元として、書き換えたものを配置・参照するように。
#
apiVersion: v1
kind: ConfigMap
metadata:
name: thisproject-config
data:
ENVIRONMENT: local # 環境名