Snippets Collections
import sys

print(sys.argv[0])  # Outputs: script.py
print(sys.argv[1])  # Outputs: arg1
print(sys.argv[2])  # Outputs: arg
param(
    [string]$param1,
    [string]$param2
)

Write-Host "Parameter 1 is: $param1"
Write-Host "Parameter 2 is: $param2"
$firstArg = $args[0]  # This will be 'arg1'
$secondArg = $args[1] # This will be 'arg2'
$thirdArg = $args[2]  # This will be 'arg3'
  {
    "version": 1,
    "author": "Alan Hu",
    "editor": "wokwi",
    "parts": [
      { "type": "wokwi-arduino-mega", "id": "mega", "top": 0, "left": 0, "attrs": {} },
      { "type": "wokwi-neopixel", "id": "rgb1", "top": -281.9, "left": -365.8, "attrs": {} },
      {
        "type": "wokwi-led-ring",
        "id": "ring1",
        "top": -213.82,
        "left": 151.03,
        "attrs": { "pixels": "16" }
      },
      {
        "id": "serial",
        "type": "wokwi-serial-port",
        "attrs": { "baud": "115200" }
      }
    ],
    "connections": [
      [ "ring1:GND", "mega:GND.1", "black", [ "v-3.46", "h-88.12", "v71.33" ] ],
      [ "ring1:VCC", "mega:5V", "red", [ "v20.54", "h-248.39", "v251.69", "h197.19", "v-4.36" ] ],
      [ "ring1:DOUT", "mega:3", "green", [ "v26.24", "h2" ] ],
      [ "ring1:DIN", "mega:2", "green", [ "v48.05", "h-2.35" ] ],  
      [ "mega:1", "$serialMonitor:RX", "", [] ],
      [ "mega:0", "$serialMonitor:TX","", [] ],
      [ "mega:16", "serial:RX", "", [] ],  
      [ "mega:17", "serial:TX","", [] ]

    ],
    "dependencies": {}
  }
{
  "version": 1,
  "author": "Uri Shaked",
  "editor": "wokwi",
  "parts": [
    {
      "type": "wokwi-arduino-uno",
      "id": "uno",
      "top": 0,
      "left": 0,
      "attrs": {}
    },
    {
      "id": "serial",
      "type": "wokwi-serial-port",
      "attrs": { "baud": "115200" }
    }
  ],
  "connections": [
    ["$serialMonitor:RX", "serial:TX", ""],
    ["$serialMonitor:TX", "serial:RX", ""]
  ],
  "serialMonitor": {
    "display": "always"
  }
}
Connect Serial Monitor to different Serial Port

[ "mega:17", "$serialMonitor:TX", "" ],
  [ "mega:16", "$serialMonitor:RX", "" ],
import logging

# Create a custom logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)  # Set the lowest level for the logger

# Create formatters
debug_formatter = logging.Formatter('%(asctime)s - [DEBUG] - %(message)s')
error_formatter = logging.Formatter('%(asctime)s - [ERROR] - %(message)s')
info_formatter = logging.Formatter('%(asctime)s - [INFO] - %(message)s')

# Create file handlers
debug_file_handler = logging.FileHandler('debug.log')
debug_file_handler.setLevel(logging.DEBUG)  # Capture all logs
debug_file_handler.setFormatter(debug_formatter)

error_file_handler = logging.FileHandler('error.log')
error_file_handler.setLevel(logging.ERROR)  # Capture only ERROR and CRITICAL logs
error_file_handler.setFormatter(error_formatter)

info_file_handler = logging.FileHandler('info.log')
info_file_handler.setLevel(logging.INFO)  # Capture INFO, WARNING, ERROR, and CRITICAL logs
info_file_handler.setFormatter(info_formatter)

# Add handlers to the logger
logger.addHandler(debug_file_handler)
logger.addHandler(error_file_handler)
logger.addHandler(info_file_handler)

# Log messages
logger.debug('This is a debug message')
logger.info('This is an info message')
logger.error('This is an error message')
def read_config_from_yaml(path_config):
    '''
    :param path_config: Path to the config file
    :return:
    '''
    # Read the content of the yaml file
    config_data = {}

    with open(path_config, 'r') as file:
        data = yaml.safe_load(file)
        # Extract key-value pairs from the nested 'config' key

    return data
def contains_substring(main_string, substrings):
    for substring in substrings:
        if substring in main_string:
            return True
    return False
with open('filename.txt', 'r') as f:
    content = f.read()
print(content)
star

Fri Aug 25 2023 03:35:53 GMT+0000 (Coordinated Universal Time)

#args #list #files #embed #image
star

Thu Aug 24 2023 06:17:58 GMT+0000 (Coordinated Universal Time)

#args #list #files #embed #image
star

Wed Aug 23 2023 22:09:56 GMT+0000 (Coordinated Universal Time)

#args #list #files
star

Wed Aug 23 2023 22:09:38 GMT+0000 (Coordinated Universal Time)

#args #list #files
star

Fri Aug 18 2023 07:46:45 GMT+0000 (Coordinated Universal Time)

#args
star

Fri Aug 18 2023 07:33:52 GMT+0000 (Coordinated Universal Time)

#args
star

Fri Aug 18 2023 07:15:54 GMT+0000 (Coordinated Universal Time)

#args
star

Thu Aug 17 2023 20:47:36 GMT+0000 (Coordinated Universal Time)

#args
star

Thu Aug 17 2023 08:31:28 GMT+0000 (Coordinated Universal Time)

#args
star

Thu Aug 17 2023 06:09:05 GMT+0000 (Coordinated Universal Time)

#args
star

Wed Aug 16 2023 17:40:15 GMT+0000 (Coordinated Universal Time)

#args

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension