Quick Tips
VSCode Tricks for Web Development
Select Everything in the Outer HTML Element There is no shortcut for this by default but we can create one with the following steps: Now you can select the contents of the outer element in the DOM with the shortcut Ctrl + Shift + A. Move the Selected Rows (or the Row of the Cursor)…
Troubleshooting Web Applications Deployed with CapRover in Docker Containers
Jump into the terminal of a CapRover app named testapp. Use Ctrl + P, then Ctrl + Q to exit that terminal without killing the container. Logs of the deployed application (–follow keeps retrieving the latest events): CapRover logs: Logs for Docker itself (if your application keeps getting respawned in new containers, the answer may…
SFTP File Operations with Python Using an SSH Key
Below are some functions to read, write, and delete a file, list a directory, and check if a file exists in a remote SFTP server with Python. I have written these specifically for working with CSV files and pandas data frames. The argument file in the functions below should be the full path to the…
12 Principles for Building Software as a Service Apps
The Twelve Factors: # Factor Description I Codebase There should be exactly one codebase for a deployed service with the codebase being used for many deployments. II Dependencies All dependencies should be declared, with no implicit reliance on system tools or libraries. III Config The configuration that varies between deployments should be stored in the…
How to Take a Screenshot of a Website in Python Silently with Selenium
The code below will make a browser 1920px wide, and as long as the page and take its screenshot: If the page needs to load asynchronously to complete building the DOM, you may need to give it a few seconds before taking the screenshot: If the page requires scrolling down to load the rest of…
Changing the Directory Used by Docker
If you want to have the docker images kept in another directory, such as a mounted volume: Then place the following after updating “/mnt” with your target path. Restart Docker: The old Docker directory will not be used anymore so you can remove it by:
Downloading All Files in a Directory from a Jupyter Notebook Server
Problem When you are following a tutorial with exercises on a Jupyter Notebook Server, you may want to download and work with those files locally, but there is no obvious way to download all files as the Download button disappears when multiple files/folders are selected. Solution Step 1 Click on the Jupyter logo on the…
Splitting Flask Routing Functions into Different Modules
We can put group-related routing functions into separate modules to keep a big project organized and avoid having one long views.py in your project. For example, we can take the login and sign-up-related functions from views.py and move them into a module named auth.py. In auth.py, we need to register a new blueprint: In auth.py:…
How to Remove A Single Commit From 3 Commits Ago
Run the following: You will see your commits as seen below. Replace the word pick with drop for the commit you want to remove. Then, force push to remote: That’s all!
Installing GeoPandas with Its Dependencies, without installing Microsoft Visual C++
The Problem If you try to install GeoPandas with pip install geopandas, you may get an error like below. Since you don’t have the dependency GDAL installed, the installer cannot find the config and exits. Then you try installing gdal with pip install gdal and you get another error saying: The Solution Christoph Gohlke from…