Skip to content

Instantly share code, notes, and snippets.

View ko31's full-sized avatar
I want to play catch!

Ko Takagi ko31

I want to play catch!
View GitHub Profile
@ko31
ko31 / post_slack.php
Created January 8, 2020 23:57
How to easily post to slack channel with PHP
<?php
// Your slack token
$token = 'YOURTOKEN';
// Your slack channel (e.g. #general)
$channel = '#general';
// Post message
$text = "<!channel>Hello World!";
@ko31
ko31 / download_website_by_wget.md
Last active December 17, 2019 06:51
Download website files using wget

Usage

wget -P /path/to/download -E -k -m -nH -np -p -c https://example.com
Option Overview
-P Set save directory path.
-E This option will cause the suitable suffix to be appended to the local filename.
@ko31
ko31 / manual.md
Last active May 4, 2020 07:16
XSERVER に wp-cli をインストール

手順

インストールするディレクトリ作成

mkdir -p ~/local/bin

インストール

@ko31
ko31 / functions.php
Created October 26, 2019 06:35
[Simple Slug Translate] Customize translated post statuses.
/**
* Customize translated post statuses.
*/
add_filter( 'simple_slug_translate_post_status', function( $statuses ) {
// Specify post statuses
$statuses = [
'draft',
'publish',
];
@ko31
ko31 / functions.php
Created October 26, 2019 06:21
[Simple Slug Translate] Customize the translated slug.
/**
* Customize the translated slug.
*/
add_filter( 'simple_slug_translate_results', function( $results ) {
// 200 - OK
if ( 200 === $results['code'] ) {
// Customize slug
$results['text'] = sprintf( 'translated-%s', $results['text'] );
}
@ko31
ko31 / touch.php
Created October 10, 2019 02:34
YYYY/MM/DD/[filename].html というファイルに対して、ディレクトリ構成の年月日からファイル最終更新日時をセット
<?php
/**
* YYYY/MM/DD/[filename].html というファイルに対して、
* ディレクトリ構成の年月日からファイル最終更新日時をセット
*/
$paths = glob('*/*/*/*.html');
foreach ($paths as $path) {
list($year, $month, $day, $file) = explode('/', $path);
touch($path, strtotime(sprintf('%s/%s/%s', $year, $month, $day)));
@ko31
ko31 / update.md
Created September 11, 2019 03:04
vulnerabilities alert が出るので npm-check-updates でパッケージをアップデートする

npm-check-updates をインストールする。

$ npm install -g npm-check-updates

更新可能なパッケージを確認する。

$ ncu
@ko31
ko31 / sample.sh
Last active August 18, 2019 11:58
wp --allow-root core language install ja --activate
wp --allow-root option update timezone_string 'Asia/Tokyo'
@ko31
ko31 / motto.png
Last active August 10, 2019 10:53
motto
motto.png
@ko31
ko31 / gosign.txt
Created August 10, 2019 10:33
Gosign Ascii Art
________ ________ ________ ___ ________ ________
|\ ____\|\ __ \|\ ____\|\ \|\ ____\|\ ___ \
\ \ \___|\ \ \|\ \ \ \___|\ \ \ \ \___|\ \ \\ \ \
\ \ \ __\ \ \\\ \ \_____ \ \ \ \ \ __\ \ \\ \ \
\ \ \|\ \ \ \\\ \|____|\ \ \ \ \ \|\ \ \ \\ \ \
\ \_______\ \_______\____\_\ \ \__\ \_______\ \__\\ \__\
\|_______|\|_______|\_________\|__|\|_______|\|__| \|__|
\|_________|