Skip to content

Instantly share code, notes, and snippets.

View koladev32's full-sized avatar
🏠
Working from home

Mangabo Kolawole koladev32

🏠
Working from home
View GitHub Profile
from weasyprint import HTML
HTML('https://koladev.xyz/blog/django-docker-aws-nginx-letsencrypt/').write_pdf('blog.pdf')
@koladev32
koladev32 / script.py
Created November 14, 2021 13:24
Download Youtube Video with Python
from pytube import YouTube
YouTube('https://youtu.be/dQw4w9WgXcQ').streams.first().download()
@koladev32
koladev32 / center-element.css
Created July 6, 2020 02:14
If you are confused on how to center element in CSS, here is some code to help you.
/*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;
@koladev32
koladev32 / syncmeteo.py
Created September 3, 2019 22:03
Introduction to asynchronous programming with python Part 1 : asyncio your code
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
@koladev32
koladev32 / asyncmeteo.py
Created September 3, 2019 22:00
Introduction to asynchronous programming with python Part 1 : asyncio your code
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:
@koladev32
koladev32 / awaitables.py
Created September 3, 2019 21:57
Introduction to asynchronous programming with python Part 1 : asyncio your code
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:
@koladev32
koladev32 / synchello.py
Last active September 3, 2019 21:55
Introduction to asynchronous programming with python Part 1 : asyncio your code
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()
@koladev32
koladev32 / asynchello.py
Created September 3, 2019 21:52
Introduction to asynchronous programming with python Part 1 : asyncio your code
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__':
@koladev32
koladev32 / example2.py
Created September 3, 2019 21:40
Introduction to asynchronous programming with python Part 1 : asyncio your code
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
@koladev32
koladev32 / example1.py
Last active September 4, 2019 19:18
Introduction to asynchronous programming with python Part 1 : asyncio your code
import urllib2
print(urllib2.urlopen(url).read()) #line3
print("Hello") #line 4