Skip to content

Instantly share code, notes, and snippets.

View kobaatsu's full-sized avatar

KOBAYASHI atsushi kobaatsu

View GitHub Profile
@kobaatsu
kobaatsu / pref.csv
Last active July 21, 2025 10:14
都道府県一覧 #utils
北海道 HOKKAIDO hokkaido
青森県 AOMORI aomori
岩手県 IWATE iwate
宮城県 MIYAGI miyagi
秋田県 AKITA akita
山形県 YAMAGATA yamagata
福島県 FUKUSHIMA fukushima
茨城県 IBARAKI ibaraki
栃木県 TOCHIGI tochigi
群馬県 GUNMA gunma
@kobaatsu
kobaatsu / log.php
Last active March 21, 2025 05:23
functions.phpでのログ取得 #wordpress
<?php
// /wp-content/debug.log にログを出力
ob_start();
print_r($prev);
$test = ob_get_contents();
ob_end_clean();
error_log('ログ: ' . $test);
@kobaatsu
kobaatsu / dustenfeld.js
Last active November 28, 2022 03:09
ダステンフェルドのシャッフル #js
// based on https://qiita.com/pure-adachi/items/77fdf665ff6e5ea22128
const shuffled = array.reduce((pre, _, i) => {
const _i = array.length - i;
const k = Math.floor(Math.random() * _i);
const _arr = [...pre];
[_arr[k], _arr[_i - 1]] = [_arr[_i - 1], _arr[k]];
return _arr;
}, array);
@kobaatsu
kobaatsu / plugins.php
Last active November 17, 2022 01:17
プラグイン一覧 #wordpress
<!-- https://nelog.jp/get_plugins -->
<textarea cols="16" rows="10">
<?php
$all = '';
//plugin.phpを読み込む
include_once ABSPATH . 'wp-admin/includes/plugin.php';
$plugins = get_plugins();
if (!empty($plugins)) {
$all .= '有効化済みのプラグイン:' . PHP_EOL;
foreach ($plugins as $path => $plugin) {
@kobaatsu
kobaatsu / padstart.js
Last active November 14, 2022 06:56
ゼロ埋め #js
// ゼロ以外でも使える #noie
// https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
const z = (i + "").padStart(2, "0");
@kobaatsu
kobaatsu / month.json
Last active November 9, 2022 09:23
月の配列 #utils
[
{
"en": "january",
"ja": "1月"
},
{
"en": "february",
"ja": "2月"
},
{
@kobaatsu
kobaatsu / yohbi.json
Last active November 9, 2022 09:17
曜日の配列 #utils
[
{"day":"sun","yohbi":"日"},
{"day":"mon","yohbi":"月"},
{"day":"tue","yohbi":"火"},
{"day":"wed","yohbi":"水"},
{"day":"thu","yohbi":"木"},
{"day":"fri","yohbi":"金"},
{"day":"sat","yohbi":"土"}
];
@kobaatsu
kobaatsu / gcd.js
Last active October 12, 2022 03:43
ユークリッド互除法 #js
// https://blog.ver001.com/javascript-aspect-ratio/
const getGCD = (a, b) => (b === 0 ? a : getGCD(b, a % b));
const getAspectRatio = (w, h) => {
const gcd = getGCD(w, h);
return `${w / gcd}:${h / gcd}`;
};
@kobaatsu
kobaatsu / getNumberLines.js
Last active August 15, 2022 09:59
行数のカウント #js
/**
* https://shanabrian.com/web/javascript/element-get-number-of-lines.php
* 要素内にあるテキストの行数を取得
* @param {Element} element 取得するもとの要素
* @return {Number} 行数を返す
*/
var getNumberLines = function (element) {
var fontSize = 0,
count = 0,
calcResult = 0; // 要素からスタイルを取得
@kobaatsu
kobaatsu / imageUrl.js
Last active August 15, 2022 09:58
正規表現 #js #note
// https://regex101.com/r/gXDhi9/1
isValidImageUrl = (url) => {
const imgReg =
/^(?:(?<scheme>[^:/?#]+):)?(?:\/\/(?<authority>[^/?#]*))?(?<path>[^?#]*\/)?(?<file>[^?#]*\.(?<extension>[Jj][Pp][Ee]?[Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Ss][Vv][Gg]|[Ww][Ee][Bb][Pp]))(?:\?(?<query>[^#]*))?(?:#(?<fragment>.*))?$/gm;
return imgReg.test(url);
};