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 read_json_file(file_path: str) -> dict: | |
| """ | |
| Reads a JSON file and returns a dictionary containing its data. | |
| Args: | |
| file_path: The path to the JSON file to read. |
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 os | |
| import sys | |
| def get_folder() -> str: | |
| args = sys.argv | |
| if len(args) != 2 or not os.path.isdir(args[1]): | |
| print("a folder must be set as the first argument") | |
| sys.exit(1) | |
| return sys.argv[1] |
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
| valid_envs := dev uat bench prod | |
| env := $(word 1,$(valid_envs)) | |
| cmd_plan := terraform plan -var-file=$(env).tfvars | |
| cmd_apply := terraform apply -auto-approve -var-file=$(env).tfvars | |
| cmd_destroy := terraform destroy -auto-approve -var-file=$(env).tfvars | |
| ifeq (,$(filter $(env),$(valid_envs))) | |
| $(error Invalid env specified. Available envs: $(valid_envs)) | |
| endif |
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 os | |
| import magic | |
| from pydantic import BaseModel | |
| from enum import Enum | |
| import tkinter as tk | |
| import time | |
| # Tip: run it in the background with: nohup python fake_extension_detector.py & | |
| SECONDS_TO_WAIT = 60 |
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 os | |
| import shutil | |
| FOLDER = "/home/costa/Downloads" | |
| NAME = "name" | |
| EXTENSION = "extension" | |
| EXTENSION_FOLDER_MAPPING = [ | |
| ["text", ["doc", "docx", "pdf"]], | |
| ["image", ["png", "jpeg", "gif", "jpg"]], |
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 os | |
| from datetime import datetime | |
| current_year = datetime.now().year | |
| project_path = "/home/costa/coding/python" | |
| author = "Lourenço Costa" | |
| new_project = "" | |
| gitignore_content = """ | |
| # Ignore compiled Python files | |
| *.pyc |
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 requests | |
| import json | |
| from tabulate import tabulate | |
| import questionary | |
| import webbrowser | |
| API_ENDPOINT = "https://api.github.com/gists" | |
| AUTH_TOKEN = "" | |
| USERNAME = "" |
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 check_args_and_kwargs_types(func): | |
| def inner(*args, **kwargs): | |
| hints = typing.get_type_hints(func) | |
| #args | |
| keys = func.__code__.co_varnames | |
| args_dict = {} | |
| for k, v in zip(keys, args): |
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
| package main | |
| import ( | |
| "fmt" | |
| "syscall" | |
| "github.com/shirou/gopsutil/v3/process" | |
| ) | |
| var print = fmt.Println |
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
| search_dir=/usr/share/nano/*.nanorc | |
| nano_file=/.nanorc | |
| for entry in `ls $search_dir`; do | |
| echo include "'${entry}'" >> $nano_file | |
| done | |
NewerOlder