This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from weasyprint import HTML | |
| HTML('https://koladev.xyz/blog/django-docker-aws-nginx-letsencrypt/').write_pdf('blog.pdf') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pytube import YouTube | |
| YouTube('https://youtu.be/dQw4w9WgXcQ').streams.first().download() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*Center element horizontally and vertically*/ | |
| .has-element-at-center { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| /*Center element horizontally*/ | |
| .has-item-centered-horizontally { | |
| display: flex; | |
| justify-content: center; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| url_req ='https://www.prevision-meteo.ch/services/json/' | |
| def get_meteo(city:str): | |
| """Get the temperature of the city given in params""" | |
| s = time.perf_counter() | |
| r = requests.get(url=url_req+city) | |
| temp = r.json() | |
| elapsed = time.perf_counter() - s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import aiohttp | |
| url_req ='https://www.prevision-meteo.ch/services/json/' | |
| async def get_temp(city:str): | |
| """Get the temperature of the city given in params""" | |
| print(f"Request for {city}.") | |
| s = time.perf_counter() | |
| async with aiohttp.ClientSession() as session: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| async def nested(): | |
| return 42 | |
| async def main(): | |
| # Nothing happens if we just call "nested()". | |
| # A coroutine object is created but not awaited, | |
| # so it *won't run at all*. | |
| nested() | |
| # Let's do it differently now and await it: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def hello(): | |
| print('Hello') | |
| time.sleep(2) | |
| print('World') | |
| def main(): | |
| for _ in range(3): | |
| hello() | |
| if __name__ == "__main__": | |
| import time | |
| s = time.perf_counter() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| async def hello(): | |
| print("Hello") | |
| await asyncio.sleep(2) | |
| print("World") | |
| async def main(): | |
| await asyncio.gather(hello(),hello(),hello()) | |
| if __name__=='__main__': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib2 | |
| list_urls = get_thousand_urls() | |
| content = [] | |
| for url in list_urls: #url_task | |
| content.append.urllib2.urlopen(url).read() | |
| print("Hello") | |
| #other tasks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib2 | |
| print(urllib2.urlopen(url).read()) #line3 | |
| print("Hello") #line 4 |