See more details here https://r4ven.fr/en/blog/ubuntu-compress-pdf-nautilus/
Tuesday, December 16, 2025
Monday, December 15, 2025
updating fonts in ubuntu
To bulk install fonts in Ubuntu, copy font files (.ttf, .otf) to ~/.local/share/fonts/ (for your user) or /usr/share/fonts/ (system-wide), then run fc-cache -fv in the terminal to update the font cache, or use the graphical Font Manager by dragging and dropping them in.
Thursday, December 11, 2025
non-blocking network calls when using asyncio in python
To avoid blocking your Event Look in Python when using asyncio, do not use `requests` but use `aiohttp`
Here is some example code. `aiohttp` gives us a session that works well on the asyncio Event Loop.
import aiohttp
import asyncio
async def fetch_real_url(session, url):
async with session.get(url) as response:
return await response.text()
async def main():
async with aiohttp.ClientSession() as session:
urls = ['http://python.org', 'http://google.com', 'http://example.com']
# Create a list of tasks
tasks = [fetch_real_url(session, url) for url in urls]
# Run them all at once
responses = await asyncio.gather(*tasks)
print(f"Downloaded {len(responses)} pages concurrently.")
if __name__ == "__main__":
asyncio.run(main())
Other useful things...
- `async` returns a coroutine object that can be scheduled.
- Calling this function returns a `future` — a placeholder for a result that hasn't happened yet. It tracks the state (Pending, Finished, Cancelled).
- The Event Loop is single-threaded. The Event Loop serves as a scheduler of these tasks.
Subscribe to:
Comments (Atom)