Skip to content

Instantly share code, notes, and snippets.

View Akira-Hayasaka's full-sized avatar
🏠
Working from home

Akira Hayasaka Akira-Hayasaka

🏠
Working from home
View GitHub Profile
static const std::map<string, string> ISO_2_TO_3_MAP = {
{"AF", "AFG"},
{"AL", "ALB"},
{"DZ", "DZA"},
{"AS", "ASM"},
{"AD", "AND"},
{"AO", "AGO"},
{"AI", "AIA"},
{"AQ", "ATA"},
{"AG", "ATG"},
@Akira-Hayasaka
Akira-Hayasaka / comp_dates_before_1970_epoch.h
Created August 24, 2023 08:19
compare before 1970/01/01 epoch std::tm
static bool comp_dates_before_1970_epoch(const std::tm& dt1, const std::tm& dt2)
{
if (dt1.tm_year != dt2.tm_year) return dt1.tm_year < dt2.tm_year;
if (dt1.tm_mon != dt2.tm_mon) return dt1.tm_mon < dt2.tm_mon;
if (dt1.tm_mday != dt2.tm_mday) return dt1.tm_mday < dt2.tm_mday;
if (dt1.tm_hour != dt2.tm_hour) return dt1.tm_hour < dt2.tm_hour;
if (dt1.tm_min != dt2.tm_min) return dt1.tm_min < dt2.tm_min;
return dt1.tm_sec < dt2.tm_sec;
}
@Akira-Hayasaka
Akira-Hayasaka / hdr.frag
Last active June 2, 2022 07:55
hdr.frag
#version 150
uniform sampler2DRect tex;
uniform float r_for_hlg;
in vec2 texCoordVarying;
out vec4 outputColor;
// HLG OETF
vec3 hlg_oetf(vec3 E)
static string prepend_0(const int i, const int n_zero)
{
return std::string(n_zero - std::min(n_zero, (int)ofToString(i).length()), '0') + ofToString(i);
}
auto prepend_0 = [&](const int i, const int n_zero) -> string
{
return std::string(n_zero - std::min(n_zero, (int)ofToString(i).length()), '0') + ofToString(i);
};
@Akira-Hayasaka
Akira-Hayasaka / gpu_check.py
Last active July 12, 2021 00:40
ipython common
from tensorflow.python.client import device_lib
print(tf.__version__)
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
device_lib.list_local_devices()
@Akira-Hayasaka
Akira-Hayasaka / opencv.sh
Last active January 13, 2021 07:57
openFrameworks opencv apothecary for building opencv with opencv_contrib (visual studio)
#!/usr/bin/env bash
#
# OpenCV
# library of programming functions mainly aimed at real-time computer vision
# http://opencv.org
#
# uses a CMake build system
FORMULA_TYPES=( "osx" "ios" "tvos" "vs" "android" "emscripten" )
@Akira-Hayasaka
Akira-Hayasaka / install_and_setup_msys2.txt
Last active January 13, 2021 07:56
install and setup msys2 env for using openFrameworks apothecary on windows 10
https://www.msys2.org/
http://www.gaia-gis.it/gaia-sins/mingw64_how_to.html
https://github.com/git-for-windows/git/wiki/Install-inside-MSYS2-proper
pacman -S --needed base-devel
pacman -S --needed mingw-w64-i686-toolchain
pacman -S --needed mingw-w64-x86_64-toolchain
pacman -S --needed mingw-w64-i686-cmake mingw-w64-x86_64-cmake
@Akira-Hayasaka
Akira-Hayasaka / gif.cmd
Last active July 11, 2024 01:39
create gif
ffmpeg -i a.mp4 -vf "fps=10,scale=1280:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
normal
ffmpeg -i input.mov -r 10 -vf scale=640:-1 -f gif output.gif
mid
ffmpeg -i input.mov -filter_complex "[0:v] fps=10,scale=640:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" output-palette.gif
high
ffmpeg -i input.mov -filter_complex "[0:v] fps=10,scale=w=640:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" output-multiple-palette.gif
@Akira-Hayasaka
Akira-Hayasaka / functional_declarative.js
Last active October 9, 2020 07:10
functional & declarative
let sum = 0;
let numbers = [2, 4, 6, 10, 16];
for (let i = 0; i < numbers.length; i++) {
numbers[i] = numbers[i] - 1;
if (numbers[i] % 3 === 0) {
sum += numbers[i];
}
}
console.log("0", sum);
@Akira-Hayasaka
Akira-Hayasaka / curried.js
Last active October 7, 2020 05:22
currying & Function Composition (aka HOC)
// curried functions, a.k.a HOC
const witha = (extra) => (component) => (props) => {
console.log("witha", extra);
console.log("witha", component);
console.log("witha", props);
return () => component(props);
};
const withb = (extra) => (component) => (props) => {
console.log("withb", extra);
console.log("withb", component);