Tag Archives: Snippet
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…
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…
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:…
Python Shortcuts
*args and **kwargs Combine lists with zip() For Else and While Else Inline conditions Unpack a collection of items and assign them to variables Assign multiple variables in one line Initialize a collection in one line Itertools
How to Solve “File [scriptName].ps1 cannot be loaded because running scripts is disabled on this system.” Error on Windows
Open the PowerShell as an administrator and run: Source: https://stackoverflow.com/a/4038991/1937377
How to Show or Hide Mounted Drives on Gnome Dock in Ubuntu
Hide Mounted Drives from Dock Show Mounted Drives on Dock
How to Remove Default Shortcuts from Sidebar in Ubuntu (for Gnome Files)
The default shortcuts are controlled by the file below. Just edit it and comment out the lines corresponding to the undesired items. Then restart file manager: