Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
با درود خدمت تمامی متخصصین نرم افزار
اینجانب به نمایندگی از گروه مشاورین مالی قرن طلایی فعال در حوزه استراتژِی نوین مالی هوشمند
در جهت تولید و بروزرسانی محصولات جدید در این حوزه.
به دنبال شناسایی و جذب و همکاری با دو نفر از دوستان برنامه نویس آزاد و خلاق هستم.
شرایط کاری بسیار منصفانه و مبتنی بر اصل برد برد و منافع تیمی خواهد بود .
بدین وسیله از دوستان فعال در سه مورد زیر دعوت به همکاری و گفتگوی اولیه می نمایم:
داده کاوی: Data Mining
معماری نرم افزار و الگوها
زبان های: Javascript _ Python

لطفا با شماره همراه 09126046229 تماس یا پیامک با ذکر تخصص ارسال نمایید

#job_offer #job #تبلیغات
In python you can use requests to connect to an endpoint an fetch result or create a new endpoint and so on. When you GET result from an endpoint which has an invalid https, the library will give an error. In order to solve this problem you can pass verify=False to requests.get().

A sample would be like:

payload = requests.get(url, auth=HTTPBasicAuth(username, password), verify=False)

Now another issue happens and a WARNING message appears in your log InsecureRequestWarning. You can surpass this message as well by the command below:

from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

NOTE: I have done this on a local server behind a firewall, be extremely cautious in case you want to do this on your production server.

#python #requests #InsecureRequestWarning #verify #urllib3
If you have an script and you want to clear the terminal before executing your script you can use the below control characters:

print(chr(27) + "[2J")



The above command will clear the screen by using Python

#python #chr #terminal #clear_terminal
Have you had a chance to work with Git? If so, did you know that you can work with your git repository from within python script?

GitPython python library does exactly this job:

http://gitpython.readthedocs.io/en/stable/

#python #git #push #pull #GitPython
سوال نرمش ذهن :)

میخواهیم یک دنباله از اعداد را به دو دسته تقسیم کنیم:
فرض کنید ورودی به شما nعدد میدهد، نام این لیست از اعداد را aبگذاریم.
میخواهیم aرا به دو لیست bو cتقسیم کنیم که اولا اعضای bو cبا یکدیگر اشتراک نداشته باشند،
ثانیا هر عضو از aدر یکی از لیست های bیا cباشد. مقدار مجموع اعداد لیست bرا Bو مقدار مجموع
اعضای لیست cرا Cنامگذاری میکنیم. میخواهیم این بخش بندی طوری صورت گرفته باشد که مقدار
B-Cبیشینه باشد.
ورودی:
ابتدا یک عدد nبه عنوان تعداد اعداد لیست aبه شما داده میشود، سپس در nخط بعدی اعضای
لیست aبه عنوان ورودی داده میشود: a1, a2, …, an
1 ≤ n ≤ 100
-100 ≤ a1, a2,…, an ≤ 100
خروجی:
مقدار B-Cرا چاپ کنید.
مثال:
Input
4 1 2 -3 0
Output
10
توضیح: بخش بندی بهینه به این صورت میشود:
b = {4, 1, 2, 0} وc = (-3}

در صورت رسیدن به جواب، پاسخ رو به @Pickle_Ali ارسال کنید.
سلام و خداقوت به همراهان عزیز کانال،
🔴 بزودی در کنار پادکستهای بسیار زیبای Masters of Scale دوره های آموزشی MongoDB مقدماتی قرار داده می شود (زبان اصلی)

با ما همراه باشید :)
If you use json.dumps() in order to write a json into a file, it will be wriiten all in one line. You can do more with dumps(). You can pretty print into the file with indentation using indent parameter:

dumped_json = json.dumps(json.loads(content), indent=4)


You can do more and sort json keys! To do that pass sort_keys to dumps function like below:

dumped_json = json.dumps(json.loads(content), indent=4, sort_keys=True)

#python #json #dumps #indent #sort #sort_keys
Few days ago we talk about gitPython to work with git inside of python. The code below is a sample that would do all routine tasks like pulling and pushing or commit.

1- Initiate git object in python by providing path:

from git import Repo
repo = Repo(repo_path)


2- If you want to pull results from git repo:

repo.git.pull('origin', 'refs/heads/dev')


3- Let's say you want to set username and email for git author:

config = repo.config_writer()
config.set_value("user", "email", author_email)
config.set_value("user", "name", author_name)


4- Now to add a specific file to staged:

index = repo.index
index.add([file_path])


5- Commit the staged file with a message:

index.commit(commit_message)


6- The final step is to push to a remote repo:

repo.git.push('origin', 'refs/heads/dev')

#python #git #gitPython #pull #push #author
In case you want to serve static files in your website in nginX, you can add a new location directive to your server block that corresponds to your website:

server {

# your rest of codes in server block...

location / {

location ~ \.(css|ico|jpg|png) {
root /etc/nginx/www/your_site/statics;
}

# your rest of codes...

}
}

This is it, whether it is a uwsgi proxy, fpm, etc.

#web_server #nginx #static #location #serve
Netflix has open sourced his container management system called Titus written in Go Lang. You can see documentation of it here:

- https://netflix.github.io/titus/

Source code and Docs:

- https://github.com/Netflix/titus

#container_orchestration #docker #container #golang #go #netflix #titus #aws
If you have installed mysql server and want to install MYSQL-python package, you may encounter the below error like me:

EnvironmentError: mysql_config not found


The solution is to install libmysqlclient-dev:

sudo apt-get install libmysqlclient-dev


If you have installed MariaDB then:

sudo apt-get install libmariadbclient-dev

#mysql #mysql_config #MYSQLpython