Skip to content

Instantly share code, notes, and snippets.

@ksasao
ksasao / hello.txt
Created February 12, 2023 15:28
Bingから見えるかテスト
Hello
@ksasao
ksasao / index.html
Last active February 24, 2025 02:24
Alternative to labeled geo intent for iOS (also works for Android) . Sample URL -> http://gist.githack.com/ksasao/bc5fc05d0676f3ec07cf8666e8236c8f/raw/[email protected],139.7670152,17z&t=Tokyo%20Sta.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Map Viewer</title>
<link rel="stylesheet" href="https://d19vzq90twjlae.cloudfront.net/leaflet-0.7.3/leaflet.css" />
<!-- reference to Leaflet JavaScript -->
<script src="https://d19vzq90twjlae.cloudfront.net/leaflet-0.7.3/leaflet.js"></script>
@ksasao
ksasao / A_OMMF_Weight.ino
Created December 3, 2022 21:42
M5Stack用はかりキット(重さユニット付き)https://www.switch-science.com/products/8014 を利用した重量取得のコードです。#OMMF2022 で利用したものです。メディアンフィルタ(中央値フィルタ)を使って、このセンサ特有のスパイク状(とびとびの値)のノイズを除去しています。
#include <M5Atom.h>
#include "BrownieClient.h"
#define PIN_DOUT 32
#define PIN_SLK 26
#define MEDIAN_FILTER_SIZE 10
static char ssid[64] = "your-ssid";
static char pass[64] = "your-password";
static char mqtt[64] = "192.168.xx.xx";
@ksasao
ksasao / atomcam2_rtspwriter.py
Last active September 1, 2023 12:51
ATOM Cam 2 の映像を RTSP で受信して1分毎にファイル名を変えて動画で保存する Python コード。詳細→ https://twitter.com/ksasao/status/1593834857536585729
# RTSPを受信して .mp4 にエンコード
# ATOM Cam 2 は 20fps が標準 (赤外カメラモードでは15fpsとなるが下記コードは未対応)
import cv2
import datetime
import os
# 日付をファイル名にする
def get_filename():
now = datetime.datetime.now()
filename = './mp4/' + now.strftime('%Y%m%d_%H%M') + '.mp4'
@ksasao
ksasao / Program.cs
Last active November 9, 2022 14:17
ゼロ埋めされた4桁の数字は円周率の小数第n位に初めて出現するか。 例えば "1415" → n=1, "6716" → n=99846
// Pi.txt は https://www.tstcl.jp/ja/randd/pi.php をコピペしたもの
string text = File.ReadAllText("Pi.txt");
// テキストの改行・空白を除く。1M桁程度ならこの実装でも余裕でしょう。
text = text.Replace("\r\n", "").Replace(" ", "");
List<string> buffer = new List<string>();
// 1M桁程度ならこの実装でも余裕でしょう。
for(int i = 0; i <= 9999; i++)
{
@ksasao
ksasao / camera.ino
Last active March 22, 2023 13:18
Spresense の HDRカメラの画像を表示するサンプルコードです。Spresense メインボードとカメラだけで動作します。拡張ボードは不要です。https://twitter.com/ksasao/status/1521667631061037056
/*
* camera.ino - Simple camera example sketch
* Copyright 2018, 2022 Sony Semiconductor Solutions Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
@ksasao
ksasao / uso.kml
Last active April 1, 2022 12:16
住所にウソを含む地名。Geolonia 住所データ https://github.com/geolonia/japanese-addresses および 地理院マップシート https://geolib.gsi.go.jp/node/2459 を利用。uso.kml を保存して 地理院地図 https://maps.gsi.go.jp/ に Drag&Dropしてください。 https://twitter.com/ksasao/status/1509864894379982848
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
<Document>
<Style id="SYMBOL2.symbolStyle">
<IconStyle>
<Icon>
<href>https://maps.gsi.go.jp/portal/sys/v4/symbols/080.png</href>
</Icon>
<scale>1</scale>
</IconStyle>
@ksasao
ksasao / Program.cs
Created February 22, 2022 13:17
A.I.VOICE Editor 外部連携API を DLL参照せずに動的に読み込んで利用するサンプルコードです。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.IO;
namespace HelloAIVOICE
@ksasao
ksasao / fs3000x3.ino
Last active February 15, 2022 13:31
Renesas FS3000 monitor with PCA9548AP. See https://twitter.com/ksasao/status/1493564005017059329
#include <M5StickCPlus.h>
#define PCA9548AP_I2C_ADDRESS 0x70
void setup()
{
M5.begin();
Wire.begin();
}
uint8_t selectI2CPort(uint8_t channel){
@ksasao
ksasao / luminometer.ino
Created February 1, 2022 16:35
M5StickC 環境光センサ Hat。ロームのBH1750FVを利用 。 https://twitter.com/ksasao/status/1488550499549065218
#include <M5GFX.h>
#include <M5StickCPlus.h>
#include <M5_BH1750FVI.h>
M5GFX display;
M5_BH1750FVI sensor;
uint16_t lux;
void setup() {