Skip to content

Instantly share code, notes, and snippets.

# pip install pillow
# ref: https://tat-pytone.hatenablog.com/entry/2021/12/22/202936
from PIL import Image
# 画像の読み出し
im1 = Image.open('input/tsuzuri1.jpg')
im2 = Image.open('input/nankyoku.jpg')
im2 = im2.resize((960, 1165))
# グリーンバックの画像をHSV変換
@showyou
showyou / main.rs
Created December 31, 2022 06:23
曜日を答えるやつ
use String;
use std::io;
fn calc_day_of_weeks(date: i32) -> i32{
let year = date / 10000;
let month = date % 10000 / 100;
let year_fixed = if month < 3 {year - 1} else {year};
let month_fixed = if month < 3 {month + 12} else {month};
let year_bottom = year_fixed % 100;
@showyou
showyou / replypattern.json
Created May 2, 2022 09:57
hamaの会話パターン
{
"footer":"なのよ",
"comment":"/* 識別子 複数対応, 先頭のみ対応,応答間隔, 判定文字, 返信文字群 */",
"ohayou": [ true, false, 480, "おはよう|起床|オハヨウ|こんにち(わ|は)", ["おはようなのよ","おはおはなのよ","おはようご>ざいますなのよ"] ],
"tadaima":[ false, false, 30, "ただいま|帰宅($|。|し(まし)*た($|。))",["おかえりなのよ", "おかえりなさいなのよ"]],
"otukare":[ false, false, 10, "(疲|つか)れた|タスケテ|助けて|悲しい|つらい",["おつかれさまなのよ","あともうちょっと、>なのよ。","私が見守ってるのよ","元気出して、なのよ♪"]],
"chucchu":[ false, false, 0, "甘えたい|ちゅっ",["にゃ〜","にゃん♪","ふん、なのよ。"]],
"gacha":[ false, false, 10, "ガチャ|ガシャ", ["まわし過ぎには注意なのよ", "天井まで行った?なのよ", "ガチャは悪い文明なのよ"]],
"nanya":[ false, false, 10, "なんや!", ["なんやとはなんなのよ!", "なんやとはなんなのよ!"]],
"sate":[ false, false, 40, "さて", ["さて?", "さて?"]],
@showyou
showyou / how to build
Created February 7, 2021 03:20
M1 Mac + rustupでrust 1.49.0が入る
% rustc hello.rs -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
@showyou
showyou / gen_image.py
Created December 21, 2020 13:13
gen_image.py
from PIL import Image, ImageDraw
images = []
before = 20
frames = 30 + 1
after = 20
s = (0xff, 0xff)
e = (0x8e, 0x00)
@showyou
showyou / zsh
Created December 16, 2020 06:34
zsh。もっといい物はあるかと
autoload -Uz compinit
autoload -Uz vcs_info
zstyle ':vcs_info:*' formats '(%s:%b)'
zstyle ':vcs_info:*' action formats '(%s:%b|%a)'
precmd (){
psvar=()
LANG=en_US.UTF8 vcs_info
[[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_"
}
compinit
@showyou
showyou / gist:425eebe841c8d06fbad37de62d686ed3
Created September 20, 2020 13:09
ヴァイオレットエヴァーガーデンとそれ程関わらないけど家の話
親が二年前に亡くなったけど、その次の自分の誕生日近くに、おばから母から預かった手紙を渡された
@showyou
showyou / sample_readline.py
Created May 16, 2020 14:35
ファイル読み込み
# sys.argvのlenに関しては(本当は良くないけど)今回は割愛
import sys
filename = sys.argv[1]
with open(filename) as f:
lines = f.readlines()
cnt = 0
for l in lines:
print(cnt, l.rstrip("\n"))
cnt += 1
@showyou
showyou / combination_of_duotrio.py
Created April 4, 2020 07:31
次のデュオトリオの組み合わせを勝手に見つける
import random
aqours = ["千歌", "梨子", "果南", "ダイヤ", "曜", "善子", "花丸", "鞠莉", "ルビィ"]
def check(combi):
if set(combi) == ("千歌", "果南") or \
set(combi) == ("善子", "曜") or \
set(combi) == ("ダイヤ", "ルビィ") or \
set(combi) == ("花丸", "鞠莉", "梨子"):
@showyou
showyou / generator.py
Created April 4, 2020 01:23
x日後にyするz
import random
days = random.randint(1,101)
action = random.choice(["死ぬ", "生きる", "結婚する", "食べる", "進化する", "辞職する", "産卵する"])
target = random.choice(["ワニ", "カエル"])
text = "%s日後に%s%s" % (days, action, target)
print(text)