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
# Ensure the ScheduledTasks module is available | |
Import-Module ScheduledTasks | |
# Define the search string | |
$searchString = '\scheduled_reports\' | |
# Retrieve all scheduled tasks that have actions defined | |
$allTasks = Get-ScheduledTask | Where-Object { $_.Actions -ne $null } | |
# Initialize an array to store matching tasks |
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 confluent_kafka import Consumer, TopicPartition | |
# Consumer configuration | |
conf = { | |
'bootstrap.servers': 'your_broker', | |
'group.id': 'your_group', | |
'enable.auto.commit': False, | |
'auto.offset.reset': 'none', | |
} | |
consumer = Consumer(conf) |
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 networkx as nx | |
from ortools.sat.python import cp_model | |
from typing import List, Optional | |
import matplotlib.pyplot as plt | |
def generate_random_directed_graph( | |
num_nodes: int, | |
edge_prob: float, | |
seed: int | None = None |
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
-- Assuming table t has one row with lower_bound and upper_bound | |
WITH Numbers AS ( | |
-- Anchor member: start with the lower bound | |
SELECT lower_bound AS number | |
FROM t | |
UNION ALL | |
-- Recursive member: increment the number by 1 each time | |
SELECT number + 1 | |
FROM Numbers | |
WHERE number + 1 <= (SELECT upper_bound FROM t) |
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
DECLARE @SchemaName NVARCHAR(128) = 'YourSchemaName'; | |
DECLARE @SQL NVARCHAR(MAX) = ''; | |
-- Select all columns that have a NOT NULL constraint | |
SELECT @SQL = @SQL + 'ALTER TABLE [' + s.name + '].[' + t.name + '] ALTER COLUMN [' + c.name + '] ' | |
+ TYPE_NAME(c.system_type_id) | |
+ CASE | |
WHEN c.max_length = -1 THEN '(MAX)' | |
WHEN c.system_type_id IN (231, 167) THEN '(' + CAST(c.max_length AS VARCHAR(10)) + ')' | |
WHEN c.system_type_id IN (106, 108) THEN '(' + CAST(c.precision AS VARCHAR(10)) + ',' + CAST(c.scale AS VARCHAR(10)) + ')' -- Handle DECIMAL/NUMERIC |
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 prorate_proportionally(df: pd.DataFrame, group: pd.DataFrame): | |
# Get the total tonnage values from the first row | |
total_tonnage_moved_contract = group.iloc[0]["tonnage_moved_contract"] | |
total_tonnage_moved_spot = group.iloc[0]["tonnage_moved_spot"] | |
total_tonnage_moved_unknown = group.iloc[0]["tonnage_moved_unknown"] | |
# Calculate the total commitment | |
total_commitment = group["tonnage_committed"].sum() | |
# Compute proration factors for each row |
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 msal | |
import httpx | |
from dynaconf import Dynaconf | |
# Load configuration | |
config = Dynaconf( | |
settings_files=['settings.toml', '.secrets.toml'], | |
environments=True, | |
load_dotenv=True, | |
) |
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 pyodbc | |
import re | |
from datetime import date, datetime | |
from typing import Any, Dict, Optional, List | |
def load_json(file_path: str) -> Any: | |
with open(file_path, 'r') as file: | |
return json.load(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
import subprocess | |
import json | |
def run_powershell_command(command): | |
completed_process = subprocess.run( | |
["powershell", "-Command", command], | |
capture_output=True, | |
text=True | |
) | |
if completed_process.returncode != 0: |
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 logging | |
import os | |
from typing import Any, Dict, Optional, Type, List, Tuple | |
import jsonref # Library for resolving JSON schema references | |
from jsonschema import Draft7Validator | |
from sqlalchemy import ( | |
JSON, | |
Boolean, |
NewerOlder