Skip to content

Instantly share code, notes, and snippets.

View kamiaka's full-sized avatar
💭
living

Shinya Kamiaka kamiaka

💭
living
View GitHub Profile
@kamiaka
kamiaka / duration.ts
Last active June 28, 2021 23:16
Convert time durations on TypeScript (JavaScript)
export class DurationUnit {
constructor(public readonly value: number, public readonly name: string) {}
}
export const nanoSecond = new DurationUnit(1, 'ns');
export const microSecond = new DurationUnit(1000 * nanoSecond.value, 'µs');
export const milliSecond = new DurationUnit(1000 * microSecond.value, 'ms');
export const second = new DurationUnit(1000 * milliSecond.value, 's');
export const minute = new DurationUnit(60 * second.value, 'm');
export const hour = new DurationUnit(60 * minute.value, 'h');
@kamiaka
kamiaka / normalizeUTF8MacKana.php
Last active July 26, 2022 10:29
Replace Japanese Kana from UTF-8-MAC to UTF-8 for any env.
<?php
/**
* Replace Japanese Kana from UTF-8-MAC to UTF-8 for any env.
*
* code is generated
*
* @param string utf-8-mac string
* @return string utf-8 string
*/
@kamiaka
kamiaka / convert_kana.js
Last active August 3, 2023 03:50
JS Convert "Kana" one from another (zen-kaku, han-kaku and more)
/**
* Convert "Kana" one from another
* (zen-kaku, han-kaku and more)
*
* @param string str
* @param string option (optionaly)
* @return string converted string
*/
function convert_kana (str, option) {
option = option || "KV";