Skip to content

Instantly share code, notes, and snippets.

View yousan's full-sized avatar
💻
I must work everyday

Yousan_O yousan

💻
I must work everyday
View GitHub Profile
@yousan
yousan / change_db_prefix.sh
Last active May 6, 2020 13:40
Change WordPress table prefix
#!/usr/bin/env bash
# Change WordPress table prefix
# WP-CLI is reqiured
# WARNING: BACKUP is strongly recommended
# usage: change_db_prefix.sh wp_new_prefix_
# 1. Get all WordPress tables
# 2. Change wp_options and wp_usermeta values
# 3. Rename tables
# 4. Change table prefix at wp-config.php
@yousan
yousan / install_wpcli_for_xserver.sh
Last active March 11, 2020 06:56
WP-CLI Install script for XServer
#!/usr/bin/env bash
mkdir ~/bin
curl -o bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x bin/wp
echo 'alias wp="php7.4 ~/bin/wp"' >> ~/.bashrc
source ~/.bashrc
@yousan
yousan / get_cloudwatch_logs_incomingbytes_sum.sh
Last active July 28, 2022 15:09
Check CloudWatch usage by AWS CLI
#!/usr/bin/env bash
## The original file is here. https://dev.classmethod.jp/cloud/aws/check-cloudwatch-logs-incomigbytes-by-aws-cli/
## Show CloudWatch log size as CSV (TSV) format.
## CloudWatchのロググループをCSV(TSV)形式で出力します
# Sample
# ./get_cloudwatch_logs_incomingbytes_sum.sh yousan-aws ap-northeast-1 3
#
# Byte Date LogGroup MegaByte GigaByte
# 19820.0 2019-09-19T00:00:00Z /aws/lambda/yousantest 0.02 0.00
# 35428.0 2019-09-18T00:00:00Z /aws/lambda/yousantest 0.03 0.00
@yousan
yousan / stagename.sh
Created August 24, 2019 01:31
Define stagename to sanitize branchname
#!/usr/bin/env bash
# 現在のブランチ名からブランチハッシュを取得する
# ブランチハッシュ => ブランチ名からスラッシュの置換、文字列を短く、ハッシュを付加してサニタイズしたもの。
# e.g. master => master
# e.g. develop => develop
# e.g. feature/yousan/test => feature-yousan-test-faaa59
# e.g. feature/yousan/something-toooooooooooooooooooooooooooooooooooo-long-branch-name => feature-yousan-something-tooooooooooooooooooooooooooooooo-379fca
set -xe
# 現在のブランチ名を取得する
@yousan
yousan / .commit_template
Created February 26, 2019 04:14 — forked from Jung0/.commit_template
🤘 Emoji prefix to use at commit message
# ==================== Emojis ====================
# 🎉 :tada: 初めてのコミット(Initial Commit)
# 🔖 :bookmark: バージョンタグ(Version Tag)
# ✨ :sparkles: 新機能(New Feature)
# 🐛 :bug: バグ修正(Bagfix)
# ♻️ :recycle: リファクタリング(Refactoring)
# 📚 :books: ドキュメント(Documentation)
# 🎨 :art: デザインUI/UX(Accessibility)
@yousan
yousan / commit.md
Created December 7, 2018 09:14
Gitコミットのルールについてについて

ベース

ブランチ名の命名規則をGitFlow、マージはPRでマージさせるGitHub Flowを組み合わせて使っています。

Git-flowって何?

ブランチ名について

  1. 名前は features/yousan/201801/fix-admin-panel といった名前でブランチを作ってください。 開発用ブランチとして、features/ブランチの以下にユーザ名(例: yousan/)、年月(例: 201801)、機能概要(例: fix-admin-panel)としてください。
@yousan
yousan / version.sh
Last active November 30, 2019 06:36
#!/usr/bin/env bash
# バージョンを求めるスクリプトです。
# Usage: curl -s -L https://gist.githubusercontent.com/yousan/34016e297cad5871b27a94135d5e4d43/raw/46f5662225ffec4bcfc4bc720a42cbb74cd8c9b3/version.sh | bash
# @see https://qiita.com/yousan/items/cffa19f67f225097127d
echo $(git tag | sort -V | tail -1) '-' | tr -d " \n"; git rev-parse HEAD | cut -c1-7 | tr -d "\n"; echo '-'$(date +%Y%m%d)
@yousan
yousan / wp_query_example.php
Last active September 22, 2018 05:01 — forked from Olein-jp/wp_query_example
WP_Queryで出力する際のサンプル
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
* Japanese translated by hissy
*
* CODEX: http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/WP_Query#.E3.83.91.E3.83.A9.E3.83.A1.E3.83.BC.E3.82.BF
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
* Original: https://gist.github.com/luetkemj/2023628/9e911982440141a13cb1dd8ba1ad6b35cd7bbdd7
*/
@yousan
yousan / Readme.md
Created July 13, 2018 05:32
Gitの運用ルール

ブランチ名について

  1. 名前は features/yousan/201801/fix-admin-panel といった名前でブランチを作ってください。 開発用ブランチとして、features/ブランチの以下にユーザ名(例: yousan/)、年月(例: 201801)、機能概要(例: fix-admin-panel)としてください。

feature以外のブランチについて

  1. ブランチの作成はdevelopから行ってください。
  2. masterブランチ、developブランチへの直接コミットは行わないようにしてください。
  3. featureブランチの作成にはSourceTreeのGit Flowを使うと便利です。

コミットとブランチの粒度について