Skip to content

Instantly share code, notes, and snippets.

View Mya-Mya's full-sized avatar
🐙

Mya-Mya Mya-Mya

🐙
View GitHub Profile
@Mya-Mya
Mya-Mya / syspath.py
Created June 4, 2024 02:36
`sys.path`に記載されたディレクトリ内にあるパッケージを挙げる
import os, sys
for path in sys.path:
if os.path.isdir(path):
print(f"{path}")
for child in os.listdir(path):
full_child_path = os.path.join(path, child)
if os.path.isdir(full_child_path) and not child.endswith("-info"):
print(f"{child}", end=", ")
print()
print()
@Mya-Mya
Mya-Mya / RemoveBadgedUsersInReplies.js
Last active May 6, 2024 11:48
リプライ画面での認証済みアカウントの投稿を削除する
javascript: (function () {
/**
* @param root{HTMLElement}
* @param idxlist{Number[]}
* @returns {HTMLElement}
*/
function digChild(root, idxlist) {
if (!idxlist.length) return root;
var next_idxlist = [...idxlist];
var i = next_idxlist.shift();
@Mya-Mya
Mya-Mya / evernote2txt.py
Last active February 7, 2024 02:26
🐘Exported Evernote HTML File → Simple Text File
from bs4 import BeautifulSoup
from pathlib import Path
from dataclasses import dataclass
from tqdm import tqdm
from datetime import datetime
import re
from collections import defaultdict
@dataclass
class Article:
@Mya-Mya
Mya-Mya / bestmmtraj.m
Created January 25, 2024 08:35
Find the maximum probability trajectory in a markov model.
N = 8;
K = 4;
% (k,i,j) = 時刻k-1→kでの,j→iの遷移度数
T_data = rand(K, N, N)
%% 遷移度数表データを視覚化する
fig = figure(Name="Transition Counts Strength");
hold on;
xlabel("Time k"); ylabel("State Index i");
/*
PushAndSurvive
使用ボード
ネコボード
遊び方
シリアルモニターを用意し、ボーレートを1200に合わせます。
電源を入れると、シリアルモニターにストーリーが流れてきます。
いいタイミングの時に、ネコボードのボタンを押してください。
@Mya-Mya
Mya-Mya / Nabeatsu.m
Last active October 12, 2023 14:40
厳密なナベアツアホ割合を求める
N = 1e8
x_s = 1:N;
aho_flag_list = zeros(1,N);
%% xが3の倍数であればアホ
tic
aho_flag_list(3:3:N) = 1;
toc
@Mya-Mya
Mya-Mya / scenechanging.m
Created June 14, 2023 08:49
MATLAB uifigure GUI Scene Changing
function scenechanging
%%
fig = uifigure;
l = uigridlayout(fig,[3 2]);
maincontainer = uipanel(l);
maincontainer.Layout.Column = [1 2];
maincontainer.Layout.Row = [1 3];
s1_button = uibutton(l);
s1_button.Text = "1";
@Mya-Mya
Mya-Mya / okaerinasai.m
Created June 13, 2023 13:03
MATLAB Code Based GUI Programming Sample
function okaerinasai
%%
fig = uifigure;
fig.Name = "MATLAB GUI Test";
%%
layout = uigridlayout(fig,[2 2]);
%%
greeting_label = uilabel(layout);
greeting_label.Text = "お帰りなさい,あなた.何にする?";
greeting_label.HorizontalAlignment = "right";
@Mya-Mya
Mya-Mya / gridder_v2.py
Last active May 20, 2022 14:14
写真にグリッドを付ける
from PIL import Image, ImageDraw
from pathlib import Path
from matplotlib import pyplot as plt
def add_grid(image: Image.Image, d: int) -> Image.Image:
width, height = image.size
new_image = Image.new("RGB", (width+d, height+d), (255, 255, 255))
new_image.paste(image, (0, 0))
draw = ImageDraw.Draw(new_image)
@Mya-Mya
Mya-Mya / useComingBackState.js
Created February 7, 2022 14:51
The hook similar to useState, but automatically set to default value some time after the value is set.
import { useState } from "react";
export default (defaultValue, ms) => {
const [value, setValue] = useState(defaultValue);
const [timeoutHandler, setTimeoutHandler] = useState(null);
const mySetValue = (newValue) => {
setValue(newValue);
if (timeoutHandler) clearTimeout(timeoutHandler);
setTimeoutHandler(
setTimeout(() => {
setValue(defaultValue);