Write a polite but firm email to a landlord who has not fixed the heating for three weeks. I want the repair, not a fight.
Claude Opus 5.5
Subject: Heating Repair Needed at [Your Address] – Request for Repair Date
Dear [Landlord's Name],
I'm writing about the heating at [your address, unit number], which has not been working since [date the problem started]. I first reported it on [date of first report] and followed up on [date(s) of later contact], but it has now been about three weeks without a repair.
I appreciate that things can get busy. However, with the current temperatures, the flat is getting very cold, and it is becoming difficult to live in comfortably. [Optional: add a specific detail, e.g., "The indoor temperature has been dropping to around X°C/°F overnight," or "This is especially difficult because I work from home / have a young child."]
Could you please confirm by [specific date, e.g., Friday, March 8] when a repair technician will come? I'm happy to be flexible with access. I'm generally available [list days/times], and I can arrange access at other times if needed.
If there is anything you need from me to help move this forward, such as photos, a description of the problem, or a contact number for the technician, please let me know and I'll send it straight away.
Thank you for your help. I'd like to get this resolved quickly and smoothly for both of us.
Kind regards, [Your Name] [Your Phone Number] [Your Address / Unit Number]
A few tips to help you get results without creating conflict:
Send it in writing (email or letter) so you have a dated record, even if you've only called before.
Keep copies of all messages and note the dates of any calls.
If you get no reply by your deadline, send a short, calm follow-up. You could add a line such as: "I understand landlords are generally required to keep heating in working order, so I'd be grateful if we could arrange this as soon as possible." This reminds them of their obligation without sounding like a threat.
If it still isn't fixed, check your local tenant rights. Most areas have a housing authority or tenant advice service that can help.
Asked Nov 1, 2026. Unedited.
Write a React hook that debounces a value and cancels on unmount. Include the TypeScript types.
Claude Opus 5.5
useDebouncedValue and useDebouncedCallback
Below are two hooks:
useDebouncedValue: debounces a value. This is what you asked for.useDebouncedCallback: debounces a function, withcancelandflushcontrols. It's useful when you need to debounce an event handler rather than state.
Both cancel any pending timer when the component unmounts, so no state update or callback runs after unmount.
1. useDebouncedValue
// useDebouncedValue.ts
import { useEffect, useState } from 'react';
/**
* Returns `value` after it has stopped changing for `delay` ms.
* Any pending update is cancelled when `value` or `delay` changes,
* or when the component unmounts.
*/
export function useDebouncedValue<T>(value: T, delay: number = 300): T {
const [debouncedValue, setDebouncedValue] = useState<T>(value);
useEffect(() => {
const timeoutId: ReturnType<typeof setTimeout> = setTimeout(() => {
setDebouncedValue(value);
}, delay);
// Runs before the next effect (value/delay changed) AND on unmount.
return () => {
clearTimeout(timeoutId);
};
}, [value, delay]);
return debouncedValue;
}Usage
import { useEffect, useState } from 'react';
import { useDebouncedValue } from './useDebouncedValue';
interface User {
id: string;
name: string;
}
export function UserSearch() {
const [query, setQuery] = useState<string>('');
const [results, setResults] = useState<User[]>([]);
const debouncedQuery = useDebouncedValue(query, 400);
useEffect(() => {
if (!debouncedQuery) {
setResults([]);
return;
}
const controller = new AbortController();
fetch(`/api/users?q=${encodeURIComponent(debouncedQuery)}`, {
signal: controller.signal,
})
.then((res) => res.json() as Promise<User[]>)
.then(setResults)
.catch((err: unknown) => {
if ((err as Error).name !== 'AbortError') console.error(err);
});
return () => controller.abort(); // cancel in-flight request too
}, [debouncedQuery]);
return (
<>
<input value={query} onChange={(e) => setQuery(e.target.value)} />
<ul>
{results.map((u) => (
<li key={u.id}>{u.name}</li>
))}
</ul>
</>
);
}2. useDebouncedCallback (with cancel / flush)
// useDebouncedCallback.ts
import { useEffect, useLayoutEffect, useMemo, useRef } from 'react';
export interface DebouncedFunction<Args extends unknown[]> {
(...args: Args): void;
/** Cancel any pending invocation. */
cancel: () => void;
/** Immediately invoke the pending call, if any. */
flush: () => void;
/** Whether a call is currently scheduled. */
isPending: () => boolean;
}
// useLayoutEffect warns during SSR; fall back to useEffect on the server.
const useIsomorphicLayoutEffect =
typeof window !== 'undefined' ? useLayoutEffect : useEffect;
export function useDebouncedCallback<Args extends unknown[]>(
callback: (...args: Args) => void,
delay: number = 300
): DebouncedFunction<Args> {
const callbackRef = useRef(callback);
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const pendingArgsRef = useRef<Args | null>(null);
// Always call the latest callback without resetting the debounce timer.
useIsomorphicLayoutEffect(() => {
callbackRef.current = callback;
}, [callback]);
const debounced = useMemo<DebouncedFunction<Args>>(() => {
const invoke = (): void => {
const args = pendingArgsRef.current;
timeoutRef.current = null;
pendingArgsRef.current = null;
if (args) callbackRef.current(...args);
};
const cancel = (): void => {
if (timeoutRef.current !== null) {
clearTimeout(timeoutRef.current);
timeoutRef.current = null;
}
pendingArgsRef.current = null;
};
const fn = ((...args: Args): void => {
pendingArgsRef.current = args;
if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
timeoutRef.current = setTimeout(invoke, delay);
}) as DebouncedFunction<Args>;
fn.cancel = cancel;
fn.flush = () => {
if (timeoutRef.current !== null) {
clearTimeout(timeoutRef.current);
invoke();
}
};
fn.isPending = () => timeoutRef.current !== null;
return fn;
}, [delay]);
// Cancel on unmount (and when `delay` changes, which creates a new function).
useEffect(() => {
return () => debounced.cancel();
}, [debounced]);
return debounced;
}Usage
import { useDebouncedCallback } from './useDebouncedCallback';
export function AutoSaveEditor({ docId }: { docId: string }) {
const save = useDebouncedCallback((content: string) => {
void fetch(`/api/docs/${docId}`, {
method: 'PUT',
body: JSON.stringify({ content }),
});
}, 1000);
return (
<textarea
onChange={(e) => save(e.target.value)} // typed: (content: string) => void
onBlur={() => save.flush()} // save immediately when leaving
/>
);
}Notes
ReturnType<typeof setTimeout>keeps the timer type correct in both browser (number) and Node (Timeout) environments.Cancellation on unmount comes from the effect cleanup functions. React calls them on unmount, so
clearTimeoutstops any pendingsetStateor callback.Stable callback identity:
useDebouncedCallbackstores the latestcallbackin a ref. Passing an inline arrow function therefore doesn't reset the timer on every render. The returned function only changes whendelaychanges.StrictMode double-mounts effects in development. Both hooks handle this correctly because cleanup clears the timer before the effect runs again.
Asked Nov 1, 2026. Unedited.
A drug test is 99% accurate, and 0.5% of people use the drug. Someone tests positive. What is the probability they use it, and why does the answer surprise people?
Claude Opus 5.5
About 33%, or roughly 1 in 3
This assumes "99% accurate" means the test correctly flags 99% of users (sensitivity) and correctly clears 99% of non-users (specificity).
The calculation (Bayes' theorem)
$$ P(\text{user} \mid +) = \frac{P(+ \mid \text{user})\,P(\text{user})}{P(+ \mid \text{user})\,P(\text{user}) + P(+ \mid \text{non-user})\,P(\text{non-user})} $$
$$ = \frac{0.99 \times 0.005}{0.99 \times 0.005 + 0.01 \times 0.995} = \frac{0.00495}{0.0149} \approx 0.332 $$
The intuitive version: imagine 10,000 people
| Test positive | Test negative | Total | |
|---|---|---|---|
| Users (0.5%) | ~50 (99% of 50) | ~0.5 | 50 |
| Non-users (99.5%) | ~100 (1% of 9,950) | ~9,850 | 9,950 |
| Total | ~150 | 10,000 |
Of about 150 positive results, only about 50 are real users. The other ~100 are false positives. So a positive result means roughly a 1 in 3 chance of actual drug use.
Why it surprises people
Base rate neglect. People focus on the vivid "99% accurate" figure and ignore how rare drug use is. When a condition is rare, even a small error rate applied to the huge non-user population produces more false positives than there are true positives.
Confusing the two conditional probabilities. The test tells you P(positive | user) = 99%. People instinctively treat that as P(user | positive). These are very different numbers. "Most users test positive" does not mean "most positives are users."
The 1% error feels negligible. But 1% of 9,950 non-users (~100 people) is double the entire user population (50 people).
Practical takeaway
This is why positive screening results are confirmed with a second, independent test. If someone tests positive twice, the probability jumps to about 98%, because the first positive raises the "base rate" from 0.5% to 33% before the second test is applied. The same logic applies to medical screening for rare diseases, fraud detection, and security screening.
Asked Nov 1, 2026. Unedited.
What it’s good at
Ranked against 42 models, from public leaderboards and our own blind tests where we have them. How we rank
- #1of 42 for coding
- #1of 42 for writing
- #1of 42 for math
The facts
Claude Opus 5.5 is Anthropic’s flagship model. It reads images and PDFs as well as text, and it is the one to reach for when a mistake would cost you.
Scores from artificialanalysis.ai and lmarena.ai (its “high” setting).
- Made by
- Anthropic
- API price, per 1M tokens
- $4 in, $20 out
- Speed
- 97 tokens a second
- Artificial Analysis Index
- 57.6
- LMArena text
- 1,516
- LMArena coding
- 1,545
- Updated
- Oct 26, 2026