Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' of https://[email protected]/zzzamyatin/langu…
Browse files Browse the repository at this point in the history
…ages
  • Loading branch information
Dmitry committed Nov 28, 2023
2 parents e34beef + 717d5a3 commit 606d953
Show file tree
Hide file tree
Showing 24 changed files with 420 additions and 55 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/create-diagram.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Create diagram

on:
workflow_dispatch: {}
push:
branches:
- main
jobs:
get_data:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Update diagram
uses: githubocto/repo-visualizer@main
with:
excluded_paths: "ignore,.github"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

Cheatsheets for languages I speak
https://zzzamyatin.github.io/languages/


![Visualization of the codebase](./diagram.svg)
8 changes: 8 additions & 0 deletions business_intelligence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Business Intelligence

* Code-based BI https://evidence.dev/

## Open source BI
Apache Superset
Metabase
Yandex DataLens
3 changes: 2 additions & 1 deletion computer_science.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
* https://composingprograms.com/ Python based

# Principles
* SOLID https://www.freecodecamp.org/news/solid-principles-for-programming-and-software-design/
* SOLID https://www.freecodecamp.org/news/solid-principles-for-programming-and-software-design/
* Versioning https://semver.org/
1 change: 1 addition & 0 deletions diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Docker

* https://docker-curriculum.com/
* https://docs.docker.com/get-started
* https://github.com/veggiemonk/awesome-docker
* course https://www.udemy.com/course/learn-docker/
* https://www.smarthomebeginner.com/best-docker-containers-for-home-server/
* https://www.smarthomebeginner.com/docker-media-server-2022/

## reverse proxy
* caddy https://github.com/lucaslorentz/caddy-docker-proxy
* traefik https://github.com/traefik/traefik
* auth https://t.me/c/1675809627/2662

## orchestration
Kubernetes: https://www.udemy.com/course/learn-kubernetes
Portainer: https://github.com/portainer/portainer

## automatic update
* https://containrrr.dev/watchtower/

## dashboard
https://github.com/pawelmalak/flame



## Images
$ docker search postgres
$ docker pull postgres
$ docker images

## Volumes
$ docker volume create postgres-data
$ docker volume ls

## Start a container
$ docker run postgres # run an image and exit
$ docker run postgres echo "Hello, world!" # run an image and the command in it and exit
$ docker run -it postgres sh # run an image with the shell and attach to it

$ docker run \
--name p1 \
-e POSTGRES_PASSWORD=lovesexgod # set environment variable \
-P # publish all opened ports random \
-p 5432:5432 # publish a specific port ext:int \
-v postgres-data:/var/lib/postgresql/data # mount a volume ext:int \
--net MYNETWORK # put in the specific network \
-d # detached mode \
-it # interactive terminal \
--rm # rm container after stop \
postgres # which image to run. If an image is not pulled, it will be pulled automatically

$ docker stack deploy -c stack.yml postgres

## Dockerfile
Dockerfile is the list of instructions to build an image

# define the parent image, to be inherited
FROM python:3.8
MAINTAINER Name Surname <[email protected]>
# mount a volume
ADD flask-app /opt/flask-app
WORKDIR /usr/src/app
# copy all the files to the container
COPY . .
# install dependencies
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 5000
CMD ["python", "./app.py"]

$ docker build -t USERNAME/IMAGENAME IMAGEROOTDIR # Dockerfile must be in IMAGEROOTDIR

## Distributing containers
$ git clone https://github.com/prakhar1989/FoodTrucks
$ cd FoodTrucks
$ ./setup-docker.sh

setup-docker.sh:

#!/bin/bash

# build the flask container
docker build -t yourusername/foodtrucks-web .

# create the network
docker network create foodtrucks-net

# start the ES container
docker run -d --name es --net foodtrucks-net -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.3.2

# start the flask app container
docker run -d --net foodtrucks-net -p 5000:5000 --name foodtrucks-web yourusername/foodtrucks-web
Now imagine you are distributing your app to a friend, or running on a server that has docker installed. You can get a whole app running with just one command!





## Docker Compose
see [Docker Compose](docker-compose.md)

## Work with containers
$ docker ps # running containers only === $ docker container ls
$ docker ps -a # all available containers
$ docker port p1 # see exposed ports

$ docker exec -it p1 psql -U postgres
$ docker exec -it p1 psql -U postgres -c "create database scores"

$ docker logs p1

## Networks
see [docker-network](docker-network.md)

## Cool examples
$ docker run -it --rm alpine # start fast & simple linux to try
$ docker run --rm alpine ping ya.ru # run command and exit



## Clean up
$ docker stop p1
$ docker rm p1
$ docker container prune # rm all stopped containers
$ docker rmi postgres
$ docker volume rm postgres-data
$ docker network rm NETWORKNAME
29 changes: 29 additions & 0 deletions docker/docker-compose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Docker Compose
see [Docker](README.md)

https://docs.docker.com/compose/overview
https://docs.docker.com/compose/compose-file
https://github.com/docker/awesome-compose

## build images

$ docker-compose build


## run

step by step:

$ cd dir_with_docker-compose_yml
$ docker compose up

oneliner:

$ docker compose
[ -f docker-compose.yml ] # YAML file location if not in PWD
-d # detached mode
up

## clean up
$ docker compose down \
-v # for verbose output
65 changes: 65 additions & 0 deletions docker/docker-network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# docker network
see [Docker](README.md)

https://docs.docker.com/engine/userguide/networking/dockernetworks/

Linux create docker network interface **docker0**
macOS and in Win hides docker in a VM behind the NAT


$ docker networks ls
bridge
host
none
macvlan
ipvlan
overlay # docker swarm


## bridge
* an internal network
* by default
* the default bridge has no dns
* multiple *bridge* networks are possible
* manually created bridge networks becomes dns support
* :star: containers communicate within a bridge network
* :warning: containers in different networks can't communicate


$ docker network create [--drive bridge] MYNET
$ docker network create --subnet 192.168.10.0/24 --gateway 192.168.0.1 myCustomNet192
$ docker run --rm -it --name container1 --net MYNET -d nicolaka/netshoot
$ docker run --rm -it --name container2 --net MYNET nicolaka/netshoot /bin/bash
container2# ping container1

$ docker network connect MYNET2 container2 # one container can be connected to multiple networks (eg. proxy)
$ docker network disconnect container2

## host
* fixed ip address
* with communication between containers
* only one *host* network is allowed

$ docker network create --drive host MYNETWORK
$ docker run nginx --network=host


## none
* no ip address
* no communication between containers
* only one *none* network is allowed

$ docker run nginx --network=none

## macvlan
* own physical mac-address for each container

## ipvlan
* own physical ip-address for each container




## clean up
$ docker network rm NAME|ID
16 changes: 15 additions & 1 deletion exasol/SELECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,21 @@ https://docs.exasol.com/db/latest/sql/select.htm
(POS | EXPR | ALIAS) [asc | desc] [nulls (first|last)]
## limit

## union all
https://docs.exasol.com/db/latest/sql/table_operators.htm
A+B

## union
https://docs.exasol.com/db/latest/sql/table_operators.htm
A+B
without duplicates

## minus
A-B
without duplicates
https://docs.exasol.com/db/latest/sql/table_operators.htm

## intersect
## minus
A*B
without duplicates
https://docs.exasol.com/db/latest/sql/table_operators.htm
13 changes: 6 additions & 7 deletions exasol/diff_compare.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@
col4
from t02 ),

t1_nur as ( select 'T1 only' as SRC, t.* from ( select * from t1 minus select * from t2 ) as t ),
t2_nur as ( select 'T2 only' as SRC, t.* from ( select * from t2 minus select * from t1 ) as t ),
t1_t2 as ( select 'both' as SRC, t.* from ( select * from t2 union select * from t1 ) as t ),
t1_nur as ( select 'T1 only' as SRC, t.* from ( select * from t1 minus select * from t2 ) as t ),
t2_nur as ( select 'T2 only' as SRC, t.* from ( select * from t2 minus select * from t1 ) as t ),
t1_t2 as ( select 'both' as SRC, t.* from ( select * from t2 intersect select * from t1 ) as t ),

t1_t2_src as ( select * from (
t1_t2_src as (
select * from t1_t2
union all select * from t1_nur
union all select * from t2_nur
) order by 2
)

-- select * from t1_52_src;
--select * from t1_52_src order by 2;

select SRC, count(*)
from t1_t2_src
group by SRC
union all select 'T1 total', count(*) from t1
union all select 'T2 total', count(*) from t2
;
;
44 changes: 44 additions & 0 deletions exasol/operators.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Exasol operators
https://docs.exasol.com/db/latest/sql_references/predicates/overview.htm
https://docs.exasol.com/db/latest/sql_references/operators/overview.htm

## Predicates precedence
1. =, !=, <, <=, >, >=
2. [NOT] BETWEEN, EXISTS, [NOT] IN, IS [NOT] NULL, [NOT] REGEXP_LIKE, [NOT] LIKE, IS [NOT] JSON
3. NOT
4. AND
5. OR

## Operators precedence
1. +, -, PRIOR, CONNECT_BY_ROOT (unary)
2. ||
3. *, /
4. +, - (binary)

## NULL in AND and OR
-- symmetric behaviour
-- https://docs.exasol.com/db/latest/sql_references/predicates/logicaljoinpredicates.htm


select * from (

select null as "EXPRESSION", null as "RESULT"
union select 'TRUE and NULL', TRUE and NULL -- = NULL
union select 'FALSE and NULL', FALSE and NULL -- = FALSE
union select 'NULL and TRUE', NULL and TRUE -- = NULL
union select 'NULL and FALSE', NULL and FALSE -- = FALSE
union select 'NULL and NULL', NULL and NULL -- = NULL
union select 'TRUE or NULL', TRUE or NULL -- = TRUE
union select 'FALSE or NULL', FALSE or NULL -- = NULL
union select 'NULL or TRUE', NULL or TRUE -- = TRUE
union select 'NULL or FALSE', NULL or FALSE -- = NULL
union select 'NULL or NULL', NULL or NULL -- = NULL
union select 'not NULL', not NULL -- = NULL

)
where EXPRESSION is not null
order by 2,1
;

25 changes: 0 additions & 25 deletions exasol/operators.sql

This file was deleted.

Loading

0 comments on commit 606d953

Please sign in to comment.