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
@Akira-Hayasaka
Akira-Hayasaka / gist:026b7c7ae611bc7485e4
Created April 5, 2015 00:39
osx shutdown, restart, sleep script
Shut down without showing a confirmation dialog:
osascript -e 'tell app "System Events" to shut down'
Shut down after showing a confirmation dialog:
osascript -e 'tell app "loginwindow" to «event aevtrsdn»'
Restart without showing a confirmation dialog:
osascript -e 'tell app "System Events" to restart'
Restart after showing a confirmation dialog:
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 / gif.cmd
Last active July 27, 2023 07:02
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 / gist:4949752
Last active June 23, 2022 20:15
c++ copy vector into deque
std::copy(vector.begin(), vector.end(), std::inserter(deque, deque.end()));
@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);
};
// if shaper is 1, you get linear output like ofMap.
// shaper > 1 means non linear steps weighted towards the start.
// 0 < shaper < 1 means non linear steps weighted towards the end.
auto shaped_map = [&](
float val,
float inMin, float inMax,
float outMin, float outMax,
float shaper) -> float
{
// (1) convert to pct (0-1)
@Akira-Hayasaka
Akira-Hayasaka / winInst.txt
Last active September 16, 2021 07:33
windows インスタレーション用設定
- windowsはオフラインアカウントでセットアップ
- ネットワークにつなぐ
- 識別されてないネットワーク問題
http://www.projectgroup.info/tips/Windows/comm_0064.html
- windowsのライセンス認証
- windowsをアップデートする
@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()