Skip to content

Instantly share code, notes, and snippets.

@ksasao
ksasao / sunset.h
Last active March 9, 2025 02:50
現在地の日没時刻/日の出時刻を表示します https://x.com/ksasao/status/1898305387969012007
#ifndef SUNSET_H_
#define SUNSET_H_
#include<math.h>
// 計算式は下記のWebサイトを参考に実装しています
// 日出日没計算、やってみよう
// https://hhsprings.pinoko.jp/site-hhs/2015/02/%e6%97%a5%e5%87%ba%e6%97%a5%e6%b2%a1%e8%a8%88%e7%ae%97%e3%80%81%e3%82%84%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%88%e3%81%86/
typedef struct _DateTime {
int year;
@ksasao
ksasao / makeicon.py
Last active March 2, 2025 06:25
シンプルな日本地図上にマーカーをプロットします https://x.com/ksasao/status/1896076372617150879
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import pandas as pd
from PIL import Image
import numpy as np
import os
# CSVファイルを読み込む
# https://github.com/ksasao/ekimemo/blob/main/src/20250304/data.csv をローカルに保存してください
@ksasao
ksasao / ScentGPSLogger.ino
Last active February 11, 2025 14:16
M5Atom GPS と ENV Pro で、緯度経度に紐づいた匂いのログを記録します。 https://x.com/ksasao/status/1887864442442096790
// Scent+GPS Logger for M5Atom Atomic GPS Kit
// Library version M5Atom 0.1.3
// Board version M5Stack 2.1.3
#include "bme68xLibrary.h"
#include "M5Atom.h"
#include <sys/time.h>
#include <SPI.h>
#include "FS.h"
#include <SD.h>
#include <TinyGPS++.h>
@ksasao
ksasao / inputText.ino
Last active January 28, 2025 11:43
M5Cardputerで日本語表示。このコードには漢字変換機能はありません。https://x.com/ksasao/status/1884198721749213610
/**
* @file inputText.ino
* @author SeanKwok ([email protected])
* @brief M5Cardputer input text test
* @version 0.1
* @date 2023-10-13
*
*
* @Hardwares: M5Cardputer
* @Platform Version: Arduino M5Stack Board Manager v2.0.7
@ksasao
ksasao / Program.cs
Created January 25, 2025 06:54
Snipping Tool のインストールパスを取得する(Microsoft.ScreenSketch という名前でインストールされている)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FindSnippingToolPath
{
using System;
using System.Diagnostics;
@ksasao
ksasao / MainPage.xaml.cs
Created January 14, 2025 17:15
UWPで日本語OCR。XAMLは適当に作ってください。https://x.com/ksasao/status/1879207301850259523
using System;
using Windows.Graphics.Imaging;
using Windows.Media.Ocr;
using Windows.Storage.Pickers;
using Windows.Storage.Streams;
using Windows.Storage;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using System.Text;
@ksasao
ksasao / getstations.py
Last active January 13, 2025 04:30
駅データ https://github.com/Seo-4d696b75/station_database/blob/main/README.md の station.json と路線のpolylineデータ(11332.jsonなど)を利用して、指定した路線に乗車したときに駅メモでチェックイン可能な駅一覧を取得します。 https://x.com/ksasao/status/1877353964657590593
import json
import argparse
from shapely.geometry import Point, Polygon
from shapely.strtree import STRtree
def read_json(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
return data
@ksasao
ksasao / AzureMQTT.ino
Created December 19, 2024 12:54
Azure IoT Hub に対して M5Atom で直接MQTT。SAS Token やルート証明書もハードコーディングしていますが一応通信はできます。
#include "M5Atom.h"
#include <WiFi.h>
#include <PubSubClient.h>
#include <WiFiClientSecure.h>
#include "bme68xLibrary.h"
#include <math.h>
// home
const char* ssid = "your-ssid";
const char* password = "your-password";
@ksasao
ksasao / fujisan.py
Last active December 2, 2024 23:20
YouTubeの動画を再生して、その中の富士山が見えるかどうかを判定します
# Description: このスクリプトは、YouTubeの動画を再生して、その中の富士山が見えるかどうかを判定します。
# あらかじめchromeをインストールし、そのバージョンにあった chromedriver を
# 以下からダウンロードしてこのスクリプトと同じフォルダに配置
# https://googlechromelabs.github.io/chrome-for-testing/
# 環境変数 OPENAI_API_KEY に OpenAI の APIキーを設定してください。
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from PIL import Image
@ksasao
ksasao / TextAssistant.ino
Created November 6, 2024 13:55
M5Stack LLM Module で日本語対話 https://x.com/ksasao/status/1854157588247806342 #M5StackLLM
/*
* SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
* SPDX-License-Identifier: MIT
* M5Stack LLM Module で日本語対話。Serial MonitorでBoth BL&CRを設定するとよいです。
*/
#include <Arduino.h>
#include <M5Unified.h>
#include <M5ModuleLLM.h>
M5ModuleLLM module_llm;