Cancellation Token Pattern in Python

Hello! 👋 The Cancellation Token Pattern article is a pattern inspired by C#’s CancellationToken struct and Golang’s context package. The main idea of the pattern is to allow the user of an API to cancel its operations, but in order for this pattern to work, the API must be written with the cancellation token pattern in mind. To use the pattern, you need a class that represents a cancellation token. Here’s my simple version:...

March 9, 2024 · 3 min · Denis Nutiu

Image tagging with Deep Learning

Hello everyone 👋, I’ve been playing with FastAI and deep learning for a week or so and I’ve decided to combine my passion for software with my passion for photography. I’m working on an app or maybe a library that allows you to generate tags for a photo. For an amateur photographer like me it’s quite useful as I don’t always have inspiration to write tags for my photos and sometimes the tags I write are inconsistent....

July 2, 2023 · 3 min · Denis Nutiu

Deploy a FastAI model with FastAPI

Hello everyone 👋, In this quick post I’ll show you how to deploy a FastAI model using FastAPI. It’s a follow-up to my previous post from here and it is partially based on this FastAI lecture: Exporting the Model Before we create the API, we need to export the model as a pickle file. Add learn.export("<path>/cat_or_dog.pkl") with the full absolute export path at the end of the script: # ... learn = vision_learner(dls, resnet34, metrics=error_rate) learn....

June 21, 2023 · 2 min · Denis Nutiu

FastAI GPU Support

Hello everyone 👋, This is my first blog post about AI, it’s a quick post on how to enable GPU support for the FastAI library. I have avoided getting into AI for some time now, I thought that it would involve lots of complicated math, and I was not sure that it would be worth the effort, I did not get very good grates in my college math classes 😅....

June 20, 2023 · 3 min · Denis Nutiu

Overflowing Buckets

Hello everyone 👋, Today I want to share with you a problem I’ve encountered along my journey. The problem is fairly simple: You have a finite number of water units. You have a finite number of buckets. You need to distribute the water units into the buckets. Each bucket has a maximum capacity. When a bucket is full, the water overflows into the next two buckets by splitting evenly. You need to print the number of the buckets that are full....

June 15, 2023 · 3 min · Denis Nutiu

Getting Started with pdoc3 for Python

Hello everyone! 👋 In this article we’ll talk about documentation and how to document a Python project with pdoc. Documentation is an essential part of writing high-quality Python code. Not only does it make your code easier to understand, but it also makes it more maintainable and reusable. In this post, we’ll explore how to use pdoc to generate documentation for your Python code. pdoc is a powerful tool that can automatically generate documentation for your Python modules and classes based on their docstrings....

April 13, 2023 · 4 min · Denis Nuțiu

LeetCode: Removing Stars From a String & Simplify Path

Hello 👋, I’ve started doing some LeetCode dailies with Paula and I’d like to share our solutions for the last two problems. I also want to warmly welcome the new subscribers! Thank you for subscribing! If you want to attempt the problems by yourself then stop reading otherwise you’ll be spoiled with solutions. Removing Stars From a String In this problem you are given a string with stars ‘*’ and when you encounter a start you’ll need to remove the start along with the character to it’s left....

April 12, 2023 · 2 min · Denis Nuțiu, Paula Rusti

LeetCode: Boats to Save People

Introduction Hello everyone! 👋 I’ve been practicing with some Leetcode daily challenges lately and since I’ve recently moved to Substack I wanted to make my first post here 😁 Boats to Save People The problem Boats to Save People is solved using a Greedy approach. Given a number of people and their weights, along with a carry limit for the boat. You must find the number of boats needed to carry the people....

April 8, 2023 · 2 min · Denis Nuțiu, Paula Rusti

Parallel Processing in Python with concurrent.futures

Hello 👋, In this short article I want to talk about parallel processing in Python. Introduction Sometimes you will need to process certain things in parallel. If you’re using Python you may know about the global interpreter lock abbreviated GIL for short. The GIL is a lock that allows only a single thread to control the Python Interpreter at a time (per process), that means that your multi-threaded Python program will have only a single thread executing code at the same time....

March 18, 2023 · 3 min · Denis Nuțiu

Python Singleton Pattern implementation with LRU

Hello and happy new year! 🥳🙌 I’ve made a video on how to implement the singleton pattern in Python using the LRU cache. Thank you!

January 7, 2023 · 1 min · Denis Nuțiu