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() |
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
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html | |
# First of all you need to have a clean clone of the source repository so we didn't screw the things up. | |
git clone git://server.com/my-repo1.git | |
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command | |
git filter-branch --subdirectory-filter your_dir -- -- all | |
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command. |
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 time | |
import asyncssh | |
import asyncio | |
params = range(10) | |
async def run(): | |
async with asyncssh.connect("localhost", 8090, username="tester", password="t35t3r", known_hosts=None) as conn: | |
for param in params: | |
await conn.create_process(f"nohup very_very_long_run.sh {param} &") |
NewerOlder