Skip to content

Instantly share code, notes, and snippets.

View atotto's full-sized avatar
🌏
Working from home

Ato Araki atotto

🌏
Working from home
View GitHub Profile
@atotto
atotto / fstab2uml.sh
Created October 5, 2021 12:50
generate plantuml text from fstab with systemd mount config
#!/bin/bash -e
# usage
# cd /etc/; fstab2uml
grep -v -e '^\s*#' -e '^\s*$' fstab | sed -r 's|(^[^ ]+) *([^ ]*) .*|database "\2" <<\1>>|g'
grep -v -e '^\s*#' -e '^\s*$' fstab | grep x-systemd | tr -s ' ' | cut -d ' ' -f 1,2 | xargs -n 1 -I {} bash -c 'grep ^$(echo {}| cut -d " " -f 1) fstab | tr "," "\n" | tr " " "\n" | grep "x-systemd\." | sed -r "s|x-systemd\.(.*)=(.*)|[\2]: \1|" | xargs -n 1 -I [] echo "[$(echo {} | cut -d " " -f 2)] -up-> []"'
@atotto
atotto / apriltag_video_capture.py
Last active March 27, 2024 15:41
apriltag video capture example
# https://github.com/AprilRobotics/apriltag
# example image: https://github.com/AprilRobotics/apriltag-imgs/blob/master/tagStandard41h12/mosaic.png
import cv2
from apriltag import apriltag
cam = cv2.VideoCapture(0)
cv2.namedWindow("detections")
img_counter = 0
#include <M5Stack.h>
#include <WiFi.h>
#include "lwip/apps/sntp.h"
#define TFT_GREY 0x5AEB
const char *ssid = "ssid";
const char *password = "password";
@atotto
atotto / BleConnectionStatus.cpp
Last active October 19, 2020 05:05
m5-meet-keyboard
#include "BleConnectionStatus.h"
BleConnectionStatus::BleConnectionStatus(void) {
}
void BleConnectionStatus::onConnect(BLEServer* pServer)
{
this->connected = true;
BLE2902* desc = (BLE2902*)this->inputKeyboard->getDescriptorByUUID(BLEUUID((uint16_t)0x2902));
desc->setNotifications(true);
@atotto
atotto / init.el
Created July 2, 2020 01:15
simple golang editor setting for emacs
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
(when no-ssl (warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#define EPD_CS SS
GxEPD2_BW<GxEPD2_213_B73, GxEPD2_213_B73::HEIGHT> display(GxEPD2_213_B73(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0213B73
#define BAT 35
@atotto
atotto / madgwickfilter_mpu9250.ino
Created October 7, 2019 13:51
madgwickfilter + MPU9250 IMU sensor
/*
VDD ---------- 3.3V
SDA ---------- A4
SCL ---------- A5
GND ---------- GND
*/
#include "MadgwickAHRS.h" // github.com/arduino-libraries/MadgwickAHRS
#include "MPU9250.h" // github.com/bolderflight/MPU9250
@atotto
atotto / 60-ublox-m8.rules
Created September 29, 2019 08:53
/etc/udev/rules.d/60-ublox-m8.rules
SUBSYSTEM!="tty", GOTO="ublox-m8_rules_end"
ATTRS{idVendor}=="1546", ATTRS{idProduct}=="01a8", SYMLINK+="ublox-m8" MODE="0666"
LABEL="ublox-m8_rules_end"
@atotto
atotto / bind_to_device.go
Created September 26, 2019 01:30
bind to device
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"os"
"syscall"
@atotto
atotto / esc.py
Created September 18, 2019 14:56
import time
import pigpio
motor_pin = 18 # GPIO18 (pin12)
pi = pigpio.pi()
pi.set_mode(motor_pin, pigpio.OUTPUT)
pi.set_servo_pulsewidth(motor_pin, 1300)
print("please power on ESC")