Code | Description |
---|---|
docker rm $(docker ps -a -q -f status=exited) |
To remove all the containers that have exited |
EC2_REGION=
|
To login into ECR |
docker pull amazon/amazon-ecs-sample |
Just a ecs sample |
Shortcut | Description |
---|---|
shift + opt + down arrow key | Duplicate current line |
cmd + k + 0 | fold all region |
cmd + k + j | unfold all region |
cmd + opt + [ | fold single region |
cmd + opt + ] | unfold fold single region |
Description | Code | Remarks |
---|---|---|
Create a virtual environment called venv | virtualenv venv |
|
Activate the virtual environment | . venv/bin/activate |
|
See installed | pip freeze |
|
Create a requirements file | pip freeze > requirements.txt |
|
Deactivate the virtual environement | deactivate |
|
Remove the virtual environment | rm -r venv |
|
To load pip file | pip install -r requirements.txt |
|
Jupyter notebook kernel | within the virtual env python -m ipykernel install --user --name=<kernel name> |
YT Vid |
Reference: https://marklodato.github.io/visual-git-guide/index-en.html
Description | Code |
---|---|
View local commits | git log origin/main..HEAD |
View git commits in graph | git log --oneline --graph --decorate |
Undo 1 commit on current branch | git reset --soft HEAD~1 |
Merge main into current branch | git checkout <branch> , git merge main |
Description | Code |
---|---|
To know details about your virtual instances | curl http://<instance number>/latest/meta-data/ |
To know details about virtual instance user permission | curl http://<instance number>/latest/meta-data/iam/security-credentials/MyAdmin |
To know what is your user name in your policy, you can use variable | "Resource": ["arn:aws:s3:::mybucket/${aws:username}/*"] |
Description | Code |
---|---|
History | Ctrl R |
Next History | Ctrl R |
Cut | Ctrl U |
Paste | Ctrl Y |
Description | Code |
---|---|
Set number | :set number |
Go to line | :[linenumber] |
Go to end of line | $ |
Undo | Ctrl U |
Indent next 3 lines | 3>> |
Unindent next 3 lines | 3<< |
Delete inside word | diw |
Delete word to end of line | dw |
Enter a new line and go into insert mode | o |
Description | Code | Remarks |
---|---|---|
Check if file exist | test -f test.py; echo $? |
-f flag checks if file exists. If returns 0 = true |
Description | Code | Remarks |
---|---|---|
Check tcp traffic | tcpdump dst port 443 |
dump traffic on port 443, result format = (incoming traffic) > (outgoing traffic) |
Description | Code | Remarks |
---|---|---|
S3 copy local folder to bucket | aws s3 cp ./scripts s3://<bucket-name>/scripts --recursive |
copy from local script folder, into s3 bucket with prefix scripts |
Description | Code | Remarks |
---|---|---|
From list to dict | def Convert(lst): |
https://www.geeksforgeeks.org/python-convert-a-list-to-dictionary/ |
From dict retrieve elements for array | subnets = [{subnet['SubnetId'] for subnet in resp}] |
|
From dict retrieve single element as key | subnets = [{subnet['SubnetId']:subnet for subnet in resp}] |
|
Create a new-dict with desired key e.g. k = [key_a,key_b] from dict | newdict = {k: testdict[k] for k in keep} |
https://stackoverflow.com/questions/32727294/remove-keys-from-object-not-in-a-list-in-python |
Description | Code | Remarks |
---|---|---|
From powershell create directory | New-Item -Path "$env:UserProfile\bin" -ItemType Directory |
|
Add folder to path bin | reg add HKEY_CURRENT_USER\Environment /v Path /t REG_EXPAND_SZ /d "$env:Path;$env:UserProfile\bin" |
|
Check path is added | $env:Path |
Description | Code | Remarks |
---|---|---|
Windows | systeminfo |
|
Linux | cat /etc/os-release |
|
Mac | system_profiler SPSoftwareDataType |