Skip to content

Instantly share code, notes, and snippets.

View Enchan1207's full-sized avatar

Enchan Enchan1207

View GitHub Profile
@Enchan1207
Enchan1207 / README.md
Created March 22, 2024 00:36
EDID extracted from MacBook Retina 12inch, 2017

Overview

EDID情報の比較
(ioreg はコマンド ioreg の出力から得られたもの、 get-edid はパッケージread-edidget-edidの出力から得られたもの)

MD5 (get-edid.bin) = 8f43572ff6d8d6097d4d7313ee7c4daf
@Enchan1207
Enchan1207 / convert_image_to_binary.py
Last active February 10, 2024 07:12
2値画像をグラフィック液晶に反映可能な形式に変換する
#
#
#
import sys
from typing import List
import numpy as np
from PIL import Image
file_path = "/path/to/image.png"
@Enchan1207
Enchan1207 / check_if_venv.py
Created July 5, 2023 05:12
仮想環境かどうか判定する
def is_virtual_env() -> bool:
"""venv, virtualenvその他仮想環境で動いているかどうかを調べる
Returns:
bool: 仮想環境ならTrue、そうでなければFalse
"""
# base_prefixはインストール元のpython, prefixは仮想環境のpythonを指すパス
# - https://docs.python.org/ja/3/library/sys.html#sys.base_prefix
# - https://docs.python.org/ja/3/library/sys.html#sys.prefix
# これらの値が同一でなければ、仮想環境での実行と判断する
@Enchan1207
Enchan1207 / splitbytes.py
Created July 1, 2023 08:50
bytes型を任意bitで分割・結合する
#
# bytes型を任意bitで分割・結合する
#
import functools
from typing import List
def splitbytes(data: bytes, n_sep: int) -> bytes:
"""bytes型のデータを任意のビット数ごとに分割する
@Enchan1207
Enchan1207 / abst.py
Created June 23, 2023 04:26
abstract class in abstract class
#
#
#
from abc import ABCMeta, abstractmethod
class Meta(metaclass=ABCMeta):
class MetaChildren(metaclass=ABCMeta):
@Enchan1207
Enchan1207 / ViewController.swift
Created December 21, 2022 14:28
DocumentPickerを使用したPDFビューア
//
// ViewController.swift
// PDFEx
//
// Created by EnchantCode on 2020/12/26.
//
import UIKit
import PDFKit
import UniformTypeIdentifiers
@Enchan1207
Enchan1207 / log.sh
Created September 17, 2022 01:25
いい感じにANSIエスケープを除去してくれるログ出力関数 for bash
#!/bin/bash
# ログを出力する.
# 第一引数がメッセージとして扱われ、
# stdoutがttyでなければカラーエスケープシーケンスを除去する
function log(){
if [ -t 1 ]; then
printf "$1\n"
else
printf "$1\n" | sed -r 's/\x1b\[[0-9]*(;[0-9]*)*m//g'
@Enchan1207
Enchan1207 / main.py
Created February 27, 2022 13:02
ディレクトリの再帰検索
def listdir_r(path: str) -> List[str]:
"""ディレクトリの再帰検索
Args:
path (str): 検索対象
Returns:
List[str]: 検索結果
"""
@Enchan1207
Enchan1207 / nabeatsu.py
Created December 17, 2021 01:15
ナベアツをつくろう
#
# イテレータ上手く使えばナベアツを錬成できるのでは?
#
import sys
from typing import Optional, Union
class Nabeatsu:
@Enchan1207
Enchan1207 / custom_range.py
Created December 17, 2021 00:49
range()を作る
#
# Custom range() implementation
#
class CustomRange:
def __init__(self, start: int, end: int, pace: int = 1) -> None:
self.end = end
self.pace = pace