Skip to content

Instantly share code, notes, and snippets.

View dzonesasaki's full-sized avatar

Daizo Sasaki dzonesasaki

View GitHub Profile
@dzonesasaki
dzonesasaki / spr_me_serial_rx.ino
Created December 28, 2023 07:46
a sample of Serial.read() on SubCore1 of sony spresense using Arduino-IDE
#include <MP.h>
#ifdef SUBCORE
// sub core
void setup() {
Serial.begin(115200);
MP.RecvTimeout(MP_RECV_POLLING);
MP.begin();
MP.EnableConsole();
//ref to https://developer.sony.com/spresense/development-guides/arduino_developer_guide_en.html#_mp_class
@dzonesasaki
dzonesasaki / runnue.py
Created December 15, 2023 02:32
run nue-asr with a long wav file on CPU
import nue_asr
import librosa
import numpy as np
import sys
# pip
# torch
# transformers
# git+https://github.com/rinnakk/nue-asr
@dzonesasaki
dzonesasaki / conv_holidays_tsv.py
Last active January 4, 2023 02:13
converting holiday list from syukujitsu.csv to date tsv only this year
import datetime
import os
mojico=['shift_jis','cp932','utf-8']
myurl='https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv'
fnameL='syukujitsu.csv'
# forlat: Y/M/D,name
if os.path.exists(fnameL):
with open(fnameL, 'rt',encoding=mojico[0]) as fid:
txtorg = fid.read()
@dzonesasaki
dzonesasaki / calc_epochtime.c
Created December 8, 2022 07:16
calc unix epoch time froom date using C
//gcc calc_epochtime.c
#include <stdio.h>
#include <stdint.h>
#include <time.h>
struct tm gtmCurrentTime;
void intoDatetime(uint16_t uiYearAc, uint8_t uiMonthOrg, uint8_t uiDate, uint8_t uiHour, uint8_t uiMinute, uint8_t uiSecond ,struct tm *ptm){
//usage : intoDatetime( 2022,12,6,17,30,5);
@dzonesasaki
dzonesasaki / makeData_2cluster_LCGs.tsv
Last active December 8, 2022 01:14
make 2 cluster sample data using LCG and Box-Muller for SpreadSheet
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 13 columns, instead of 12. in line 1.
"param1" "param2" "param3" "LCG_1" "LCG_2" "LCG_3" "BoxMuller_I" "BoxMuller_Q" "Quantize" "X" "Y"
"multiplier" 3 20 21 3 50 12 =SQRT(-2*LN(E2/B$4+2^(-10)))*COS(2*PI()*F2/C$4) =SQRT(-2*LN(E2/B$4+2^(-10)))*SIN(2*PI()*F2/C$4) =rounddown(g2/D$4+0.5) =J2*B$10+H2*B$11 =J2*C$10+I2*C$11
"increment" 5 11 13 =MOD(E2*B$2+B$3,B$4) =MOD(F2*C$2+C$3,C$4) =MOD(G2*D$2+D$3,D$4)
"modulus" 101 103 105
"usage : copy E3,F3,G3 to bottom cell"
"modulus are equal to max length"
"E2,F2,G2 are initial value"
"H2,I2 are Box-Mullr method"
"J2 is quantization"
"K2,L2 are X-Y plot example" 1 1
@dzonesasaki
dzonesasaki / esp32_rtc_manual_setting.ino
Last active December 8, 2022 05:21
a sample of manual setting the local time on ESP32 using arduino-IDE
#include "lwip/apps/sntp.h"
struct tm gtmCurrentTime;
//#define DEBUGON
void fixDatetime(){
gtmCurrentTime.tm_year = 2022 - 1900;
gtmCurrentTime.tm_mon = 12 -1;
gtmCurrentTime.tm_mday = 6;
@dzonesasaki
dzonesasaki / cnsNAudioTest221031.cs
Created October 31, 2022 08:25
NAudio test using c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NAudio.Wave;
namespace cnsNAudioTest221031
{
internal class Program
@dzonesasaki
dzonesasaki / splitpdf.py
Created August 18, 2022 06:11
splitting each pages for pdf file using PyPDF2
#!python3
#splitpdf.py
#ref to : https://fastclassinfo.com/entry/python_pdf_split/
import PyPDF2
import sys
fnameL = 'a.pdf'
if len(sys.argv)>1:
fnameL = sys.argv[1]
@dzonesasaki
dzonesasaki / read_NMEA_tst.py
Created August 2, 2022 08:13
get lat,lon from NMEA message of GPS module GYSFDMAXB , GYSFFMANC
#!python3
# read_NMEA_tst.py
# hardware : GYSFFMANC :GYSFDMAXB : MT3333 : https://akizukidenshi.com/catalog/g/gK-13850/
# only for JAPAN
TIME_ZONE = 9
fLat = 0
fLon = 0
fAlt = 0
@dzonesasaki
dzonesasaki / tcp_rx_tst.py
Created June 2, 2022 02:23
a sample of TCP tx/rx using python3
#!python3
#tcp_rx_tst.py
# receive data from tcp socket
import socket
import time
from contextlib import closing
host = '127.0.0.1'
port = 55430