Skip to content

Instantly share code, notes, and snippets.

View estshorter's full-sized avatar

estshorter estshorter

View GitHub Profile
@estshorter
estshorter / caller.py
Last active March 9, 2023 14:19
nanobind sample
import numpy as np
import my_ext
a = np.arange(0, 8, dtype=np.uint8).reshape(4, 2)
my_ext.inspect(a)
print("--------\n")
my_ext.prepare()
b = my_ext.calc(a)
@estshorter
estshorter / identicon.py
Last active April 29, 2022 00:22
identicon
import hashlib
import itertools
from colorsys import hls_to_rgb
import numpy as np
from PIL import Image, ImageShow
INPUT = "1430311"
PIXEL = 70 # 1ピクセルのサイズ
@estshorter
estshorter / snippets.rs
Last active September 19, 2021 13:51
rust snippets
// https://maguro.dev/debug-macro/
macro_rules! debug {
($($a:expr),* $(,)*) => {
#[cfg(debug_assertions)]
eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
};
}
// https://kuretchi.hateblo.jp/entry/rust_nested_vec
macro_rules! nested_vec {
@estshorter
estshorter / any.cpp
Last active April 17, 2021 00:18
c++ any implementation
// http://staryoshi.hatenablog.com/entry/2015/10/27/173925
#include <iostream>
#include <memory>
class Any {
private:
struct base {
virtual std::type_info const& type() const { return typeid(nullptr); }
virtual std::unique_ptr<base> clone() const { return nullptr; }
};
@estshorter
estshorter / config.h
Last active October 16, 2021 15:17
ymd09
/*
Copyright 2020 Patrick Fruh
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@estshorter
estshorter / arnold-orbit.py
Created February 2, 2021 12:55
arnold orbit
from functools import partial
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import solve_ivp
def U(r):
return 0.5 * r ** 3
@estshorter
estshorter / argononed.py
Last active November 12, 2020 13:25
argononed.py
#!/usr/bin/python3
import os
import time
from threading import Thread
import RPi.GPIO as GPIO
import smbus
rev = GPIO.RPI_REVISION
@estshorter
estshorter / update-mb.rs
Last active January 28, 2020 12:04
Rust script for downloading and applying MusicBee Patches from https://getmusicbee.com/patches/
use std::fs::{self, File};
use std::io::{self, stdout, BufWriter, ErrorKind, Write};
use std::path::PathBuf;
use std::process::Command;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use std::time::SystemTime;
use chrono::{DateTime, Local, TimeZone, Utc};
@estshorter
estshorter / TqdmLoggingHandler.py
Last active December 31, 2019 05:13
TqdmLoggingHandler
import logging
import tqdm
class TqdmLoggingHandler(logging.Handler):
# https://stackoverflow.com/questions/38543506/change-logging-print-function-to-tqdm-write-so-logging-doesnt-interfere-wit
def __init__(self, level=logging.NOTSET):
super().__init__(level)
def emit(self, record):
@estshorter
estshorter / test-logging.py
Last active January 3, 2020 11:39
script for logging
import contextlib
import datetime
import time
import logging
from logging.handlers import MemoryHandler
import sys
from typing import Any, Callable, Iterator, MutableMapping
from tqdm import tqdm
import toml