This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if ! command -v fromdos > /dev/null 2>&1; then | |
sudo apt update && sudo apt install -y tofrodos | |
fi | |
grep --exclude-dir=".git" -URIl ^M . | xargs fromdos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set fencs=ucs-bom,utf-8,euc-kr,default,latin1 | |
set ai " autoindent | |
"set ar " autoread when modified externally | |
"set aw " autowrite with specific command and modified contents | |
set bs=indent,eol,start " backspace. type :help bs | |
"set bk " backup | |
"set bdir a,b " backupdir. paths to save backup. | |
"set bsk a,b " backupskip. paths or files not to save backup | |
"set cedit=<C-f> " shortcut for history window on command-line mode | |
set cin " cindent. apply c-style indent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Licensed to the public under the Apache License 2.0. | |
# from https://github.com/openwrt/luci/blob/master/modules/luci-lua-runtime/luasrc/sys/zoneinfo/tzdata.lua | |
# ('Timezone name', 'Key') | |
# TZ='Key' date +%Y%m%d-%H%M%S | |
# for example) TZ='KST-9' date +%Y%m%d-%H%M%S for Asia/Seoul | |
TZ = ( | |
('Africa/Abidjan', 'GMT0'), | |
('Africa/Accra', 'GMT0'), | |
('Africa/Addis Ababa', 'EAT-3'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# openwrt WizFi630S 읽기 쓰기 테스트 | |
echo "----------------------------" | |
date | |
FILE_COUNT=$(df -h / | awk -F'[^0-9.]+' 'NR==2{print int($4)}') | |
for i in `seq 1 $FILE_COUNT`; do | |
dd if=/dev/urandom of=test_file_$i.bin bs=1M count=1 > /dev/null 2>&1 | |
hash=`sha256sum test_file_$i.bin | awk '{print $1}'` | |
eval file_${i}_sha256=$hash | |
echo "File $i hash: $hash" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
from os.path import splitext, dirname, rename | |
from os import rename | |
def move_pathlib(src_full: Path): | |
# filename = "/home/pi/1709705942.jpg" | |
newname = datetime.fromtimestamp(int(src_full.stem)).strftime("%Y-%m-%d_%H-%M-%S") | |
npp = Path(pp.parent, newname).with_suffix(pp.suffix) | |
src_full.rename(npp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
from pathlib import Path | |
from typing import Optional | |
from watchdog.events import FileSystemEvent, FileSystemEventHandler | |
from watchdog.observers import Observer | |
class _EventHandler(FileSystemEventHandler): | |
def __init__(self, queue: asyncio.Queue, loop: asyncio.BaseEventLoop, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/dts-v1/; | |
/plugin/; | |
/ { | |
compatible = "brcm,bcm2835"; | |
fragment@0 { | |
target = <&spi0>; | |
__overlay__ { | |
#address-cells = <1>; | |
#size-cells = <0>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
def is_jpg(): | |
img = Path("output-2023-12-15/30661_10000000c840e868_2023-12-15_16-01-46.wav").read_bytes() | |
print("jpg" if img[0] == 0xff and img[1] == 0xd8 and img[2] == 0xff else "no jpg") | |
return True if img[0] == 0xff and img[1] == 0xd8 and img[2] == 0xff else False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import yaml | |
from pathlib import Path | |
def get_rpi_type() -> str: | |
rev = int(yaml.safe_load(Path("/proc/cpuinfo").read_text().replace("\t", "")).get("Revision"), base=16) | |
rpi_type = (rev & 0x00000FF0)>>4 if rev & 0x800000 else [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 6, 2, 3, 6, 2][rev & 0x1f] | |
rpi_model = {0: 'A', 1: 'B', 2: 'A+', 3: 'B+', 4: '2B', 6: 'CM1', 8: '3B', 9: 'Zero', 0xa: 'CM3', 0xc: 'ZeroW', 0xd: '3B+', 0xe: '3A+', 0x10: 'CM3+', 0x11: '4B', 0x12: 'Zero2W', 0x13: '400', 0x14: 'CM4', 0x15: 'CM4S', 0x17: '5',} | |
return rpi_model.get(rpi_type, "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import smbus | |
bus_number = 10 | |
def have_csicamera() -> bool: | |
# csi 카메라는 i2c 를 사용하므로 연결되어 있다면 /dev/i2c-10 이 존재 | |
return Path(f"/dev/i2c-{bus_number}").exists() |
NewerOlder