Tech C**P
14 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Bamilo has reached its end!

The ecommerce website Bamilo which tried hard to combat with Digikala has closed down. The domain now redirects to snapp market:

- https://www.bamilo.com/

#bamilo #digikala #failure #ecommerce #snapp
DO NOT USE UWSGI multi-threaded mode with alpine image!

I've been stuck on this issue for a couple of days as our service returned 503 Gateway timeout while our server load was totally ok around 1.0 (1m load average). So our load test got failed at the be beginning of the test! We found out it is related to docker base image of python alpine. Use python slim image instead. Or in case you have many changes you can stick with alpine and change thread to 1 in uswgi configuration file.


#docker #alpine #uwsgi #python #slim #respawn
Do you log a lot like me in your Python modules? If so, you had the same problem to always find the first occurence of a log after time, filename, etc. Let's clarify this with a sample log:

[2012-10-02 application.py:1 _get()] DEBUG: this is a log content
[2012-10-02 db.py:1005 _fetch_all_info()] INFO: this is a log content


You can see that both have the same log content but it's hard to follow cause of length of file name, line number and function name. To format this better we can have space padding in formatters. spaces are identified by `s. Now lets see the same log, but this time with space padding.

The formatter is as below:

[%(asctime)s %(filename)15s:%(lineno)4s %(funcName)20s()] %(levelname)s %(message)s


NOTE: this is not the exact formatter for the above log, it is for demonstration!


Now the output will something like below:

[2012-10-02   application.py:    1               _get()] DEBUG: this is a log content
[2012-10-02 db.py: 1005 _fetch_all_info()] DEBUG: this is a log content


You can see that log content is so much easier to follow by using space padding. It may not be obvious on telegram with small devices. So try it your self :)))

#python #logging #log #logger #formatter #log_formatter #space_padding #padding
How does kubernetes scheduler work? Stripe engineer Julia Evans has written a delightfully clear explanation of how sched‐
uling works in Kubernetes.

https://jvns.ca/blog/2017/07/27/how-does-the-kubernetes-scheduler-work/


#containerization #kubernetes #scheduler #pods #kubectl
In Debian based OSes if you want to install Postman you need to download the binary package and run it everytime you need. But there is a better way for it that you can access Postman system wide. There is
gist in github for it:
- https://gist.github.com/SanderTheDragon/1331397932abaa1d6fbbf63baed5f043

Download shell and run it! (Be careful and read any shell script before running it, I've read it myself)

Now you can add it to favorites and have instant access to it.

Spread your love for m2sh :)))

#postman #debian #ubuntu #shell #gist #github
Enable workmode in Telegram:

open settings in telegram desktop and without clicking anywhere type workmode a dialog will open to confirm that want it to be enabled. After telegram restart you willl have a new bar above chat accounts -> Hide muted chats click on it to hide muted chats from the left pane.

Spread your love for m2sh :)

#telegram #trick #fun #workmode #work_mode
In order to enable bash completion in Kubernetes you can usee the below command in linux bash:

source <(kubectl completion bash)


Now to test this enter the below command and you should see the completion:

kubectl cl<TAB>


It should be expanded to kubectl cluster-info.


#linux #bash #shell #kubernetes #kubectl
EMQ X broker is a fully open source, highly scalable, highly available distributed MQTT messaging broker for IoT, M2M and Mobile applications that can handle tens of millions of concurrent clients.

Starting from 3.0 release, EMQ X broker fully supports MQTT V5.0 protocol specifications and backward compatible with MQTT V3.1 and V3.1.1, as well as other communication protocols such as MQTT-SN, CoAP, LwM2M, WebSocket and STOMP. The 3.0 release of the EMQ X broker can scaled to 10+ million concurrent MQTT connections on one cluster.

https://github.com/emqx/emqx


#github #emqx #mqtt #pubsub #wss #ws #websocket #web_socket
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 [email protected]
}


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 [email protected]
}



#webserver #caddy #proxy #proxy_pass #wss #ws #websocket