Skip to content

Instantly share code, notes, and snippets.

View kobaatsu's full-sized avatar

KOBAYASHI atsushi kobaatsu

View GitHub Profile
@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 / month.json
Last active November 9, 2022 09:23
月の配列 #utils
[
{
"en": "january",
"ja": "1月"
},
{
"en": "february",
"ja": "2月"
},
{
@kobaatsu
kobaatsu / log.php
Last active May 22, 2023 01:32
functions.phpでのログ取得 #wordpress
<?php
ob_start();
print_r($prev);
$test = ob_get_contents();
ob_end_clean();
error_log('ログ: ' . $test);
// 検索正規表現
@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 / 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 / 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);
};
@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; // 要素からスタイルを取得
# 例2017年01月01日 00時00分00秒より、古い記事を削除
DELETE FROM wp_posts WHERE post_date < '2017-01-01 00:00:00';
# 最小の記事IDを確認し、メモを取る
select ID,post_date from wp_posts ORDER BY ID ASC limit 5 ;
# wp_postmetaテーブルからのデータ削除(最小の記事IDが140679の場合)
DELETE FROM wp_postmeta WHERE post_id < 140679;
@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 / circle-num.styl
Created July 8, 2019 08:56
[丸数字リスト] まず使わない
nums = ('\2780' '\2781' '\2782' '\2783' '\2784' '\2785' '\2786' '\2787' '\2788' '\2789')
for n, i in nums
li:nth-of-type({i+1})::before
content n