- Run commands in Git Bash
env PIP_REQUIRE_VIRTUALENV=0 python -m pip install --user pipx
python -m pipx ensurepath --force
- Open a new Git Bash terminal
pipx --version
- If getting an error during the installation of packages using pipx
No Python at 'C:\Users\<username>\AppData\Local\Programs\Python\PythonX\python.exe'
- Then remove the following folder
C:\Users\<username>\.local\pipx
- If still having the same issue
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
from PIL import Image | |
import random | |
def paste_image(source_path, target_path, position=None): | |
""" | |
Pastes a small source image onto a larger target image. | |
Parameters: | |
- source_path: Path to the small source image. | |
- target_path: Path to the larger target image. |
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
# Microsoft Authentication Library (MSAL) for Python: pip install requests msal | |
import requests | |
import msal | |
## 1. Redirect User to Microsoft Login: | |
# Replace these variables with your actual values | |
client_id = "your_client_id" | |
client_secret = "your_client_secret" | |
authority = "https://login.microsoftonline.com/your_tenant_id" |
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
from pyspark.sql import SparkSession | |
from pyspark.sql.functions import col, when, regexp_extract, length, lpad | |
# Create a SparkSession | |
spark = SparkSession.builder.appName("TupleToDataFrame").getOrCreate() | |
# List of tuples | |
arr = [("a", "0a1x"), ("x", "3"), ("cc", "11"), ("h", "5")] | |
# Create a DataFrame |
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 boto3 | |
from datetime import datetime | |
from awsglue.context import GlueContext | |
from pyspark.context import SparkContext | |
# First, use boto3 to list and filter objects | |
def list_s3_files_after_date(bucket_name, prefix='', start_date=None): | |
s3 = boto3.client('s3') |
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 boto3 | |
from awsglue.context import GlueContext | |
from pyspark.context import SparkContext | |
from awsglue.dynamicframe import DynamicFrame | |
def read_deleted_files_to_dynamicframe(bucket_name, prefix=''): | |
# Initialize Glue context | |
sc = SparkContext() | |
glueContext = GlueContext(sc) | |
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
# Print available disks (drives) and partitions | |
lsblk -o name,UUID,partuuid,mountpoint | |
# Assumption | |
## Windows OS bootloader is installed on /dev/nvme0n1 | |
## Linux OS bootloader is installed on /dev/nvme1n1 | |
# Add Windows bootloader entry | |
sudo efibootmgr -c -d /dev/nvme0n1 -p 1 -l \\EFI\\Microsoft\\Boot\\bootmgfw.efi -L "Windows Boot Manager" |
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 json | |
import requests | |
import pandas as pd | |
from itertools import chain | |
def get_sbahn_list(product='suburban', operator='1'): | |
""" | |
Get S-Bahn Line list from VBB Transport API | |
S-Bahn: product=suburban |
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
# Credits: | |
# Author: Gabriel Cassimiro | |
# Blog post: https://towardsdatascience.com/transfer-learning-with-vgg16-and-keras-50ea161580b4 | |
# GitHub Repo: https://github.com/gabrielcassimiro17/object-detection | |
# | |
import tensorflow_datasets as tfds | |
from tensorflow.keras import layers, models | |
from tensorflow.keras.utils import to_categorical | |
from tensorflow.keras.callbacks import EarlyStopping |
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
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license | |
# Hyperparameters for low-augmentation COCO training from scratch | |
# python train.py --batch 64 --cfg yolov5n6.yaml --weights '' --data coco.yaml --img 640 --epochs 300 --linear | |
# See tutorials for hyperparameter evolution https://github.com/ultralytics/yolov5#tutorials | |
lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3) | |
lrf: 0.01 # final OneCycleLR learning rate (lr0 * lrf) | |
momentum: 0.937 # SGD momentum/Adam beta1 | |
weight_decay: 0.0005 # optimizer weight decay 5e-4 | |
warmup_epochs: 3.0 # warmup epochs (fractions ok) |
NewerOlder