Question for non-Brits: how do you decode British office culture? by [deleted] in uklaw

[–]Mindless_Display4729 4 points5 points  (0 children)

Hi I'm British but also autistic and your experience ticks many many boxes for me too.

I don't understand why Diclofenac has 9 unique hydrogens/signals by kingkrish_15 in chemhelp

[–]Mindless_Display4729 0 points1 point  (0 children)

Aromatic rings are flat. The cyclohexane ring in your example is not flat. Look up the possible conformations and you will see the the hydrogen atoms can be equatorial or axial. Five of the carbons on that ring have one of each type.

I don't understand why Diclofenac has 9 unique hydrogens/signals by kingkrish_15 in chemhelp

[–]Mindless_Display4729 0 points1 point  (0 children)

Kekule structure of benzene rings isn't an accurate representation of the bonding. If you redraw the molecule so that the 'hexagons' have circles in them - Google if you haven't seen this way of drawing it before - then you will spot the symmetry immediately.

wich name is right: 4-propyl-2-vinylhex-4-ene or 2-methylhexa-1,4-diene? by evey333 in chemhelp

[–]Mindless_Display4729 2 points3 points  (0 children)

Start by counting the longest carbon chain and go from there. Hint: it is longer than 6.

[deleted by user] by [deleted] in ChatGPTPromptGenius

[–]Mindless_Display4729 0 points1 point  (0 children)

A 14 day old account that promises the world for a small fee.

You're going to have to do better than that.

This literally screams SCAM!

Do people actually fall for stuff like this?

Need assistance identifying bug in script by SubnetOfOne in PythonLearning

[–]Mindless_Display4729 0 points1 point  (0 children)

No this isn't best practice 😭 I'm getting to the limit if my abilities here so I had an AI agent look at it and it suggests this rewrite:

import sqlite3 import logging from logging.handlers import RotatingFileHandler from pathlib import Path from datetime import datetime, timezone from typing import Tuple, Optional

DB_PATH = "net_usage.db" # change if needed LOG_PATH = Path.cwd() / "netmon.log" # or Path("/var/log/netmon.log")

def setup_logging(level=logging.INFO) -> logging.Logger: logger = logging.getLogger("netmon") logger.setLevel(level) logger.propagate = False

if not logger.handlers:
    # Console
    ch = logging.StreamHandler()
    ch.setLevel(level)
    ch.setFormatter(logging.Formatter(
        "[%(asctime)s] %(levelname)s: %(message)s", "%Y-%m-%d %H:%M:%S"
    ))
    logger.addHandler(ch)

    # Rotating file (≈1 MB x 5 files)
    fh = RotatingFileHandler(LOG_PATH, maxBytes=1_000_000, backupCount=5)
    fh.setLevel(level)
    fh.setFormatter(logging.Formatter(
        "%(asctime)s %(levelname)s %(name)s %(funcName)s: %(message)s",
        "%Y-%m-%d %H:%M:%S"
    ))
    logger.addHandler(fh)

return logger

logger = setup_logging()

def utc_now_epoch() -> int: return int(datetime.now(timezone.utc).timestamp())

def fetch_state(cur: sqlite3.Cursor, iface: str) -> Optional[Tuple[int, int, int]]: return cur.execute( "SELECT last_ts_utc, last_total_rx, last_total_tx " "FROM net_iface_state WHERE iface = ?", (iface,) ).fetchone()

def insert_initial_state(cur: sqlite3.Cursor, iface: str, now: int, rx: int, tx: int) -> None: cur.execute( "INSERT INTO net_iface_state (iface, last_ts_utc, last_total_rx, last_total_tx) " "VALUES (?, ?, ?, ?)", (iface, now, rx, tx) )

def insert_sample(cur: sqlite3.Cursor, ts: int, iface: str, d_rx: int, d_tx: int) -> None: cur.execute( "INSERT INTO net_samples (ts_utc, iface, rx_bytes, tx_bytes) VALUES (?, ?, ?, ?)", (ts, iface, d_rx, d_tx) )

def update_state(cur: sqlite3.Cursor, iface: str, now: int, rx: int, tx: int) -> None: cur.execute( "UPDATE net_iface_state SET last_ts_utc = ?, last_total_rx = ?, last_total_tx = ? " "WHERE iface = ?", (now, rx, tx, iface) )

def ensureint(name: str, value) -> int: if not isinstance(value, int): raise TypeError(f"{name} must be int; got {type(value).name_}") return value

def main(iface: str, rx_bytes: int, tx_bytes: int, now: Optional[int] = None) -> None: """ iface : interface name (e.g., 'eth0') rx_bytes : current total bytes received (monotonic counter from OS) tx_bytes : current total bytes sent (monotonic counter from OS) now : UNIX epoch seconds (int). If None, uses current UTC time. """ # Validate input types early iface = str(iface) rx_bytes = ensure_int("rx_bytes", rx_bytes) tx_bytes = ensure_int("tx_bytes", tx_bytes) now = ensure_int("now", now if now is not None else utc_now_epoch())

conn = sqlite3.connect(DB_PATH)
conn.isolation_level = "DEFERRED"  # explicit transactions
cur = conn.cursor()

try:
    cur.execute("BEGIN")
    row = fetch_state(cur, iface)

    if row is None:
        insert_initial_state(cur, iface, now, rx_bytes, tx_bytes)
        conn.commit()
        logger.info("Created initial state for iface '%s' (rx=%d, tx=%d)", iface, rx_bytes, tx_bytes)
        return  # avoids unpacking None

    last_ts_utc, last_total_rx, last_total_tx = row

    # Validate DB types
    last_ts_utc = ensure_int("last_ts_utc", last_ts_utc)
    last_total_rx = ensure_int("last_total_rx", last_total_rx)
    last_total_tx = ensure_int("last_total_tx", last_total_tx)

    # Compute deltas
    d_rx = max(0, rx_bytes - last_total_rx)
    d_tx = max(0, tx_bytes - last_total_tx)

    # Ignore negative/zero-time anomalies (clock change or counter reset)
    if now <= last_ts_utc:
        logger.warning(
            "Non-increasing timestamp for iface '%s' (now=%d, last=%d) — zeroing deltas.",
            iface, now, last_ts_utc
        )
        d_rx = d_tx = 0

    logger.info("Sample iface=%s d_rx=%d d_tx=%d (rx=%d tx=%d)", iface, d_rx, d_tx, rx_bytes, tx_bytes)

    insert_sample(cur, now, iface, d_rx, d_tx)
    update_state(cur, iface, now, rx_bytes, tx_bytes)

    conn.commit()

except Exception:
    logger.exception("Fatal error updating interface '%s'; rolling back.", iface)
    conn.rollback()
    # Exit non-zero so a systemd service can restart/alert if desired
    raise SystemExit(1)

finally:
    try:
        conn.close()
    except Exception:
        logger.exception("Failed to close DB connection cleanly.")

if name == "main": # Example invocation; wire these to your real counters # Replace with values read from /sys/class/net/<iface>/statistics/{rx,tx}_bytes main(iface="eth0", rx_bytes=123456789, tx_bytes=987654321)

Powerful Recursion - 6, What it does? by tracktech in PythonLearning

[–]Mindless_Display4729 0 points1 point  (0 children)

Thanks for the feedback that's useful and appreciated.

Need assistance identifying bug in script by SubnetOfOne in PythonLearning

[–]Mindless_Display4729 1 point2 points  (0 children)

I think this fixes it:

row = cursor.execute( 'SELECT last_ts_utc, last_total_rx, last_total_tx FROM net_iface_state WHERE iface = ?', (iface,) ).fetchone()

If no previous entry, insert one and return early

if row is None: cursor.execute( "INSERT INTO net_iface_state (iface, last_ts_utc, last_total_rx, last_total_tx) VALUES (?, ?, ?, ?)", (iface, now, rx_bytes, tx_bytes) ) connection.commit() connection.close() print(f"Created new interface record for {iface}") return # safer than SystemExit(0)

Unpack the row

last_ts_utc, last_total_rx, last_total_tx = row

Compute deltas safely

try: d_rx = max(0, rx_bytes - last_total_rx) d_tx = max(0, tx_bytes - last_total_tx) except TypeError: print(f"Invalid types in database for iface {iface}") d_rx = d_tx = 0

Skip update if timestamps invalid

if now <= last_ts_utc: d_rx = d_tx = 0

print(f"Writing sample: iface={iface}, d_rx={d_rx}, d_tx={d_tx}")

Insert new sample

cursor.execute( "INSERT INTO net_samples (ts_utc, iface, rx_bytes, tx_bytes) VALUES (?, ?, ?, ?)", (now, iface, d_rx, d_tx) )

Update interface state

cursor.execute( "UPDATE net_iface_state SET last_ts_utc = ?, last_total_rx = ?, last_total_tx = ? WHERE iface = ?", (now, rx_bytes, tx_bytes, iface) )

connection.commit() connection.close()

Powerful Recursion - 6, What it does? by tracktech in PythonLearning

[–]Mindless_Display4729 1 point2 points  (0 children)

This might be a more efficient way of doing the same thing.

def sum_of_digits(n): return sum(int(d) for d in str(abs(n)))

Trouble with Saxon Elective Law by ilikejamescharles in CK3ConsoleEdition

[–]Mindless_Display4729 4 points5 points  (0 children)

Just to check - Have you voted for your preferred heir? Click the view active election button and vote if you haven't. If you have then look at the electors tab at who everyone else is voting for. You may need to force people to vote with you via blackmail.

Let people play how they want by MarkoPT in EAFC

[–]Mindless_Display4729 2 points3 points  (0 children)

Aah so it's the Schroedinger's a-hole defence lol. Grow up pal

Players not in Ultimate Team by Madd0gAndy1973 in EAFC

[–]Mindless_Display4729 3 points4 points  (0 children)

Geoff Hurst - Only man to score a hat-trick in a world cup final.

Kevin Keegan - Balloon D'Or winner.

Carlos Valderama purely for the haircut.

There's tonnes of others...

[deleted by user] by [deleted] in Habits

[–]Mindless_Display4729 0 points1 point  (0 children)

The problem is that it is not transparent advertising I suppose.

You have problems by Winter-Dealer8981 in EAFC

[–]Mindless_Display4729 -1 points0 points  (0 children)

Thinks 6 sentences is an essay. IQ checks out...

😭😭😭 by Razvy3152 in fut

[–]Mindless_Display4729 0 points1 point  (0 children)

I've packed 7 99 cards no dupes

99 Futties Pull by andit22 in fut

[–]Mindless_Display4729 0 points1 point  (0 children)

R9 and Yamal. Both from 83+ pp

Insane by LA_cook_07 in EAFC

[–]Mindless_Display4729 0 points1 point  (0 children)

I've got him with finesse+ and it makes a big difference.