Skip to content

Instantly share code, notes, and snippets.

View ksuzushima's full-sized avatar

ksuzushima

  • Tokyo
View GitHub Profile
@ksuzushima
ksuzushima / nodebrew_DS_Store.md
Last active June 23, 2021 11:54
nodebrew ls で `Use of uninitialized value $a1 in numeric comparison (<=>) at /Users/(ユーザ)/.nodebrew/current/bin/nodebrew line 675.` が出る #nodebrew
$ nodebrew ls

Use of uninitialized value $b1 in numeric comparison (<=>) at /usr/local/bin/nodebrew line 678.
Use of uninitialized value $a1 in numeric comparison (<=>) at /usr/local/bin/nodebrew line 678.
Use of uninitialized value $a1 in numeric comparison (<=>) at /usr/local/bin/nodebrew line 678.
.DS_Store
v6.3.1
v7.10.0
v8.2.1
@ksuzushima
ksuzushima / wp_add_custom_meta_box.php
Created May 8, 2018 07:55
Basic usage for add_meta_box #wordpress #add_meta_box
<?php
/**
* Basic usage add_meta_box
* @link https://developer.wordpress.org/reference/functions/add_meta_box/
*/
add_action( 'add_meta_boxes', 'add_custom_meta_box' );
/**
@ksuzushima
ksuzushima / wp_status404.php
Created May 7, 2018 06:43
Redirect 404 status #wordpress
<?php
/**
* @link https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect
* @link https://developer.wordpress.org/reference/classes/wp_query/set_404/
*/
function status404() {
if ( is_singular( 'hoge' ) ) {
global $wp_query;
$wp_query->set_404();
@ksuzushima
ksuzushima / zero-padding.js
Created April 26, 2018 02:01
Zero Padding in JavaScript
function zeroPadding(number, length) {
return (Array(length).join('0') + number).slice(-length);
}
zeroPadding(240, 10) // 0000000240
/**
* String.prototype.padStart()
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
@ksuzushima
ksuzushima / detect_attachment_id.php
Created April 2, 2018 05:39 — forked from minodisk/detect_attachment_id.php
WordPressで画像のURLからアタッチメントIDを取得する
<?php
/**
* 画像のURLのサイズ違いのURLを取得する
*
* @param string $url 画像のURL
* @param string $size 画像のサイズ (thumbnail, medium, large or full)
*/
function get_attachment_image_src($url, $size) {
$image = wp_get_attachment_image_src(get_attachment_id($url), $size);
@ksuzushima
ksuzushima / php-brew-install-composer.md
Created March 29, 2018 02:12
How to brew install Composer.

PHP version

$ php -v
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
@ksuzushima
ksuzushima / tree-command.md
Last active May 11, 2018 08:51
treeコマンドの日本語文字化け #tree
tree -N
@ksuzushima
ksuzushima / jquery.3.3_addclass.html
Created January 29, 2018 03:30
jQuery 3.3 can add and remove multiple classes.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>jQuery 3.3 addClass, removeClass</title>
</head>
<body>
@ksuzushima
ksuzushima / mt_image_url_width.md
Created January 25, 2018 08:27
[Movable Type] カスタムフィールドでアップロードした画像にwidthを指定してそのサイズで出力するやり方

Hoge というカスタムフィールドの場合

<mt:Entries>
  <mt:EntryDataHogeAsset>
    <img src="<mt:AssetThumbnailURL width="90">" alt="<mt:EntryTitle>">
  </mt:EntryDataHogeAsset>
</mt:Entries>
@ksuzushima
ksuzushima / gas-muteHttpExceptions.js
Created November 10, 2017 01:25
Setting muteHttpExceptions to true in the HTTP request to suppress errors.
/**
* 備忘録
* @link https://stackoverflow.com/questions/31891694/handle-404-errors-in-urlfetchapp-fetch
*/
function fetchPage() {
var response = UrlFetchApp.fetch("http://ctrlq.org/404", {muteHttpExceptions: true});
if (response.getResponseCode() == 404) {
Logger.log("Web page not found");
}