Notes


1. How to explore different git branches and look for something, quickly?

In some occastions, you may face a repo of a legacy code with many branches. And, you may need to look for something in those branches as you do not know exactly which branch has that item. For instance, I recently encountered a repo with many branches and I needed to look for a few specific terms. How should I do that? One idea is to just do `git checkout ` and then search in some of its directories. For that latter part (i.e. searching in directories), I can use `grep` command in terminal to check all files in a directory. But, what about the branches? I can execute the git command from a shell script that iterates over all branches. For the sake of simplicity, I am going to do it for the local branches only.

Here is the script:

And, that's it! Hope you have enjoyed it.

2. You may have noticed *args and **kwargs in some Python code. What are they?

These two are used to pass a variable number of arguments to a function. The *args will take the positional arguments and give them to you as a tuple. The **kwargs will give you the keyword arguments as a dictionary! But, what are positional and keyword arguments? Let's learn this by checking an example.

In the above example, we have a function called `example_func` that takes two positional arguments and two keyword arguments. The positional arguments are `arg1` and `arg2` and the keyword arguments are `kwarg1` and `kwarg2`. It is called positional because the order of the arguments matters. On the other hand, the keyword arguments are called so because they are identified by their names. So, the order of the keyword arguments does not matter. Note that all keyword arguments must come after the positional arguments. Okay! Now, let's say you want to write a function that takes a function and its arguments as input and then executes the function with those arguments. For instance, you want to have a function that determines whether the output of another function is None or not! How would you do that? You can use *args and **kwargs to do that!

Note that I do not know how many arguments the function `func` takes. So, I use *args and **kwargs to pass the arguments to it. So far, we have not digged into the details of *args and **kwargs. Now, let's see how they store the information!

Let's say I want to pass `example_func` as the first argument of the function `check_return`. So, I can do it like this:
`check_return(example_func, 1, 2, kwarg1=3, kwarg2=4)`
And then, this is what we will have:
args = (1, 2)
kwargs = {'kwarg1': 3, 'kwarg2': 4}
So, whenever we pass this as *args and/or **kwargs, it will expand them again and pass them to function!

3. How to use AI to boost your resume?

Ref: Coursera Career Advice One way to boost your resume according to a job posting is to provide a prompt that does exactly that! You are an Applicant Tracking System programmed by a professional recruiter to identify candidates for an open job role with the following requirements: Please revise and rephrase my resume WITHOUT ADDING ANYTHING ON YOUR OWN to have better match with those requirements.