Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
abregman committed Nov 30, 2020
1 parent a8377a2 commit 15b79c6
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ Name | Description
[opensource.com](https://opensource.com) | open source related articles including DevOps
[CooperPress](https://cooperpress.com/publications) | various newsletters on different topics
[afreshcup](https://afreshcup.com) | "covering Ruby on Rails and whatever else I find interesting in the universe of software"
[thisweekindevops.com](https://thisweekindevops.com) | "DevOps news without the hype"

## Articles

Expand Down
1 change: 1 addition & 0 deletions resources/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ Name | Comments
* Stop and remove all containers: `docker container stop $(docker container ls -aq)`
* Run container with bash shell: `docker run -ti ubuntu:latest bash`
* Check how many containers are running: `docker info`
* Cleanup everything: `docker system prune -a -f`
3 changes: 2 additions & 1 deletion resources/elk.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ PUT test_index/_settings
}
```

* Delete index: `DELETE /<index_name>`
* Delete index from console UI: `DELETE /<index_name>`
* Delete all indexes from CLI: `curl -X DELETE 'http://<elasticsearch_address>:9200/_all` # Don't run this! it will delete also the Kibana index and you'll not have default space available

* Create cluster

Expand Down
7 changes: 7 additions & 0 deletions resources/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Name | Comments
Name | Comments
:------ |:--------:
[Kubernetes Networking](https://github.com/nleiva/kubernetes-networking-links) | Kubernetes Networking Resources
[Liveness and Readiness Probes](https://www.openshift.com/blog/liveness-and-readiness-probes) |

## Misc

Expand All @@ -41,6 +42,12 @@ Name | Comments
[Kubesort](https://github.com/AATHITH/kubesort) | "kubesort helps you sort the results from kubectl get in an easy way"
[IngressMonitorController](https://github.com/stakater/IngressMonitorController) | "A Kubernetes controller to watch ingresses and create liveness alerts for your apps/microservices"

## Certificates

Name | Comments
:------ |:--------:
[CKAD-Practice-Questions](https://github.com/bbachi/CKAD-Practice-Questions) | "a consolidated list for CKAD practice questions"

## CheatSheet

### Minikube
Expand Down
8 changes: 7 additions & 1 deletion resources/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

<div align="center"><img src="../images/linux_map.png"></div><hr/>

## Learn Linux - Articles and Guides
## Learn Linux - Tutorials and Guides

Name | Comments
:------|:------:
[Linux Journey](https://linuxjourney.com) | Written guides + exercises + quiz
[Techmint Linux](https://www.tecmint.com/free-online-linux-learning-guide-for-beginners) | Written articles/lessons
[Linux Survival](https://linuxsurvival.com/linux-tutorial-introduction) | Interactive guide

## Learn Linux - Articles

Name | Comments
:------|:------:
[Linux Filesystem Explained](https://www.linux.com/training-tutorials/linux-filesystem-explained) | NSIA

## Linux Deep Dive - Articles

Name | Comments
Expand Down
42 changes: 42 additions & 0 deletions resources/mongo.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,45 @@ Name | Description
:------|:------:
[Guru99 MongoDB Tutorial](https://www.guru99.com/what-is-mongodb.html) | MongoDB Tutorial
[Tutorialspoint Tutorial](https://www.tutorialspoint.com/mongodb) | MongoDB Tutorial

## Cheat Sheet

### Mongo Shell

I assume the following for the purpose of the examples:
* DB name: usage_patterns
* Collection name: accounts

* DB stats: `db.stats()`
* Switch to a DB: `use usage_patterns`

* show collections: `show collections`
* Count the number of documents in a collection: `db.accounts.count()`
* Remove all the documents from a collection: `db.accounts.remove({})`

* Export Mongo DB into JSON file: `mongoexport --db=usage_patterns --collection=accounts --out=data.json`

#### Aggregations

* Count the number of documents: `db.accounts.aggregate([ { "$count": "number of documents" }])`
* Show only the sub element "attachment_uuids": `db.accounts.aggregate( [ {$project: {"hosts.attachment_uuids": 1, _id:0}} ] )`

### Mongo Python

* Add new element to an arrray only if it doesn't exists already

```
mongo_client.update(
{ "account_number": account_num },
{ "$addToSet": { "hosts": {'hostname': hostname} } }
)
```

* Add a new element to an array in sub-document (if it doesn't exists already):

```
mongo_client.update_one(
{ "account_number": account_num, "hosts.hostname": hostname },
{ "$addToSet": { "hosts.$.attachment_uuids": attachment_uuid } }
)
```

0 comments on commit 15b79c6

Please sign in to comment.