gitチートシート

ブランチ操作

  • ブランチ切替

  • カレントから新しいブランチの作成

    • git branch -b hoge/fugafuga
  • 作ったブランチをremote にpush

    • git push origin hoge/fugafuga
  • リモートブランチ一覧

    • git branch -r
  • リモートブランチとってくる

    • git checkout feat/hogehoge
  • リモートブランチの削除

    • git branch -r -d hoge/fugafuga
  • カレントのブランチ名の変更

    • git branch -m 変更後の名前
  • 既に削除したリモートブランチを一覧から削除

    • git fetch --prune
  • ブランチがどこから分岐してんのか見る(masterから分岐した例)

    • git show-branch --sha1-name master feat/hoge-branch | tail -1
  • 特定ブランチのclose

コミットを書き換える

リポジトリ操作

認証

TIPS

GitHub実践入門 ~Pull Requestによる開発の変革 (WEB+DB PRESS plus)

GitHub実践入門 ~Pull Requestによる開発の変革 (WEB+DB PRESS plus)

nkfのチートシート

macbrewで入れたやつ

とりあえずhelpみる

nkf --help
Usage:  nkf -[flags] [--] [in file] .. [out file for -O flag]
 j/s/e/w  Specify output encoding ISO-2022-JP, Shift_JIS, EUC-JP
          UTF options is -w[8[0],{16,32}[{B,L}[0]]]
 J/S/E/W  Specify input encoding ISO-2022-JP, Shift_JIS, EUC-JP
          UTF option is -W[8,[16,32][B,L]]
 m[BQSN0] MIME decode [B:base64,Q:quoted,S:strict,N:nonstrict,0:no decode]
 M[BQ]    MIME encode [B:base64 Q:quoted]
 f/F      Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nl
 Z[0-4]   Default/0: Convert JISX0208 Alphabet to ASCII
          1: Kankaku to one space  2: to two spaces  3: HTML Entity
          4: JISX0208 Katakana to JISX0201 Katakana
 X,x      Convert Halfwidth Katakana to Fullwidth or preserve it
 O        Output to File (DEFAULT 'nkf.out')
 L[uwm]   Line mode u:LF w:CRLF m:CR (DEFAULT noconversion)
 --ic=<encoding>        Specify the input encoding
 --oc=<encoding>        Specify the output encoding
 --hiragana --katakana  Hiragana/Katakana Conversion
 --katakana-hiragana    Converts each other
 --{cap, url}-input     Convert hex after ':' or '%'
 --numchar-input        Convert Unicode Character Reference
 --fb-{skip, html, xml, perl, java, subchar}
                        Specify unassigned character's replacement
 --in-place[=SUF]       Overwrite original files
 --overwrite[=SUF]      Preserve timestamp of original files
 -g --guess             Guess the input code
 -v --version           Print the version
 --help/-V              Print this help / configuration

ポイント

  • '--overwrite'をつけると上書き、つけないと元ファイルは残る

自動判別の結果参照

nkf --guess hoge.txt
Shift_JIS (LF)

sjisで上書き

nkf -s --overwrite hoge.txt

utf-8(BOM無し)で上書き

nkf -w --overwrite hoge.txt

文字コードutf-8に、改行コードをLFに、両方変換

nkf -w -Lu --overwrite *.txt

自動判定の文字コードがおかしい時に、指定の文字コード(sjis)で読み込ませて、指定の文字コード(utf-8)で表示する

nkf -S -w hoge.txt

うぇーい

プログラマのための文字コード技術入門 (WEB+DB PRESS plus) (WEB+DB PRESS plusシリーズ)

プログラマのための文字コード技術入門 (WEB+DB PRESS plus) (WEB+DB PRESS plusシリーズ)

awkでtsvの特定列の合計値を出す

こんなtsvがあったとする

$ cat hoge.tsv
abc     100
efg     200
xyz     300

2列目が、金額だから合計値を出したいときはこんな感じ

awk -F '\t' '{whole = whole + $2} END{print whole}' hoge.tsv
600

うぇーい

AWK実践入門 (Software Design plus)

AWK実践入門 (Software Design plus)

システム構成に使えるicon集2016

個人的な興味の範囲で(だからMS系はない)

エンジニアのためのPowerPoint再入門講座 伝えたいことが確実に届く“硬派な資料”の作り方

エンジニアのためのPowerPoint再入門講座 伝えたいことが確実に届く“硬派な資料”の作り方

mysqlのalter文チートシート

カラムの追加、変更、削除

そのまま追加

alter table hoge_table 
add hoge_description varchar(128)
;

先頭に追加

alter table hoge_table 
add hoge_description varchar(128) first
;

なんかのカラムの後に追加

alter table hoge_table 
add hoge_description varchar(128)  after a_flag
;

変更

alter table hoge_table 
change hoge_description hoge_description_old varchar(255) 
;

削除

alter table hoge_table 
drop hoge_description
;

index作成、削除

作成

alter table hoge_table
add index hoge_idx(`a_flag`,`b_flag`)
;

削除

alter table hoge_table
drop index hoge_idx
;

mysqlで時間かかってるクエリをまとめてkill

↓はshow full processlistとおなじ

SELECT * FROM information_schema.PROCESSLIST;

秒数を指定

SELECT GROUP_CONCAT(ID) FROM information_schema.PROCESSLIST WHERE TIME > [秒数];

こんな感じの結果がくる

+------------------+
| group_concat(ID) |
+------------------+
| 101,102,103             |
+------------------+

mysqladminでまとめてkill

mysqladmin kill 101,102,103 -h hogehoge -u fugafuga

世界は平和になった

エキスパートのためのMySQL[運用+管理]トラブルシューティングガイド

エキスパートのためのMySQL[運用+管理]トラブルシューティングガイド

El Capitanにhomebrewでnginx入れる

インストール

$ brew install nginx

起動

$ nginx

停止

$ nginx -s stop

デフォルト設定ファイル

/usr/local/etc/nginx/nginx.conf

デフォルトディレクト

/usr/local/Cellar/nginx/バージョン

デフォルトログディレクト

/usr/local/var/log/nginx/*.log

デフォルトページ

http://127.0.0.1:8080/

nginx実践入門 (WEB+DB PRESS plus)

nginx実践入門 (WEB+DB PRESS plus)