1,158 karma · joined Apr 1, 2007 (19y ago) · 387 submissions
comment 1y ago · link · parent
#define C(x) (sizeof(char[x]), x)
sizeof is a compile-time operation so x need to be known at compile time.
It didn't work as expected. It turns out there is an exception and the standard says that sizeof is actually calculated at runtime specifically for variable length arrays:
> The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is an integer. If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant.
comment 2y ago · link · parent
For example, consider explicitly casting the string "abc" to an int. Python throws a ValueError. Ruby silently ignores the problem and gives 0. I consider the Ruby behavior to be a gotcha.
comment 2y ago · link · parent
Another NYC one: A lot of people think "major" in The Major Deegan Expressway means it is a significant expressway, but actually the expressway is named after (Army) Major William Deegan
comment 2y ago · link · parent
comment 3y ago · link · parent
But it can be helpful to log an error message (without stacktrace) to give context that is available only in this frame before letting the exception propagate to whoever ultimately handles and logs it.
comment 3y ago · link · parent
And then I heard "... with a chainsaw. It's a chainsaw mill" and realized I may have misunderstood the context.
comment 3y ago · link · parent
This is a typical weekend NY Red Bulls game. Tickets are available for $10 : https://www.stubhub.com/new-york-red-bulls-harrison-tickets-...
This is the following weekend against Miami. Tickets start at more than $500 (~$650 with fees) : https://www.stubhub.com/new-york-red-bulls-harrison-tickets-...
comment 3y ago · link · parent
comment 3y ago · link · parent
* "Recycling Bins" from Home Depot
* "Recycling Bins" from Amazon
* "Find the Recycle Bin" from Microsoft
* "Recycling Bins" from Lowes.com
* "Recycle Bins" from Target
* "Recycling Bins" from Walmart
comment 3y ago · link · parent
https://www.theatlantic.com/magazine/archive/2023/06/ai-warf...
comment 3y ago · link · parent
https://github.com/benfred/py-spy
It's worked really well for my needs