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 | |
# Convert Japanese era (JE) to/from Common Era (CE) Calendar | |
# c.f. https://www.jacar.archives.go.jp/apps/help/chronological_table.html | |
display_help_message() { | |
cat <<EOF | |
$0, Convert Japanese era (JE) to/from Common Era (CE) Calendar | |
usage: $0 [MTSHR] <year jp> | |
$0 <year ce> |
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 python3 | |
def country2region(country_name_jp): | |
"""Return region name of the country. (Japanese version) | |
""" | |
country_name_jp = country_name_jp.strip() | |
return country_region_200_ja[country_name_jp] | |
country_region_200_ja = { |
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
{ | |
"アイスランド": "欧州", | |
"アイルランド": "欧州", | |
"アゼルバイジャン": "欧州", | |
"アフガニスタン": "中東", | |
"アラブ首長国連邦": "中東", | |
"アルジェリア": "アフリカ", | |
"アルゼンチン": "中南米", | |
"アルバニア": "欧州", | |
"アルメニア": "欧州", |
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 python3 | |
import json | |
from io import StringIO | |
import pandas as pd | |
def csv_to_json(csv_in): | |
"""Convert an n*2 array (CSV) to a JSON file. | |
""" | |
# Load CSV data |
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 python3 | |
from pathlib import Path | |
from sys import exit | |
from hashlib import md5 | |
from datetime import datetime | |
from time import sleep | |
import pandas as pd | |
import requests |
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 | |
# c.f. CSVと親しくなるAWK術 | |
# https://future-architect.github.io/articles/20210330/#複数のCSVファイルを1ファイル結合する | |
echo | |
echo 'Concatenate CSVs \033[93mWITH HEADERs\033[0m and deduplicate HEADERs.' | |
read -rp 'glob pattern? >> ' pattern |
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 | |
# Rename files/directories in the current directory. | |
# Unlike bash, sh doesn't implement [[ operator. Thus, the extension is intentionally set to .bash. | |
# Help message | |
if [[ $1 == '' || $1 == '--help' || $2 == '' ]]; then | |
{ | |
echo 'usage: renamer \033[3mpattern repl\033[0m\n' | |
exit | |
} |
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
library(tidyverse) | |
library(DBI) | |
# RSQLite is a DBI-compatible interface which means | |
# you primarily use functions defined in the DBI package, | |
# so you should always start by loading DBI, not RSQLite: | |
# c.f. <https://cran.r-project.org/web/packages/RSQLite/vignettes/RSQLite.html> | |
fetcher <- function(query_in) { | |
mydb <- dbConnect(RSQLite::SQLite(), "/somewhere/my_db.sqlite3") |
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
// | |
// timedelta c++ version w/chrono | |
// | |
#include <iostream> | |
#include <chrono> | |
#include <ctime> | |
#include <iomanip> | |
// for the header |
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
# CLion on a Mac with Homebrew-ed Boost C++ Libraries needs the following CMake script. | |
# c.f. https://intellij-support.jetbrains.com/hc/en-us/community/posts/206607995/comments/360002127239 | |
# c.f. https://formulae.brew.sh/formula/boost | |
# Ubuntu(sudo apt install libboost-all-dev)/CLion doesn't need the script. | |
set(Boost_INCLUDE_DIR /usr/local/Cellar/boost/1.83.0/include) | |
set(Boost_LIBRARY_DIR /usr/local/Cellar/boost/1.83.0/lib) | |
find_package(Boost 1.83.0) | |
include_directories(${Boost_INCLUDE_DIR}) |
NewerOlder