Skip to content

Instantly share code, notes, and snippets.

@saasan
saasan / show_toast.js
Created December 25, 2021 15:45
Vanilla JSでトースト
function generateToastHTML(message) {
return `
<div class="_toast">
<style scoped>
._toast
{
position: fixed;
right: 2rem;
bottom: 0;
padding: 1rem;
@saasan
saasan / post_slack.sh
Created May 20, 2021 14:57
Slackへ通知するシェルスクリプト
#!/bin/bash
WEBHOOK_URL=https://hooks.slack.com/services/xxxxxxxxxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx
post_slack() {
echo "payload={\"text\": \"$(cat)\"}" | curl -s -S -X POST -d @- ${WEBHOOK_URL}
}
echo "<!here>\nhoge\nfuga" | post_slack
@saasan
saasan / m5stickc-bluetooth-keyboard-macro.ino
Last active April 4, 2021 07:50
M5StickC + ESP32-BLE-Keyboard ライブラリでキーボードマクロ
#include <vector>
#include <M5StickC.h>
#include <BleKeyboard.h>
// -----------------------------------------------------------------------------
// 定数
// -----------------------------------------------------------------------------
// 電源ボタンが1秒未満押された
const uint8_t AXP_WAS_PRESSED = 2;
// キーと待ち時間の構造体
@saasan
saasan / m5stickc-esp8266audio-progmem.ino
Created June 17, 2020 10:48
M5StickC + Speaker Hat で ESP8266Audio ライブラリを使用して MP3 ファイルを再生する (PROGMEM)
#include <M5StickC.h>
#include "FS.h"
#include "SPIFFS.h"
#include "AudioFileSourcePROGMEM.h"
#include "AudioGeneratorMP3.h"
#include "AudioOutputI2S.h"
// オーディオファイル名
const char AUDIO_FILE_NAME[] = "/hoge.mp3";
@saasan
saasan / m5stickc-esp8266audio-spiffs.ino
Created June 17, 2020 10:43
M5StickC + Speaker Hat で ESP8266Audio ライブラリを使用して MP3 ファイルを再生する
#include <M5StickC.h>
#include "FS.h"
#include "SPIFFS.h"
#include "AudioFileSourceSPIFFS.h"
#include "AudioGeneratorMP3.h"
#include "AudioOutputI2S.h"
// オーディオファイル名
const char AUDIO_FILE_NAME[] = "/hoge.mp3";
@saasan
saasan / m5stickc-spiffs-wav.ino
Last active June 7, 2020 15:06
M5StickC + Speaker Hat で SPIFFS から読み込んだ WAV ファイルを再生する
#include <vector>
#include <M5StickC.h>
#include "FS.h"
#include "SPIFFS.h"
// WAVファイル名
const char WAVE_FILE_NAME[] = "/hoge.wav";
// スピーカー出力ピンの番号
const uint8_t SPEAKER_PIN = GPIO_NUM_26;
@saasan
saasan / m5stickc-sound.ino
Last active May 24, 2020 17:26
M5StickC + Speaker Hat で音声データを再生する
#include <M5StickC.h>
// スピーカー出力ピンの番号
const uint8_t SPEAKER_PIN = GPIO_NUM_26;
// LOWでLED点灯、HIGHでLED消灯
const uint8_t LED_ON = LOW;
const uint8_t LED_OFF = HIGH;
// PWM出力のチャンネル
const uint8_t PWM_CHANNEL = 0;
@saasan
saasan / m5stickc-ledspk.ino
Last active May 17, 2020 10:03
M5StickCでボタンを押したらLED点灯とSpeaker Hatを鳴らす
#include <M5StickC.h>
// スピーカー出力ピンの番号
const int SPEAKER_PIN = GPIO_NUM_26;
// LOWでLED点灯、HIGHでLED消灯
const int LED_ON = LOW;
const int LED_OFF = HIGH;
const int freq = 50;
const int ledChannel = 0;
@ECHO OFF
ECHO "500ミリ秒寝ます"
powershell -Command "sleep -m 500"
ECHO "起きました"
PAUSE
{% if include.tag %}
{% assign filter = include.tag %}
{% else %}
{% if page.tags %}
{% assign filter = page.tags.first %}
{% endif %}
{% endif %}
{% if filter %}
<ul class="tag-list">