Skip to content

Instantly share code, notes, and snippets.

@luisdelatorre012
luisdelatorre012 / sox_report.md
Created May 28, 2025 13:38
Sox report from O3

SOX Compliance and Production Change Approvals: Real vs. “Rubber Stamp”

Internal Control Expectations for Change Management

Under Sarbanes-Oxley (SOX) Section 404, companies must maintain effective internal control over financial reporting – which includes IT general controls like change management. Both management and auditors (guided by PCAOB/AICPA standards) evaluate whether changes to production systems (especially those impacting financial data) are properly controlled. In practice, change management is expected to be “a systematic and standardised approach to ensuring all changes to the IT environment are appropriate, authorised and preserve the integrity of… programs and data”. The widely-used COSO internal control framework reinforces that principle: it highlights control activities such as proper authorizations/approvals and segregation of duties as fundamental to mitigating risks. In short, SOX compliance demands that moving any update into a production environment be subject to

@luisdelatorre012
luisdelatorre012 / show_scheduled_tasks.ps1
Last active November 20, 2024 17:30
Show scheduled tasks
# 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
@luisdelatorre012
luisdelatorre012 / on_assign_example.py
Created November 6, 2024 02:16
example of using on assign
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)
@luisdelatorre012
luisdelatorre012 / hamiltonian_path_or_tools.py
Last active November 6, 2024 02:15
hamiltonian path with or tools
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
@luisdelatorre012
luisdelatorre012 / missing indices
Created November 3, 2024 20:31
missing_indices.sql
-- 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)
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
@luisdelatorre012
luisdelatorre012 / prorate_proportionally.py
Created October 11, 2024 02:18
prorate proportionally
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
@luisdelatorre012
luisdelatorre012 / current_user_msal.py
Created September 20, 2024 01:17
Console app for displaying current user's info using MSAL
import msal
import httpx
from dynaconf import Dynaconf
# Load configuration
config = Dynaconf(
settings_files=['settings.toml', '.secrets.toml'],
environments=True,
load_dotenv=True,
)
@luisdelatorre012
luisdelatorre012 / recursively_walk_dict.py
Last active September 30, 2024 11:37
Recursively walk dict
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)
@luisdelatorre012
luisdelatorre012 / ad_group_sync.py
Created September 17, 2024 16:37
ad group sync
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: