semaphores are a little asymmetric, let’s see how.
Semaphore is a synchronization construct in concurrent programming. But do you know about the asymmetric behavior of semaphores?
Let’s see some definitions.
A semaphore is an object with two methods Wait and Signal, a private integer counter and a private queue (of threads)
wait: Decrements the value of the semaphore variable by 1. If the new value of the semaphore variable is negative, the process executing wait is blocked (i.e., added to the semaphore’s queue). Otherwise, the process continues execution.
signal: Increments the value of semaphore variable by 1. After the increment…
Let’s make Boomerang ( by Instagram) like gifs.
Knowledge grows exponentially. The more we know, the greater our ability to learn, and the faster we expand our knowledge base — Dan Brown
True it is!
If you haven’t read Part1 of the series, go read it here.
This time let’s learn a few more handy and elegantly powerful methods from Moviepy.
We will do it via an example. Say we want to make a funny gif which plays forwards and backwards ( just like Boomerang from Instagram)
I love cats ( just like everyone else 😅). I found a funny…
Moviepy is a video editing library in python.
In this series I’ll try to explain how to use Moviepy to get things done.
To get started you need to have python installed on your system. You can refer to this article for setting up python on mac, this one for linux based systems. Once you have python on our system, you can install Moviepy with the instructions on it’s github page.
Let’s get started with some basic terms related to videos.
A Video in general, is a sequence of image frames played at a certain fps. Every video has certain…
This article explains an example of how to use numpy indexing efficiently.
Let’s start with a simple example of transforming elements of an array by an arbitrary transformation rule.
Say you have a 1D array of integers named source which you want to transform into 1D array of integers named result using the lookup table named lookup_table.
source = [0,2,3,1,4,5]lookup_table = [11,22,33,44,55,66]
How to perform lookup?
To find the mapping of an integer n read nth element in lookup_table.
If we apply above transformation rule to source array, we would get
result = [11,33,44,22,55,66]
A naive python code for…
HPC Engineer @ R&D Lab