The 2026 Heapfield Developer Survey results are live — view the results here! →

Heapfield

Newest Questions

10 votes2 answers158 views
JavaScript: why does [1, 2, 10].sort() put 10 before 2?

[1, 2, 10].sort() // [1, 10, 2] Is this a bug?

javascriptarrayssorting
user884120321asked
1 vote2 answers82 views
Vim: how do I exit without saving?

I opened a file in vim by accident. How do I quit and discard changes?

vimeditor
user884120321asked
0 votes1 answer87 views
Python: what is the difference between __str__ and __repr__?

When should I implement __repr__ and when __str__?

pythonooprepr
user884120321asked
10 votes1 answer155 views
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.

rustlifetimesborrow-checker
Oskar Lindqvist9asked
2 votes1 answer270 views
Bash: loop over files with spaces in their names

for f in $(ls *.txt) breaks on file names with spaces. What is the right way?

bashshellfilenames
user884120321asked
0 votes1 answer203 views
C#: async void vs async Task

When is async void acceptable?

c#async-await
Jonah Weiss3asked
6 votes2 answers657 views
Git: undo the most recent local commits

I committed the wrong files and have not pushed yet. How do I undo the last commit but keep my changes?

gitgit-resetversion-control
user884120321asked
2 votes1 answer390 views
Spark: how to avoid a shuffle when joining a small table?

Joining a 2 GB fact table with a 5 MB lookup table causes a full shuffle. Any way to avoid it?

apache-sparkpysparkperformance
Amara Nwosu9asked
3 votes1 answer700 views
Embedded C: volatile still needed for memory-mapped registers?

With modern compilers and -O2, is volatile still required for hardware registers, or are memory barriers enough?

cembeddedvolatile
Oskar Lindqvist9asked
2 votes1 answer185 views
Async Python: run blocking code without freezing the event loop

I call a blocking library function inside an async def handler and the whole server stalls. How do I run it without blocking?

pythonasyncioconcurrency
Priya Raghunathan9asked
6 votes1 answer959 views
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?

reactjsreact-hooksuse-effect
Amara Nwosu9asked
11 votes1 answer963 views
CSS grid: make the last row items stretch to fill the width

I have a grid with grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)). When the last row has fewer items they keep their column width. I want them to stretch across the remaining space. Possible with grid alone?

csscss-gridlayout
Lin Mei9asked
2 votes1 answer1.7k views
Kubernetes pod stuck in CrashLoopBackOff, no logs

kubectl logs for my pod returns nothing and the pod restarts every few seconds. How can I see why it crashes?

kubernetesdebugging
Oskar Lindqvist9asked
4 votes1 answer684 views
Docker container exits immediately with code 0

FROM node:22-alpine WORKDIR /app COPY . . RUN npm ci CMD npm start & docker run returns right away and docker ps shows nothing. Logs are empty.

dockerdockerfilecontainers
Priya Raghunathan9asked
12 votes2 answers1.6k views
SQL: get the latest row per group

For each customer_id I need the most recent order from orders(id, customer_id, created_at, total).

sqlpostgresqlgroupwise-max
Tomás Ferreira6asked
9 votes1 answer720 views
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?

javacollectionsiterator
Dmitri Vasko3asked
11 votes2 answers6.0k views
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 sequential scan. Why is the index ignored?

postgresqlindexingquery-optimization
Tomás Ferreira6asked
11 votes1 answer838 views
Floating point: why is 0.1 + 0.2 != 0.3?

0.1 + 0.2 === 0.3 is false in JavaScript. Is the language broken?

floating-pointjavascriptprecision
user884120321asked
11 votes1 answer1.0k views
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?

goconcurrencychannels
Jonah Weiss3asked
5 votes2 answers3.2k views
TypeScript: type an object whose keys come from a union

I have type Theme = 'light' | 'dark' and want an object that must contain a colour for every theme. How do I type it?

typescriptgenericsmapped-types
Lin Mei9asked
0 votes1 answer1.3k views
Regex to match a hex colour like #fff or #1a2b3c

I need a regular expression that accepts #fff and #1a2b3c but not #12 or #ggg.

regexjavascriptvalidation
Amara Nwosu9asked
2 votes0 answers964 views
Is it possible to style the scrollbar in Firefox?

::-webkit-scrollbar does nothing in Firefox. Is there an alternative?

cssfirefoxscrollbar
Lin Mei9asked
1 vote1 answer11.6k views
ClosedHow to center a div horizontally and vertically?

What is the modern way to centre a box inside its parent both ways?

cssflexboxcentering
user884120321asked
-3 votes0 answers11.5k views
ClosedWhat is the best programming language to learn first in 2026?

Python or JavaScript?

discussion
user884120321asked
13 votes2 answers59.0k views
How do I select rows from a pandas DataFrame based on column values?

I have a DataFrame of orders and want only the rows where status is "shipped" and total is above 100. In SQL: SELECT * FROM orders WHERE status = 'shipped' AND total > 100; What is the idiomatic pandas equivalent?

pythonpandasdataframe
Amara Nwosu9asked
13 votes4 answers139k views
Why does iterating a sorted list run faster than an unsorted one in this C++ loop?

I have a loop that sums every element of a large std::vector<int> that is at least 128. If I sort the vector first (outside the timed region), the loop runs about five times faster: #include <algorithm> #include <chrono> #include <iostream> #include <random> #include <vector> int main() { std::vecto

c++performanceoptimizationcpu-architecture
Priya Raghunathan9asked