Software engineering and personal development

Tag: developer (Page 1 of 2)

How to Assign Multiple Variables in a Single Line in Python

assorted-color mugs on rack
Photo by Eric Prouzet on Unsplash

One of the first things that you learn when you start to program is learning how to declare a variable and assign to it a value.

For example, you are told to assign a string and then print it in a console:

Now, if we want to assign another variable in there, our intuition can be to just add a new line, and assign it there:

Continue reading

10 Quick Python Snippets That Can Help You Work with Dates

Photo by Brad Neathery on Unsplash

If you use Python in your work, or simply for scripting, chances are that there will come a point in time when you are going to need to work with dates.

It can be doing a conversion from one format to the other one, changing the timezone, etc.

Since you have already decided to read this article, then why don’t we stop wasting time talking and just start immediately learning?

1. Convert a string into a date

Despite being engineers, we still spend a considerable amount of time using a natural language to talk.

Since that is the case, we can also convert a string looking like a natural phrase into a date as shown below:

In this example:

  • %d — represents the day of the month, like 21, 22, 23, etc.
  • %B — represents the actual name of the month like January, February, March etc.
  • %Y — represents the year, like 2020, 2021, etc.

2. Convert from one timezone to another one

As we are mostly working remotely these days, we may have the chance to also work with someone who is in another timezone.

You can of course just Google and find out what time it is now in New York City even if you have never been before, but there is joy in implementing this yourself.

Let’s see how to do that.

3. Find the number of days between 2 dates

Since we still live in this universe where time passes, we may need to find the number of days that have passed between one point and another one.

We can of course pull up a calendar and manually count the days, which is slow and boring.

To do that quickly, we can import the date module in our Python script and initially prepare the dates:

After that, we can basically just find the difference between 2 numbers:

Yes, it’s that simple.

You do not have to spend hours doing it manually on a physical calendar. It can take barely a few moments to do it like this.

4. Add days to a date

Let us imagine that you are working on a feature of a product in which the subscription for a user expires 90 days from now. You want to save up that date in the database using the following:

5. Add weeks to a date

You can also just change that to weeks, like the following:

6. Subtract days from a date

Have you ever wanted to go back in time and improve something in your life, stayed more with your loved ones, or simply start investing in Bitcoin a little bit earlier?

Well, I wish I could tell you how to do that.

However, if you want to find a date in the past, let’s say 180 days from now, you can easily do that using the following:

7. Subtract weeks from a date

As you may have guessed already, you can also find a date by subtracting weeks:

8. Find the difference between 2 dates in months

We can also find the difference between the 2 dates in months quite quickly.

We should keep in mind that we may have dates that are in different years, and it’s not enough to think that we can just subtract two months.

For example, between October 2018 and November 2021, there isn’t just a month difference. There is also a difference in years as well.

9. Put days before months

The majority of the world puts days in front of months in their dates:

Image: John Harding/Mona Chalabi Photograph: John Harding/Mona Chalabi

However, there can be cases when you get as input a date where the month is in front of the day.

If you want to convert those dates in the format that the majority of the world uses, here is how:

10. Find the first day of the month

In some companies, they pay their employees on the first day of every month.

If you want to know what day of the week will that be, then this snippet can be helpful:


That’s pretty much it. I hope you learned at least something in this article.

Why Software Engineers Need to Know Their Way Around Hardware

Image source: https://images.pexels.com/photos/6804581/pexels-photo-6804581.jpeg


When we code programs, hardware is often the last thing we think about. After all, we have intuitive compilers to handle system translations for us. They can even check our errors for free. Plus, if our computers run the programs perfectly, then there’s no need to think about how they do it.

However, this couldn’t be further from the truth. Here’s why software engineers need at least basic hardware knowledge.

Continue reading

Add a few helpful GitHub features using Enhanced GitHub

Image source: Chrome Web Store

GitHub is one of the most popular version control repositories. In it, you can find countless public projects in many programming languages.

I have already written an article about DownGit, which gives you the ability to create a download link for GitHub projects. This is a Chrome extension that you can use to add additional functionalities that can be helpful to you from time to time.

Continue reading

The difference between libraries and frameworks with analogies

Img source: geeksforgeeks.org

Software developers use the words libraries and frameworks very frequently and interchangeably, but they are not the same. Koushik Kothagal, who is a really good programming instructor, with a lot of helpful tutorials, especially for Java technologies, has published a really great video explaining both of these concepts and is really easy to understand and follow.

Continue reading

A quick shortcut for quickly navigating in Github repositories

GitHub is one of the best places for developers to store their projects, collaborate with other colleagues, and learn from other open source projects as well. These type of projects are written in different programming languages, usually using different frameworks. As these frameworks or developers in general usually possess certain ways of organizing their code files into many folders, it makes it a bit difficult to navigate through them manually in GitHub.  Luckily there is a really helpful shortcut that help with that. Continue reading

« Older posts

© 2024 Fatos Morina

Theme by Anders NorenUp ↑