This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Place these two scripts in a directory of your choice (in this example its ~/.scripts) and make aliases of your choice for each script. Use "sudo chmod +x <script_name>" or equivalent to give them executable permission. | |
| # Example aliases | |
| ``` | |
| alias sgpt2lite="~/.scripts/sgpt2lite.sh" | |
| alias sgpt2openai="~/.scripts/sgpt2openai.sh" | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def print_color(text, color): | |
| colors = { | |
| 'black': '\033[30m', | |
| 'red': '\033[31m', | |
| 'green': '\033[32m', | |
| 'yellow': '\033[33m', | |
| 'blue': '\033[34m', | |
| 'magenta': '\033[35m', | |
| 'cyan': '\033[36m', | |
| 'white': '\033[37m', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| The script initializes a SpaCy model with configurable GPU preference. It loads the specified model, prints GPU/CPU usage based on preference, and provides the initialized SpaCy pipeline for natural language processing tasks. | |
| spacy_download automatically downloads a model with pip and then load it as a module when it is not currently installed, its usage is identical to spacy.load(), meaning that you can also exclude or disable pipeline components. | |
| """ | |
| import spacy | |
| import spacy.cli | |
| from spacy.language import Language | |
| from spacy_download import load_spacy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import spacy.util | |
| import sys | |
| import os | |
| import spacy | |
| def get_installed_models(): | |
| """ | |
| Get information about installed spaCy models. | |
| Prints out information about each installed spaCy model, including |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| def check_cuda_availability(): | |
| """ | |
| Check GPU/CUDA availability using PyTorch functions. | |
| This function checks whether CUDA is available on the system | |
| and provides information about available CUDA devices, if any. | |
| This script will work for PyTorch versions 0.4 and above. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias actenv='select folder in *(/); do source $folder/bin/activate; break; done' | |
| alias .actenv='select folder in .*/(/); do source "$folder"/bin/activate; break; done' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Python Script to Get Site Packages | |
| Description: | |
| This Python script provides a simple way to retrieve the site packages directories within your Python environment. If you're new to Python development or exploring the Python ecosystem, understanding where your packages are installed can be crucial. By using the `site` module, this script fetches the paths to the site packages, which typically contain third-party packages installed via pip or other package managers. | |
| How to Use: | |
| 1. Installation: Ensure you have Python installed on your system. You can download and install Python from the official website: [Python Downloads](https://www.python.org/downloads/). | |
| 2. Clone the Gist: Clone or download this gist from GitHub to your local machine. | |
| 3. Run the Script: Open your terminal or command prompt, navigate to the directory containing the script, and execute it by typing `python script_name.py` (replace `script_name.py` with the actual name of the script). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # NOTE: If you encounter any issues running the script, update the shebang line | |
| # above to the path of your Python 3 interpreter. You can find the path by running | |
| # the 'which python3' command in your terminal. Example: | |
| # #!/usr/bin/env /usr/bin/python3 | |
| """ | |
| The script retrieves a list of installed packages on a Debian-based system using the `dpkg --list` command. | |
| It prompts the user to select an output format (Markdown, CSV, YAML, TXT, or XLSX) and a directory to save the resulting file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # NOTE: If you encounter any issues running the script, update the shebang line | |
| # above to the path of your Python 3 interpreter. You can find the path by running | |
| # the 'which python3' command in your terminal. Example: | |
| # #!/usr/bin/env /usr/bin/python3 | |
| """ | |
| To run the script, ensure that the script file has the necessary read and execute permissions. | |
| 1. Save this script to a directory of your choice. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # NOTE: If you encounter any issues running the script, update the shebang line | |
| # above to the path of your Python 3 interpreter. You can find the path by running | |
| # the 'which python3' command in your terminal. Example: | |
| # #!/usr/bin/env /usr/bin/python3 | |
| """ | |
| This script is designed to assist users in projects where multiple virtual environments coexist within the same directory. | |
| It searches for directories that meet the criteria of a virtual environment and presents the user with them as options in a prompt so they can easily select which environment they wish to activate. |
NewerOlder