Mateus Brandão
@mateusb
Member · Member since May 2018
Backend, Kotlin.
0 followers · 0 following
Badges and trust level are earned across the whole community.
- Topics created
- 0
- Posts created
- 1
- Likes given
- 28
- Likes received
- 0
- Days visited
- 0
- Solutions
- 0
Days visited count across the whole community, not just this forum.
Most active topics
Nothing yet.
Most liked posts
Nothing yet.
Top categories
Top tags
Nothing yet.
Recent badges
- Floating point: why is 0.1 + 0.2 != 0.3?
No — 0.1 and 0.2 have no exact binary representation, so the sum is 0.30000000000000004. Compare with a tolerance: Math.abs(a - b) < Number.EPSILON and use inte
Likes given · 10/12/2026
- Floating point: why is 0.1 + 0.2 != 0.3?
0.1 + 0.2 === 0.3 is false in JavaScript. Is the language broken?
Likes given · 10/12/2026
- Async Python: run blocking code without freezing the event loop
Push it to a thread: result = await asyncio.to_thread(blocking_fn, arg) For CPU-heavy work use a process pool with loop.run_in_executor(ProcessPoolExecutor(), f
Likes given · 10/12/2026
- Java: concurrent modification exception when removing from a list in a for-each loop
Use removeIf: names.removeIf(String::isBlank); or an explicit Iterator and it.remove().
Likes given · 10/12/2026
- Java: concurrent modification exception when removing from a list in a for-each loop
for (String s : names) { if (s.isBlank()) names.remove(s); } throws ConcurrentModificationException. How should I remove while iterating?
Likes given · 10/12/2026
- Python: what is the difference between __str__ and __repr__?
__repr__ is for developers: unambiguous, ideally valid Python that recreates the object. Used by the REPL, repr(), and containers. __str__ is for users: readabl
Likes given · 10/12/2026
- SQL: get the latest row per group
In Postgres the shortest form is DISTINCT ON: SELECT DISTINCT ON (customer_id) * FROM orders ORDER BY customer_id, created_at DESC; Portable SQL uses a window f
Likes given · 10/12/2026
- React: useEffect runs twice in development
My useEffect with an empty dependency array fires twice on mount, so my analytics event is sent twice. Is my component mounting twice?
Likes given · 10/12/2026
- Bash: loop over files with spaces in their names
Do not parse ls. Let the shell glob, and quote the variable: for f in *.txt; do printf '%s\n' "$f" done For recursive search use find … -print0 | while IFS= r
Likes given · 10/12/2026
- TypeScript: type an object whose keys come from a union
Use Record: type Theme = 'light' | 'dark'; const bg: Record<Theme, string> = { light: '#fff', dark: '#0d1117' }; Missing a key is a compile error. Use Partial<R
Likes given · 10/12/2026
- Regex to match a hex colour like #fff or #1a2b3c
/^#(?:[0-9a-f]{3}){1,2}$/i {1,2} allows exactly 3 or 6 hex digits. Add |[0-9a-f]{8} inside the group if you also want #rrggbbaa.
Likes given · 10/12/2026
- Go: all goroutines are asleep — deadlock! with an unbuffered channel
func main() { ch := make(chan int) ch <- 1 fmt.Println(<-ch) } Why does this deadlock?
Likes given · 10/12/2026
- Docker container exits immediately with code 0
The trailing & backgrounds the process. The container's main process (the shell) then has nothing left to do, exits with 0, and Docker stops the container. Use
Likes given · 10/12/2026
- JavaScript: why does [1, 2, 10].sort() put 10 before 2?
No — Array.prototype.sort compares elements as strings by default, and "10" < "2". Pass a comparator: [1, 2, 10].sort((a, b) => a - b) // [1, 2, 10] Since ES20
Likes given · 10/12/2026
- JavaScript: why does [1, 2, 10].sort() put 10 before 2?
[1, 2, 10].sort() // [1, 10, 2] Is this a bug?
Likes given · 10/12/2026
- Rust: "borrowed value does not live long enough" when returning a &str from a function
fn first_word(s: String) -> &str { s.split(' ').next().unwrap() } The compiler says the borrowed value does not live long enough. I just want the first word
Likes given · 10/12/2026
- PostgreSQL: query is slow even though the column is indexed
Also watch the time zone: created_at::date on a timestamptz depends on the session TimeZone, so the expression index is not immutable and Postgres will refuse i
Likes given · 10/12/2026
- PostgreSQL: query is slow even though the column is indexed
Wrapping the column in a function (date(created_at)) means the index on created_at cannot be used — the planner would have to compute date() for every row. Rewr
Likes given · 10/12/2026
- PostgreSQL: query is slow even though the column is indexed
This query takes ~4 s on a 30M-row table even though created_at has a B-tree index: SELECT * FROM events WHERE date(created_at) = '2026-10-01'; EXPLAIN shows a
Likes given · 10/12/2026