Skip to content

Instantly share code, notes, and snippets.

View KatsuhiroMorishita's full-sized avatar

Katsuhiro Morishita KatsuhiroMorishita

View GitHub Profile
@KatsuhiroMorishita
KatsuhiroMorishita / utils.py
Created November 2, 2024 03:31
Fixes for mp3 support for BireNET as of November 2, 2024
import os
from itertools import count, islice
from pathlib import Path
from typing import Any, Generator, Iterable, Optional, Tuple, Union
import numpy as np
import numpy.typing as npt
import requests
import soundfile as sf
from ordered_set import OrderedSet
@KatsuhiroMorishita
KatsuhiroMorishita / utils.py
Last active November 2, 2024 03:30
Fixes for mp3 support for BireNET as of September 2, 2024
import os
from itertools import count, islice
from pathlib import Path
from typing import Any, Generator, Iterable, Optional, Tuple, Union
import numpy as np
import numpy.typing as npt
import requests
import soundfile as sf
from ordered_set import OrderedSet
@KatsuhiroMorishita
KatsuhiroMorishita / slowcopy.py
Last active August 30, 2024 06:07
一度にコピーできない様な調子の悪いSDカードからファイルをゆっくりコピーするPythonのプログラムです。
# purpose: ファイルをゆっくりコピーする
# PCの機能によるファイルコピーではデータを取り出せない様な、
# 調子の悪いSDカードからデータを取り出すために作製した。
# author: Katsuhiro Morishita
# created: 2023-10-24
# license: MIT
import os, glob, time
@KatsuhiroMorishita
KatsuhiroMorishita / マクスウェル分布のシミュレーション.ipynb
Created May 9, 2021 12:36
気体分子の速度分布はマクスウェル分布に従います。このプログラムでは、分子の衝突を繰り返して速度分布がどうなるか確認しています。物理が専門ではないので少し間違えているかもしれませんが・・・。
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@KatsuhiroMorishita
KatsuhiroMorishita / RTC_adjust_with_serial_monitor.ino
Created September 9, 2018 10:52
Arduinoに接続されたRTCの時刻をシリアルモニタで調整するサンプルプログラムです。ネット上に転がっているプログラムはビルドした時刻がセットされるものがほとんどですが、このプログラムはシリアルモニタを使って任意の日時にセットできます。デフォルトでは、Stalker v3.1に搭載されているDS1337を対象にしていますが、他のICでもほとんど改造せずに使えるはずです。
// Arduinoに接続されたRTCの時刻をシリアルモニタで調整するサンプルプログラム
// memo: デフォルトでは、Stalker v3.1に搭載されているDS1337を対象にしていますが、他のICでもほとんど改造せずに使えるはずです。
// author: Katsuhiro Morihsita
// created: 2018-09-07
// license: MIT
#include <DS1337.h>
// RTC関係
DS1337 RTC;
@KatsuhiroMorishita
KatsuhiroMorishita / tf_checker4python.py
Last active April 23, 2018 01:59
文字列やベクトルや行列を含む配列の一致を判定する関数です。Pythonで行った数値計算の試験の解答用に開発しました。
# 不定形のベクトルの一致を判定する
# 数値計算の試験の解答用に開発した。
# author: Katsuhiro Morishita
# created: 2018-02
# lisence: MIT
import numpy as np
import collections
def flatten(foo):
@KatsuhiroMorishita
KatsuhiroMorishita / blynk_queue_test.ino
Last active January 25, 2018 14:57
Blynkのnotifyは一度送信すると15秒ほど不感知となり、送信リクエストが失われます。 そこで、リクエストされたメッセージを取りこぼすことなく送信するためのクラスを作成しました。実際に利用する際はクラスを.cppファイルとしてご利用ください。なお、その場合は#include<Arduino.h>の追記が必要です。
/*************************
blynkのnotifyは一度送信すると10秒ほど不感知となり、送信リクエストが失われます。
そこで、リクエストされたメッセージを取りこぼすことなく送信するためのクラスを作成しました。
author: Katsuhiro Morishita
created: 2018-01-25
lisence: MIT
**************************/
#include <Blynk.h>
#include <BlynkSimpleStream.h>
@KatsuhiroMorishita
KatsuhiroMorishita / chatter_resistance.ino
Last active October 18, 2017 13:35
チャタリング対策のクラスを実装したLEDを光らせるサンプルコードです。複数のボタンを待ち時間なしでスキャンできます。delay()を使っていないので、複数のボタンを同時に押されても判定可能です。
// purpose: チャタリング対策のテスト
// 2016年に作った気がするが、その前だったかも。
// ボタンを押すと、ただLEDが光るサンプルコード。チャタリング対策用のクラスがみそ
// author: Katsuhiro Morishita
// created: 2017-10-18
// lisence: MIT
const int led1 = 4;
const int led2 = 5;
const int butt1 = 6;
@KatsuhiroMorishita
KatsuhiroMorishita / excel2htmltable.py
Created August 24, 2017 03:49
Excelの表からhtmlのtableを作成するPythonのスクリプトです。縦に結合したセルがあっても大丈夫です。(横に結合したセルがあると対応できない)
# Excelの表からhtmlのtableを作成する
# memo: 体育大会の試合結果をWebに掲載するために作成した。
# author: Katsuhiro Morishita
# created: 2017-08-24
# lisence: MIT
import pandas as pd
import math
import re
@KatsuhiroMorishita
KatsuhiroMorishita / data_split.py
Last active March 27, 2019 18:53
機械学習用に、データをランダムに並べ替えた上で分割します。学習用のデータと検証用のデータを分ける際にご利用下さい。
# purpose: 機械学習用に、データをランダムに並べ替えた上で分割する
# author: Katsuhiro Morishita
# created: 2017-07-10
# license: MIT
import sys
import numpy as np
import pandas
argvs = sys.argv # コマンドライン引数を格納したリストの取得
if len(argvs) < 3: