Compare commits

..

No commits in common. "b34178a86f4d3721fcb361bd1f5b85d41db4b2fb" and "942ec2a062d1545139ec512c4d141af1210addae" have entirely different histories.

12 changed files with 1 additions and 367 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
.DS_Store

View File

@ -1,3 +0,0 @@
```bash
ffmpeg -ss 00:01:00 -to 00:02:30 -i input.mp4 -c copy output.mp4
```

View File

@ -1,33 +0,0 @@
# Automate update via Git Hook
1. Navigate to the bare repository:
```bash
cd ~/git/asobi.git/hooks
```
2. Create `post-receive` Hook:
```bash
nano post-receive
```
3. Add script you want to run:
```bash
#!/bin/bash
# Deployment directory
DEPLOY_DIR="/home/nik/repo/asobi"
# Navigate to the deployment directory
cd $DEPLOY_DIR
# Pull the latest changes
git pull origin main
# Restart the service
sudo systemctl restart asobi-web.service
```
4. Make the hook executable:
```
chmod +x post-receive
```

View File

@ -1,36 +0,0 @@
# Golang basics
## Initialize project
```bash
$ go mod init <project-name> #usually folder name
```
## Insert package
```go
package main
import "fmt"
func main() {
// your code here
}
```
## Running code
```bash
$ go run main.go
```
## Pointer in Go
```go
var userName string
var userTickets int
fmt.Scan(&userName)
// &userName point to the memory of the var
```
## Import package
```bash
go get github.com/gin-gonic/gin
```

View File

@ -1,45 +0,0 @@
1. Open new service file:
```
sudo nano /etc/systemd/system/<name>.service
```
2. Content
```
[Unit]
Description=Page Host Service
After=network.target
[Service]
User=your_username
WorkingDirectory=/home/your_username/repo/asobi
Environment=PYENV_ROOT=/home/your_username/.pyenv
ExecStart=/bin/bash -c "source $PYENV_ROOT/bin/pyenv && pyenv activate pyenv && python page_host.py"
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
```
3. Reload systemd, enable service:
```
sudo systemctl daemon-reload
sudo systemctl enable <name>.service
sudo systemctl start <name>.service
```
4. Check status:
```
sudo systemctl status <name>.service
journalctl -u <name>.service
```
5. Test reboot:
```
sudo reboot
```
Check status
```
sudo systemctl status page_host.service
```

View File

@ -1,12 +0,0 @@
sudo yum update -y
sudo amazon-linux-extras install epel -y
sudo wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql80-community-release-el7-5.noarch.rpm
sudo yum install mysql-server -y
/etc/yum.repos.d/*mysql*
sed -i 's/gpgcheck=1/gpgcheck=0/g' filename
sudo grep 'temporary password' /var/log/mysqld.log

View File

@ -1,159 +0,0 @@
AWS CDK ドキュメント : https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html
npm version : 10.2.3
nodenv version : 18.19.0
#nodenv導入
github:https://github.com/nodenv/nodenv
1. nodenvをクローンする
```
git clone https://github.com/nodenv/nodenv.git ~/.nodenv
```
インストール時間を短縮するためダイナミックバッシュでコンパイルする(失敗してもインストールできる)
```
cd ~/.nodenv && src/configure && make -C src
```
2. nodenvを`PATH`に追加する
```
echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrc
```
現在のシェルにbash適用する
```
source ~/.bashrc
```
3. nodenvをshellにセットアップする
```
~/.nodenv/bin/nodenv init
```
表示されたコマンドで実行する
**プラットフォームによってコマンド違うので下記のコマンドを実行しない**
```
echo 'eval "$(nodenv init - bash)"' >> ~/.bashrc
source ~/.bashrc
```
4. nodenvインストール確認
```
curl -fsSL https://github.com/nodenv/nodenv-installer/raw/main/bin/nodenv-doctor | bash
```
下記の画面表示されたら完了
```
Checking for `nodenv' in PATH: /home/nik/.nodenv/bin/nodenv
Checking for nodenv shims in PATH: OK
Checking `nodenv install' support: not found
Unless you plan to add Node versions manually, you should install node-build.
Please refer to https://github.com/nodenv/node-build#installation
Counting installed Node versions: none
There aren't any Node versions installed under `/home/nik/.nodenv/versions'.
You can install Node versions like so: nodenv install <version>
Auditing installed plugins: OK
```
##node-buildインストールオプション
*nodenv install使用するに最適化されるプラグイン*
github: https://github.com/nodenv/node-build
```
mkdir -p "$(nodenv root)"/plugins
git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build
```
##node version 18.19.0インストール
```
nodenv install 18.19.0
nodenv global 18.19.0
```
nodeバージョン確認
```
node --version
npm --version
npx --version
```
# AWSプロファイル設定
```
aws configure sso --profile <プロファイル名>
```
コマンドからユーザー情報が保存できる
```
SSO session name (Recommended): its-pharma-core-dev
SSO start URL [None]: https://d-95675820f8.awsapps.com/start/#
SSO region [None]: ap-northeast-1
SSO registration scopes [sso:account:access]:
CLI default client Region [None]: ap-northeast-1
CLI default output format [None]: json
```
### AWSアカウント切り替え
```
export AWS_PROFILE=medaca
```
### アカウントSSO(シングルサインオン)再認証
```
aws sso login --profile <プロファイル名>
```
### Alias設定 (WSLでコマンド省略)
homeダイレクトリー変更
```
cd ~
```
.bashrcにaliasにしたいコマンド書く
```
vi .bashrc
```
例:
```
alias medaca='export AWS_PROFILE=medaca'
```
この場合は`export AWS_PROFILE=medaca`コマンドが`medaca`に省略できる
最後にsourceで現在のshellに読み込み
```
source ~/.bashrc
```
## 便利なサイト
AWSワークショップhttps://cdkworkshop.com/20-typescript/20-create-project/100-cdk-init.html
AWSサンプルCDKプロジェクトhttps://github.com/aws-samples/aws-cdk-examples/tree/main
AWS CDKベストプラクティスhttps://docs.aws.amazon.com/cdk/v2/guide/best-practices.html
https://docs.aws.amazon.com/pdfs/prescriptive-guidance/latest/best-practices-cdk-typescript-iac/best-practices-cdk-typescript-iac.pdf#introduction
### 命名規則:
camelCase変数、関数
PascalCaseクラス、インターフェイス
## 脆弱性ツール
cfn-naghttps://github.com/stelligent/cfn_nag
cdk-nag

View File

@ -31,10 +31,7 @@ cd <repository>
2. Add remote repository
```bash
git remote add origin <server_credential>:~/<directory_name>/<project>.git
# sample
git remote add origin nik-deb:~/git/automation.git
git remote add origin <server_credential>/~/<directory_name>/<project>.git
```
3. Push code as main

View File

@ -1,43 +0,0 @@
## Install gcloud cli
https://cloud.google.com/sdk/docs/install
## Run spanner docker
https://cloud.google.com/spanner/docs/emulator#start-emulator-gcloud
### Set gcloud cli to point to local
```
export SPANNER_EMULATOR_HOST=localhost:9010
```
### Run spanner code on terminal
```
# Create instances
gcloud spanner instances create testinstance \
--config=emulator-config \
--description="Test Instance" \
--nodes=1
# Create database
gcloud spanner databases create testdb --instance=testinstance
# Create table
gcloud spanner databases ddl update testdb --instance=testinstance \
--ddl="CREATE TABLE Singers (
SingerId INT64 NOT NULL,
FirstName STRING(1024),
LastName STRING(1024),
SingerInfo BYTES(MAX)
) PRIMARY KEY (SingerId)"
```
### Connect to spanner through dbeaver
1. Install DBeaver CE (free) on Mac.
2. Install the Spanner JDBC driver.
3. Create a new connection → Google Cloud Spanner.
• Project ID: test-project
• Instance: testinstance
• Database: testdb
• set autoConfigEmulator to true

View File

@ -30,6 +30,3 @@ Start the service:
sudo systemctl start page_host
```
$ realpath /home/ec2-user/repo/aws-test-kadai3/venv/bin/python
/usr/bin/python3.7
[ec2-user@ip-172-31-14-7 aws-test-kadai3]$ sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.7

View File

@ -1,8 +0,0 @@
```bash
sudo ufw allow from 192.168.70.0/24 to any port 33060
```
```bash
sudo ufw status numbered
sudo ufw delete [number]
```

View File

@ -1,25 +1,5 @@
# Venv
```bash
python -m venv <env-name>
source <env-name>/bin/activate
deactivate
```
# Freeze requirement
```bash
pip freeze > requirements.txt
pip install -r requirements.txt
```
# Pipenv
```bash
pyenv install --list | grep 3.9
pyenv install 3.9.12
```
```bash
pyenv global 3.12.4
cd /path/to/your/project
pyenv local 3.9.17
```