Skip to content

Instantly share code, notes, and snippets.

@azechi
azechi / https_reverse_proxy.md
Last active April 18, 2023 09:06
Accessing WSL2 Web server via HTTPS on LAN

宅内LANでWindows機のローカルIPアドレスを固定化する

ネームサーバーでlocaldev.azechi.netを宅内LANのWin機のアドレスに設定する

localdev.azechi.netのサーバー証明書をLet's Encryptに発行してもらう

Docker Descktopを使ってnginxのhttpsリバースプロキシを実行する

@azechi
azechi / notebook.ipynb
Last active March 28, 2023 01:01
google ドライブの共有フォルダをAPIで作成する azechi/azechi#3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from struct import *
dat = None
with open("../OV767X_dat", "rb") as f:
buf = f.read()
dat = unpack(f'<{len(buf)//4}I',buf)
pin_count = 2
sample_per_word, padding = divmod(32, pin_count)
sample_count = len(dat) * sample_per_word
@azechi
azechi / dma.py
Last active January 15, 2023 00:52
Raspberry Pi Pico MicroPython Logic Analyser
from uctypes import BF_POS, BF_LEN, BFUINT32, addressof, struct
# control register structure
DMA_CTRL_LAYOUT = {
"AHB_ERROR": 31<<BF_POS | 1<<BF_LEN | BFUINT32,
"READ_ERROR": 30<<BF_POS | 1<<BF_LEN | BFUINT32,
"WRITE_ERROR": 29<<BF_POS | 1<<BF_LEN | BFUINT32,
"BUSY": 24<<BF_POS | 1<<BF_LEN | BFUINT32,
"SNIFF_EN": 23<<BF_POS | 1<<BF_LEN | BFUINT32,
@azechi
azechi / dma.py
Last active January 10, 2023 00:40
LEDマトリクスに流れる文字を表示する
from uctypes import BF_POS, BF_LEN, BFUINT32, addressof, struct
# control register structure
DMA_CTRL_LAYOUT = {
"AHB_ERROR": 31<<BF_POS | 1<<BF_LEN | BFUINT32,
"READ_ERROR": 30<<BF_POS | 1<<BF_LEN | BFUINT32,
"WRITE_ERROR": 29<<BF_POS | 1<<BF_LEN | BFUINT32,
"BUSY": 24<<BF_POS | 1<<BF_LEN | BFUINT32,
"SNIFF_EN": 23<<BF_POS | 1<<BF_LEN | BFUINT32,
"BSWAP": 22<<BF_POS | 1<<BF_LEN | BFUINT32,
@azechi
azechi / Pico_8LED_74HC595_PIO_DMA.py
Created October 27, 2022 00:21
MicroPython, Raspberry Pi Pico PIO, DMA, 74HC595, 8 LED Chaser
from rp2 import PIO, asm_pio, StateMachine
from time import sleep_ms, sleep, sleep_us
from machine import Pin, mem32
from sys import byteorder
from uctypes import addressof, struct
import pio
import dma
@micropython.viper
@azechi
azechi / Pico_DMA_CHAIN_PWM_LED_fade.py
Created October 21, 2022 11:08
Raspberry Pi Pico Micropython PWM DMA CHAIN LED fade
from uctypes import *
from machine import Pin, PWM, mem32
from sys import byteorder
# control register structure
DMA_CTRL_LAYOUT = {
"AHB_ERROR": 31<<BF_POS | 1<<BF_LEN | BFUINT32,
"READ_ERROR": 30<<BF_POS | 1<<BF_LEN | BFUINT32,
"WRITE_ERROR": 29<<BF_POS | 1<<BF_LEN | BFUINT32,
"BUSY": 24<<BF_POS | 1<<BF_LEN | BFUINT32,
@azechi
azechi / Pico_DMA_RING_PWM_LED_fade.py
Last active October 21, 2022 02:57
Raspberry Pi Pico Micropython PWM DMA RING LED fade
from uctypes import *
from machine import Pin, PWM, mem32
# control register structure
DMA_CTRL_LAYOUT = {
"AHB_ERROR": 31<<BF_POS | 1<<BF_LEN | BFUINT32,
"READ_ERROR": 30<<BF_POS | 1<<BF_LEN | BFUINT32,
"WRITE_ERROR": 29<<BF_POS | 1<<BF_LEN | BFUINT32,
"BUSY": 24<<BF_POS | 1<<BF_LEN | BFUINT32,
"SNIFF_EN": 23<<BF_POS | 1<<BF_LEN | BFUINT32,
@azechi
azechi / study.code-workspace.jsonc
Last active October 21, 2022 21:28
RPi Pico + picoprobe + WSL2 + VSCode
{
"folders": [
{
"uri": "vscode-remote://wsl+debian/home/azechi/projects/pico/study"
}
],
"remoteAuthority": "wsl+Debian",
"settings": {
"task.allowAutomaticTasks": "on"
},
@azechi
azechi / call_api_using_signed_jwt.ts
Created June 7, 2022 01:08
Call Firebase Admin APIs in Cloudflare Workers
export interface Env {
project_id: string;
private_key: string;
client_email: string;
private_key_id: string;
}
export default {
async fetch(
_request: Request,