Skip to content

Instantly share code, notes, and snippets.

View ciscorn's full-sized avatar
🛌
rehab

Taku Fukada ciscorn

🛌
rehab
View GitHub Profile
@ciscorn
ciscorn / tide_main.rs
Last active January 24, 2025 06:28
tide, tidal, 天文潮位
///
///
/// 参考: https://www1.kaiho.mlit.go.jp/kenkyu/report/rhr60/rhr60_r_01.pdf
/// 潮汐表の計算について 海洋情報部研究報告 第60号 令和4年3月18日
use chrono::{Datelike, NaiveDate};
/// 各分潮の角速度 (度/時)
const OMEGAS: [f64; 60] = [
0.0410686, 0.0821373, 0.5443747, 1.0158958, 1.0980331, 12.8542862, 12.9271398, 13.3986609,
13.4715145, 13.9430356, 14.0251729, 14.4920521, 14.5695476, 14.9178647, 14.9589314, 15.0000000,
@ciscorn
ciscorn / build_wgrib2.sh
Created August 3, 2024 11:10
Build wgrib2 on macOS
brew install libomp netcdf
export OpenMP_ROOT=$(brew --prefix)/opt/libomp
cd wgrib2-3.3.0/
mkdir -p build
cd build
cmake .. -DUSE_NETCDF3=0 -DUSE_NETCDF4=1
import math
import numpy as np
from matplotlib import pyplot as plt
def webMercatorToLngLat(mx: float, my: float) -> tuple[float, float]:
lng = (mx * 2 - 1) * 180.0
lat = (my * 2 - 1) * 180.0
lat = (
-180
@ciscorn
ciscorn / plot_ses_send_stats.py
Created October 24, 2021 12:25
Plot Amazon SES Send Statistics
import boto3
from datetime import datetime, timedelta
import zoneinfo
import pandas
from matplotlib.dates import DateFormatter
import matplotlib.pyplot as plt
JST = zoneinfo.ZoneInfo("Asia/Tokyo")
@ciscorn
ciscorn / unicode_normalization.md
Last active July 25, 2024 06:24
Normalizing Unicode strings in Python / Go / Rust

Normalizing Unicode strings in Python / Go / Rust

NFC, NFD, NFKC, NFKD

input:

it’säå(1−2)ドブロク㍿

result:

@ciscorn
ciscorn / go-tour-web-crawler-without-mutex.go
Last active September 25, 2021 06:53
A Tour of Go: Exercise: Web Crawler without Mutex (https://tour.golang.org/concurrency/10)
package main
import (
"fmt"
)
type Fetcher interface {
Fetch(url string) (body string, urls []string, err error)
}
@ciscorn
ciscorn / circuitpython_compression.py
Last active June 27, 2023 19:21
[PoC] A more effective compression algorithm for CircuitPython's i18n strings. (merged)
from collections import Counter
import re
import huffman
class TextSplitter:
def __init__(self, words):
words.sort(key=lambda x: len(x), reverse=True)
self.words = set(words)
@ciscorn
ciscorn / matplotlib_animation_wave.py
Last active December 12, 2022 04:07
matplotlib animation:: 1-d & 2-d wave equation
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.pylab import plt
from matplotlib import animation, cm
import numpy as np
from scipy.signal import convolve, convolve2d
class Wave1D:
K = np.array([1, -2, 1])
@ciscorn
ciscorn / epub_pagertl.py
Created September 22, 2018 03:01
EPUBの見開き方向を right-to-left (縦書き用) に変える
import sys
from zipfile import ZipFile
import lxml.etree as et
for path in sys.argv[1:]:
zf = ZipFile(path, mode='a')
with zf.open('OEBPS/content.opf', mode='r') as f:
doc = et.parse(f)
@ciscorn
ciscorn / install_pillow_simd.sh
Created May 4, 2018 07:50
Install pillow-simd on Ubuntu
#!/bin/env bash
pip3 uninstall pillow
apt install \
libjpeg-turbo8-dev \
zlib1g-dev \
libtiff5-dev \
liblcms2-dev \
libfreetype6-dev \