- 名前付けが適切か
- 名前空間
- クラス名
- 関数名
- 変数名
- ディレクトリ名
- ファイル名
- 副作用あり・なしが名前から連想できるか
- 読みやすさ
- クラス/関数の責務分離
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// usage: echo '{json string}' | json2varexport.php | |
// @see https://gist.github.com/Bogdaan/ffa287f77568fcbb4cffa0082e954022 | |
function varexport($expression, $return=FALSE) { | |
$export = var_export($expression, TRUE); | |
$export = preg_replace("/=> NULL/", '=> null', $export); | |
$export = preg_replace("/^([ ]*)(.*)/m", '$1$1$2', $export); | |
$array = preg_split("/\r\n|\n|\r/", $export); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find | |
find ./ -name 'main.go' | |
find ./ -name '*.go' | |
find ./ -name '*.go' -type f // -type d => directory, -type l => symbolic link | |
find ./ -name '*.go' -exec ls -la {} \; | |
# 文字列置換 | |
cat hoge | sed -e 's/hogehoge/aaa/g' | |
# 文字列抽出(grep) |
機能 | MySQL | PostgreSQL | sqlite3 |
---|---|---|---|
起動 | mysql -p -h ホスト名 -P ポート番号 -u ユーザ名 DB名 | psql -h ホスト名 -p ポート番号 -U ユーザ名 DB名 | sqlite3 |
データベース一覧 | show databases; | \l | - |
データベース切替 | use DB名 \u DB名 |
\c DB名 | - |
テーブル一覧 | show tables; | \d \dt \d+ \dt+ |
.tables |
テーブル定義確認 | desc テーブル名; | \d テーブル名 | - |
テーブルCREATE文確認 | show create table テーブル名 | pg_dump DB名 -U ユーザ名 -s -t テーブル名 | .schema hoge .schema select * from sqlite_master where type='table' and name='hoge'; |
行表示の切り替え | select * from t \G | \x | .mode line |
今日の日付 | curdate() | current_date | CURRENT_DATE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'vendor/autoload.php'; | |
echo $nodefined; // Variable $nodefined might not be defined. | |
$tmp1 = new NoExist(); // Instantiated class NoExist not found. | |
$tmp2 = noFunction(); // Function noFunction not found | |
class Hoge { | |
public function someMethod(int $someArg): string { |
curlでgrpc叩く(あらかじめ grpc-json-proxyを起動する必要あり)
$ curl -X POST \
-H 'Content-Type: application/grpc+json' \
-H "Grpc-Insecure:true" \
-x http://localhost:7001 \
-d '{"name":"hogehoge"}' \
http://127.0.0.1:50051/helloworld.Greeter/SayHello
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
sftp: | |
image: atmoz/sftp | |
volumes: | |
- ./sftp/keys/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key # SSH host key | |
- ./sftp/keys/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key # SSH host key | |
- ./xxx/.ssh/id_rsa.pub:/home/foo/.ssh/keys/id_rsa.pub:ro # sync publick key for authorized_keys | |
- ./sftp/upload:/home/foo/upload # sync upload directory | |
ports: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[client] | |
# prompt="[\\R:\\m:\\s] \\u@\\d> " | |
user=root | |
host=mysql | |
password=password | |
port=3306 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ue | |
git checkout master | |
current_branch=`git rev-parse --abbrev-ref HEAD` | |
if [[ ${current_branch} != master ]]; then | |
echo "Error: current branch is ${current_branch}" | |
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class <%= name %> { | |
constructor() { | |
this.params = [<%- fields.map(f => `'${f.name}'`).join(','); %>]; | |
} | |
} |
NewerOlder