Skip to content

Instantly share code, notes, and snippets.

View yuki-koyama's full-sized avatar

Yuki Koyama yuki-koyama

View GitHub Profile
@yuki-koyama
yuki-koyama / working_dir_creator.py
Last active October 8, 2019 00:53
A util function to create a working directory with a unique name
#
# MIT License
# (c) Yuki Koyama
#
import datetime
import os
def create_working_directory(base_dir_path: str = ".",
@yuki-koyama
yuki-koyama / log-normal.py
Last active September 18, 2025 14:45
Plotting log-normal probability distributions with varying parameters (Python 3.6+)
# MIT License
# (c) Yuki Koyama
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.cm import ScalarMappable
from matplotlib.colors import Normalize
import seaborn as sns
import math
@yuki-koyama
yuki-koyama / map.cpp
Last active August 1, 2019 11:03
C++ "map" function for arrays using C++14 features [MIT License]
#include <vector>
#include <algorithm>
template<class T, class Func>
auto Map(const std::vector<T>& input_array, Func op)
{
std::vector<decltype(op(input_array.front()))> result_array;
std::transform(input_array.begin(), input_array.end(), std::back_inserter(result_array), op);
return result_array;
}