Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
tuples vs list from a different point of view. Tuples of constants can be precomputed by Python's peephole optimizer or AST-optimizer. Lists, on the other hand, get built-up from scratch:

>>> from dis import dis 

>>> dis(compile("(10, 'abc')", '', 'eval'))
1 0 LOAD_CONST 2 ((10, 'abc'))
3 RETURN_VALUE

>>> dis(compile("[10, 'abc']", '', 'eval'))
1 0 LOAD_CONST 0 (10)
3 LOAD_CONST 1 ('abc')
6 BUILD_LIST 2
9 RETURN_VALUE


#python #list #tuple #performance #dis #compile #ast_optimizer
Caddy is the HTTP/2 web server with automatic HTTPS. I wanted to proxy pass websocket service using Caddy but it didn't work:

wss.example.org {
proxy / myservice:8083 {
header_upstream Host {host}
header_upstream X-Real-IP {remote}
}
tls myemail@gmail.com
}


In the documentation it is mentioned that proxy can proxy pass web sockets too. The problem was about not using websocket inside of the proxy stanza, so we solved it using:

wss.example.org {
proxy / myservice:8083 {
header_upstream Host {host}
header_upstream X-Real-IP {remote}
websocket
}
tls myemail@gmail.com
}



#webserver #caddy #proxy #proxy_pass #wss #ws #websocket
For prometheus you can use an alert manager, it has a docker file in the link below:
- https://hub.docker.com/r/prom/alertmanager

Awesome Prometheus alerts:
- https://github.com/samber/awesome-prometheus-alerts

alertmanager has rules, you can see sample rules here in the following link:
- https://awesome-prometheus-alerts.grep.to/rules

So to add alertmanager service:

alertmanager:
image: prom/alertmanager:latest
restart: always
command: --config.file=/etc/alertmanager/alertmanager.yml
volumes:
- ./alert/config/alertmanager.yml:/etc/alertmanager/alertmanager.yml
dns:
- 8.8.8.8


You alert manager configuration may look something like below:

global:
resolve_timeout: 5m

route:
# When a new group of alerts is created by an incoming alert, wait at
# least 'group_wait' to send the initial notification.
# This way ensures that you get multiple alerts for the same group that start
# firing shortly after another are batched together on the first
# notification.
group_wait: 10s

# When the first notification was sent, wait 'group_interval' to send a betch
# of new alerts that started firing for that group.
group_interval: 5m

# If an alert has successfully been sent, wait 'repeat_interval' to
# resend them.
repeat_interval: 30m

# A default receiver
receiver: "slack"

# All the above attributes are inherited by all child routes and can
# overwritten on each.
routes:
- receiver: "slack"
group_wait: 10s
match_re:
severity: error|warning
continue: true

# - receiver: "sms"
# group_wait: 10s
# match_re:
# severity: error
# continue: true

receivers:
- name: "slack"
slack_configs:
- api_url: 'YOUR-WEBHOOK-URL'
send_resolved: true
channel: 'monitoring'
text: "{{ range .Alerts }}<!channel> {{ .Annotations.summary }}\n{{ .Annotations.description }}\n{{ end }}"

# - name: "sms"
# webhook_config:
# - url: http://a.b.c:8080/send/sms
# send_resolved: true


You should be up & running with this sample configurations.
Spread your love for M2SH :)

#prometheus #prom #alert #alert_manager #docker #dockerfile #slack
sudo rm -rf /life/problems

sudo apt-get install +happiness -sadness
سوپرمن میخوان یا برنامه نویس؟؟؟
In order to checkout all files in a project in GIT:

git checkout -- .


#git #checkout
Forwarded from Quera
🔹مسابقاتِ برنامه‌نویسیِ Backend و Frontend تومن

در این مسابقه سوالاتِ🔹بک‌اند، Python و Django و 🔹فرانت‌اند Front-End و Reactjs‌ می‌باشد.

👈علاقه‌مندان میتوانند به صورت مجزا در این دو مسابقه شرکت کنند.
🔹همراه با ۳ میلیون جایزه نقدی

☝️از نفرات برتر این مسابقه جهت استخدام در شرکت تومن دعوت به عمل می‌آید.
زمان مسابقه: ۲۱ تیرماه روز جمعه

ثبت‌نام از در این مسابقه از طریق:👇
🔹https://quera.ir/r/dpi1h

@Quera_ir
Did you know that python print command takes sep argument as a separator between string arguments?

print('ali', 'reza', sep=', ') # output: ali, reza


#python #print #sep #separator