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
| tree -L 3 -I "__pycache__|*.pyc|*.egg-info|.venv|.git" |
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
| #!/bin/bash | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| ############################################################################### | |
| # Production Server Setup Script (Docker + PostgreSQL Backup) | |
| # | |
| # What the script does: | |
| # 1. Installs Docker Engine and Docker Compose (if not installed) |
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
| #!/bin/bash | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| ############################################################################### | |
| # Production Server Setup Script | |
| # | |
| # This script prepares a Linux server (Ubuntu) for running a production | |
| # Docker-based web application with HTTPS and automated PostgreSQL backups. |
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
| export $(sed -e 's/#.*//g' -e '/^$/d' .env | xargs) |
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 subprocess | |
| import time | |
| timeout = 40 # Set timeout to 40 seconds | |
| with open('items.txt', 'r') as file: | |
| items = file.read().strip().split('\n') | |
| for item in items: | |
| item = item.strip() # Clean up any extra whitespace |
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 | |
| def extract_json_from_text(text): | |
| # Find the first '{' character | |
| start = text.find('{') | |
| if start == -1: | |
| print("No JSON block found in the text.") | |
| return None | |
| # Use a stack to track nested braces |
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
| # pip install python-dotenv | |
| import os | |
| from dotenv import find_dotenv, load_dotenv | |
| # load variables from .env | |
| load_dotenv(find_dotenv(usecwd=True)) | |
| MY_VAR = os.getenv("MY_VAR") |
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
| """ | |
| A function allows to generate json key file used by google api from environment variables. Example of `.env` file: | |
| ``` | |
| TYPE="my_service_account" | |
| PROJECT_ID="my_project_id" | |
| PRIVATE_KEY_ID="my_private_key_id" | |
| PRIVATE_KEY="-----BEGIN PRIVATE KEY----- | |
| my_private_key_content | |
| -----END PRIVATE KEY----- |
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 | |
| from typing import Any, Dict, List | |
| import spacy | |
| from spacy.training.iob_utils import biluo_to_iob, doc_to_biluo_tags | |
| from tqdm import tqdm | |
| def spans_to_conll( | |
| samples: List[Dict[str, Any]], |
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 fix_span(text: str, span: dict): | |
| # let us check that spans are correctly extracted | |
| fixed_span = span.copy() | |
| # span starts with a space or a punctuation | |
| while text[fixed_span["start"]] in [" ", ".", ",", ";", ":", "!", "?"]: | |
| fixed_span["start"] += 1 | |
| # span is cut in the begging: e.g. "ashington DC" |
NewerOlder