There are a few different approaches for writing tests for date and/or time-sensitive functionality. One could choose to add a sleep() in the test, which would guarantee that the time passed, but that also has the downside of increasing the run time of the test. Another option is to reach out to external libraries or … Continue reading TIL: time travel with Python’s standard library
Tag: quick-tip
The difference between HTTP status codes 401 and 403: Unauthorized and Forbidden
You are working with an API and after sending a request you receive one of these two HTTP response codes: 401 or 403. What do HTTP status codes 401 and 403 mean? Official specification If you search for the official specification, this is what you get: 401: Unauthorized The 401 (Unauthorized) status code indicates that the request … Continue reading The difference between HTTP status codes 401 and 403: Unauthorized and Forbidden
A caller id for your python function
Most of you might be too young to know this but there was time that the phone in your house - not in your pocket! - would ring and gasp! you had no idea who was calling! You had to ANSWER the phone to find out. 🤦♀️ Now we have caller ID and know exactly … Continue reading A caller id for your python function
Go to line number in a file using vim
You want to see line 3842 of file called my_super_long_file.py and you can only access that file using vim. You open the file and to your dismay, by default, vim doesn't display line numbers. Here are your options: Arrow down and hope you find that line before retirementDisplay the line numbers by hitting : and … Continue reading Go to line number in a file using vim
TIL: How to move a line in Vim
For a text like the following: This is the line I want to move. This line should be the first line. In order to move the first line down, in normal mode* (not edit or insert mode), follow these steps: place the cursor at the beginning of the line you want to move - in … Continue reading TIL: How to move a line in Vim
TIL: Create and deploy a serverless function in AWS
Only two steps required (it assumes an existing account in AWS console): Create a Lambda function in AWSDeploy your Lambda function with AWS API Gateway I used these two articles as a reference: Going Serverless: how to run your first AWS Lambda function in the cloudWorking with Amazon API Gateway Important notes the lambda function … Continue reading TIL: Create and deploy a serverless function in AWS
Do I need to indent my Python code? What about JavaScript?
Yes! Indentation, or leading white space at the beginning of a line is required in Python. You can read more about why that is important here. And here is the part of the style guide convention for indentation (PEP 8). In JavaScript on the other hand, white space is added for readability only but it … Continue reading Do I need to indent my Python code? What about JavaScript?
Sending docker container logs to a separate file
In a large web application, the backend logs can get quite verbose: requests created, sent, processed, received, etc. The list can grow large very quickly depending on how logs are implemented. You can check the logs from a Docker container using docker logs, no need to exec into the container: docker logs <container_id> You can … Continue reading Sending docker container logs to a separate file