You just received your regular paycheck. Finally, after all those weeks of hard work and not having enough sleep, you finally reaped the fruits of your labor. After a few days, you checked your bank account and most of your fresh money just disappeared. You ask yourself, “Where did my salary go?“.
This is a common occurrence nowadays. People sometimes feel like they don’t see any rewards from their work as most of their paycheck just seems to vanish every month. While we need to pay our dues and bills and our costs of living, do you honestly know where your salary is going?read more
One day I was listening to a podcast where the host interviews a businessman. At the end of the interview the host asked, “What are the things you do that make you successful?“. The businessman answered: “The reason I am successful is not because of what I do today. I owe everything to 2011 me. All his hard work, his grit, and his networking efforts paid off.“
That got me thinking: am I thankful for past me? Do my actions decades ago produce something good today?
I thank 2012 me. I accepted a job from something that I have not tried before, and I was not really expecting much. It turns out to be work that boosted my income and still something I enjoy even after seven years.read more
You may have heard people talk about bad things that happened to someone else. “Poor guy, he lost his job“, “She was diagnosed with breast cancer“, or “They lost their child” are some of the examples. When this happens we may feel shocked and sad for the other person. We may even think “Thank God that did not happen to me!“.
But what if it happened to you?
Shadow boxing is an important technique used in combat sports, especially boxing. It does not involve any equipment, only yourself. Typically you do this with an imaginary opponent, or you can just do it in front of a mirror (so your enemy is you). This can even be used to “simulate” an upcoming fight against an opponent as you imagine him standing in front of you.read more
I have been using Ruby professionally for more than a decade now. Until recently, I haven’t explored much outside of the Ruby and Rails community. That changed however after I completed a course in Foundations of Data Science. This made me curious about Python and how to build applications using it.
Python and Ruby have many similarities. Both are interpreted, high-level programming languages. Python also has support for Object-Oriented Programming and Functional Programming. In terms of syntax, they have a similar look and feel, aside from some fundamental differences such as Python being indent-driven.
You may find this article to be very similar to the Ruby on Rails guide I posted years ago. This is not accidental since my goal is to introduce Python web application development to someone who is already familiar in the Ruby space.
The very first step is to install Python itself in your computer. I recommend using pyenv to manage your Python versions. pyenv is a Python version manager, like rbenv. In fact, pyenv is a fork of rbenv and is re-purposed for Python. To install pyenv:
curl https://pyenv.run | bash
After installing, update your login shell configuration by adding the following, e.g. in ~/.zshrc
Then, we can easily install a Python version, like 3.6.8 in this example:
pyenv install 3.6.8
If you are having trouble installing Python, it could be related to the OpenSSL version installed in your machine.
On Debian stretch (and Ubuntu bionic), libssl-dev is OpenSSL 1.1.x, but support for that was only added in Python 2.7.13, 3.5.3 and 3.6.0. To install earlier versions, you need to replace libssl-dev with libssl1.0-dev. This is being tracked in https://github.com/pyenv/pyenv/issues/945.
Once Python has been installed, you can opt to set the version (e.g 3.6.8) as your global version. This makes the Python executable available to all terminal sessions:
pyenv global 3.6.8
pip is Python’s package manager, like rubygems or npm. If you installed Python, pip should also be available for you. If for some reason it is not installed, you can install it using the guide here.
In Ruby/Rails we use the awesome library Bundler to handle application package management. We manage the packages using a Gemfile, and it gets converted into Gemfile.lock.
pipenv is similar to bundler, but its functionality extends beyond package management in the application. In this article we will use it similar to bundler so it will handle all the application package dependencies. To install pipenv, just use pip!
pip install pipenv
To specify the application packages, pipenv uses a Pipfile. An example is given below:
[[source]] name = "pypi" url = "https://pypi.org/simple" verify_ssl = true
Code linters such as Rubocop ensure consistent, clean code throughout your application. If all developers are using the same linter configuration, then you can be sure that any code that you encounter is organized in the same way regardless of the author.
One challenge in using linters is that it should have immediate feedback, or else it may disrupt the coding flow of the user. For example, you can run the linter manually after you make your changes, but as this is a manual process it can be easily forgotten.
To solve this, we can use pre-commit hooks (such as in git) to automatically run the linter script whenever we try to commit our changes. In this manner, it is an automated process and so will not be skipped in development.