gcloudのコマンド
コマンド
- auth されている account 一覧(gcloud auth login すると増えていく)
- gcloud auth list
- config 一覧
- gcloud config list
- configration 一覧
- gcloud config configurations list
- 新しい configuration つくって set する
- gcloud config configurations create foo-project
- gcloud config set project foo-project // project set
- gcloud config set account foo@example.com // account set
- gcloud config set compute/zone us-central1-a // zone set
- プロジェクト切り替え(activate)
- gcloud config configurations activate foo-project
コンテナ関連
- gcloudでDockerが使えるよう
- gcloud auth configure-docker
サービスアカウントの認証
gcloud auth activate-service-account \ foo@foo-project.iam.gserviceaccount.com \ --key-file /path/foo-project-1234.json \ --project foo-project
gcloud コマンドでiam role 操作
gcloud projects add-iam-policy-binding foobar-project \ --member="serviceAccount:foobar@foobar-project.iam.gserviceaccount.com" \ --role=roles/run.admin gcloud projects add-iam-policy-binding foobar-project \ --member="user:foobar@example.com" --role=roles/run.admin
参考
WordCloudつくってみためも
とりあえず macabに食わせてみる
cat input.txt | mecab
jupyterでwordcloudつくる
import MeCab from matplotlib import pyplot as plt from wordcloud import WordCloud with open('input.txt', mode='rt', encoding='utf-8') as fi: source_text = fi.read() tagger = MeCab.Tagger() tagger.parse('') node = tagger.parseToNode(source_text) wl = [] while node: if node.feature.split(',')[0] == '名詞' and node.feature.split(',')[1] == '一般': wl.append(node.surface) elif node.feature.split(',')[0] == '名詞' and node.feature.split(',')[1] == 'サ変接続': wl.append(node.surface) node = node.next word_chain = ' '.join(wl) wc = WordCloud(width=1280, height=720, prefer_horizontal=1, background_color='white', colormap='bone', font_path='/System/Library/Fonts/ヒラギノ明朝 ProN.ttc').generate(word_chain) wc.to_file("out.png") plt.imshow(wc) plt.axis('off') plt.show()
VSCodeの YAML to JSON で相互変換
これ
YAML to JSON - Visual Studio Marketplace
shift + command + P を押す
「YAML to JSON:Convert selection or document」と入力する
いじょ
fargateでsonarqube動かしてみるテスト
ecs-cliの導入
brew install ecs-cli
~/.ecs/credentialsの内容
version: v1 default: default region: ap-northeast-1 ecs_profiles: default: aws_access_key_id: xxx aws_secret_access_key: xxx
ECSクラスタ作成
手元の ecs-params.yml を参照している
ecs-cli up \ --cluster foobar-cluster \ --vpc vpc-xxx \ --subnets subnet-xxx \ --launch-type FARGATE
sonarqubeサーバ作成
ecs-cli compose \ -f docker-compose.yml service up \ --launch-type FARGATE \ --cluster foobar-cluster
ecs-params.yml
version: 1 task_definition: ecs_network_mode: awsvpc task_execution_role: ecsTaskExecutionRole task_size: cpu_limit: 1024 mem_limit: 8GB services: sonarqube: essential: true run_params: network_configuration: awsvpc_configuration: subnets: - subnet-xxx security_groups: - sg-xxx
docker-compose.yml
version: '2' services: # postgresql postgresql-sonarqube: container_name: postgresql-sonarqube image: postgres:11.2-alpine volumes: - /var/lib/postgresql - /var/lib/postgresql/data ports: - 5432:5432 networks: - sonarqube-server-network environment: POSTGRES_USER: sonar POSTGRES_PASSWORD: sonar POSTGRES_INITDB_ARGS: "--encoding=UTF-8" # SonarQube Server sonarqube-server: container_name: sonarqube-server image: sonarqube:7.5-community volumes: - ./data/sonarqube/extensions/plugin:/opt/sonarqube/extensions/plugins ports: - "9000:9000" - "9092:9092" networks: - sonarqube-server-network environment: - SONARQUBE_JDBC_USERNAME=xxx - SONARQUBE_JDBC_PASSWORD=xxx - "SONARQUBE_JDBC_URL=jdbc:postgresql://127.0.0.1:5432/sonar" volumes: - /opt/sonarqube/conf - /opt/sonarqube/data - /opt/sonarqube/extensions - /opt/sonarqube/lib/bundled-plugins networks: sonarqube-server-network:
Pythonでjson.dumpsで日本語が、Unicodeのコードになってしまうやつ
import json if __name__ == "__main__": payload = '{"abc" : "あいうえお"}' x = json.loads(payload) print(x) print(type(x)) y = json.dumps(x, ensure_ascii=False) print(y) print(type(y))
実行結果
{'abc': 'あいうえお'} <class 'dict'> {"abc": "あいうえお"} <class 'str'>
ensure_ascii=False
を指定しましょう。
json — JSON encoder and decoder — Python 3.9.2 documentation
If ensure_ascii is true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. If ensure_ascii is false, these characters will be output as-is.