Skip to content

Instantly share code, notes, and snippets.

@dannyso16
dannyso16 / M5Unified_IMU_graph.cpp
Last active May 12, 2025 13:17
M5UnifiedでIMUの各値を棒グラフで表示するサンプルプログラム。roll,pitch,yawは相補フィルタで計算して表示
#include <M5Unified.h>
// Strength of the calibration operation;
// 0: disables calibration.
// 1 is weakest and 255 is strongest.
static constexpr const uint8_t calib_value = 64;
// 姿勢角用の設定
static constexpr float COMPLEMENTARY_FILTER = 0.96f; // 相補フィルター係数
@dannyso16
dannyso16 / maibo.vb
Created December 19, 2024 12:00
simple_excel_macro
Sub UpdateNaboTable()
Dim wsNabo As Worksheet, wsMaster As Worksheet
Dim lastRowNabo As Long, lastRowMaster As Long
Dim i As Long, j As Long
Dim masterPrefecture As String, masterAge As Long, masterNotes As String
Dim naboPrefecture As String, naboBirthday As Date
Dim currentYear As Long
Dim colNaboPrefecture As Range, colNaboBirthday As Range, colNaboNotes As Range
Dim colMasterPrefecture As Range, colMasterAge As Range, colMasterNotes As Range
@dannyso16
dannyso16 / replace_and_create_files_with_params
Created September 19, 2022 12:26
テンプレファイルの一部を置換したファイルを、パラメータ違いで複数出力するPowershell
# 各種設定値
$SOURCE_FILE = "file.txt" # 置換前ファイル
$SETTING = "param.csv" # 置換のハッシュテーブル。各行ごとに新規ファイル作成
$ENCODING = "UTF8"
# 初期処理
$CurrentDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $CurrentDir
@dannyso16
dannyso16 / daemon-will-kill-Twitterer.py
Created April 30, 2021 08:41
Twitterを開くとデーモンがPCを再起動するスクリプト。python3.6.5, PySimpleGUI4.37.0
import PySimpleGUI as sg
from PIL import Image
import time
import os
import win32com.client
class TwitterTimeCounter:
def __init__(self):
self.time = 0
@dannyso16
dannyso16 / tetris_on_terminal.py
Last active January 1, 2021 12:36
terminal上でテトリスで遊ぶ。テトリミノはカラーで描画される。実行環境: python3.X, `pip install pygame`, Windows or Linux
# -*- coding: utf-8 -*-
import pygame
from pygame.locals import *
import numpy as np
import subprocess
class Color:
"""print文に色をつける
用例:print(f'赤:{Color.RED}これは赤色文字です{Color.RESET}')
@dannyso16
dannyso16 / fizzbuzz.py
Last active October 6, 2020 03:30
100万行のFizzBuzzコードをつくります。(f文字列があるのでPython 3.6以上を想定)
N = 1_000_000
s = f"N = {N}\nfor i in range(N):\n"
with open("FizzBuzz.py", mode='w') as f:
f.write(s)
for i in range(1, N):
if i == 1:
s = f"\tif i == {i}:\n\t\tprint({i})\n"
elif i % 15 == 0:
s = f"\telif i == {i}:\n\t\tprint(\"FizzBuzz\")\n"
@dannyso16
dannyso16 / delete_unused_files.py
Last active August 8, 2020 01:37
Windowsのbatファイルとして保存し、好きなフォルダに入れて実行すると過去7日間アクセスしていないファイルをすべてゴミ箱に移す。
REM = r"""
SET PYTHON_EXE="python.exe"
%PYTHON_EXE% %0 %1
PAUSE
EXIT
"""
import os
import glob
import time