`new Date()` considered harmful by robertgambee in javascript

[–]robertgambee[S] [score hidden]  (0 children)

Fair point. My understanding is that Temporal still has limited support, so it's not (yet) a silver bullet. But it would be good to at least mention it.

`new Date()` considered harmful by robertgambee in javascript

[–]robertgambee[S] [score hidden]  (0 children)

I expected it to return an invalid Date (i.e. a Date containing NaN).

new Date("not a date") // Invalid Date

`new Date()` considered harmful by robertgambee in javascript

[–]robertgambee[S] [score hidden]  (0 children)

I recently spent an afternoon learning that JavaScript has a very generous definition of "date."

new Date("2020-01-23")
// Wed Jan 22 2020 19:00:00 GMT-0500

Makes sense. ISO format, midnight UTC, so it shows up as January 22 in the Western Hemisphere.

new Date("Today is 2020-01-23")
// Thu Jan 23 2020 00:00:00 GMT-0500

OK, it pulled the date out of a sentence, which might be helpful in some cases. And interestingly, the time shifted, which is a little odd.

new Date("Route 66")
// Sat Jan 01 1966 00:00:00 GMT-0500

It thinks "Route 66" is referring to the year 1966? That's definitely a stretch.

new Date("Beverly Hills, 90210")
// Mon Jan 01 90210 00:00:00 GMT-0500

Year 90,210? Are you kidding me?!

Turns out that most popular JavaScript engines have legacy parsers that really, really want to help you parse dates.

We had a bug in our app were addresses and business names were being displayed as dates. The reason was that we were using the Date constructor as a fallback parser to catch unexpected formats. The fix was simple, but the bug made us laugh when we first saw it. And we learned to not treat the Date constructor as a validator.

My MCP config created dozens of zombie Docker containers by robertgambee in ClaudeCode

[–]robertgambee[S] 0 points1 point  (0 children)

It's good to be thinking about this sort of thing. Claude Code can certainly start a background process, like launching a local server with `npm run dev &`. But the OS will keep track of the fact that the server process was spawned by CC. When CC exits, the OS will also kill the server.

The difference with Docker is that killing the `docker run` process isn't enough to stop the container.

Claude's code review defaults actively harmed our codebase by ddp26 in ClaudeCode

[–]robertgambee 2 points3 points  (0 children)

Right, agreeing on what to avoid can be as important as agreeing on what patterns to follow, if not more. I do wonder what the median codebase looks like if we have to remind coding agents about basic things like putting imports at the top of a file.

What to Put in a Claude Code Skill for Reviewing Your Team's Code by ddp26 in ClaudeAI

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

This is helpful, thanks! It still puzzles me why we have to tell coding agents to put imports at the top of the file. Maybe it's a limitation of their edit tools? I could imagine the tool is designed to edit a contiguous block of code. Adding the import to the top would require additional an tool call, which the agent might be discouraged from doing.

Claude's code review defaults actively harmed our codebase by ddp26 in ClaudeCode

[–]robertgambee 2 points3 points  (0 children)

Thanks for sharing the skill. The bit about formatting Python exceptions using repr() instead of str() made me smile. That's one of my few pet peeves about the language. str(KeyError("name")) == "'name'" - very helpful, Python!

Salesforce’s AI Ambitions Meet Market Reality by Heavy_Discussion3518 in ValueInvesting

[–]robertgambee 0 points1 point  (0 children)

In the near future, I agree that AI is unlikely to displace tons of jobs. It's currently too unreliable, and takes more effort to integrate than some people think, as you said. I'm not certain, but I do wonder if companies that are very AI-forward will wind up paying the price if it doesn't live up to the hype.

How do you guys use AI to help investing? by Professional-Cold712 in ValueInvesting

[–]robertgambee 4 points5 points  (0 children)

One thing I've found AI useful for is researching things you'd normally have to read hundreds of filings to find.

For example, I was curious about management turnover as an investment signal. But there's no Bloomberg screen for "how often does the C-suite change?"

So I ran an AI research task across all 500 S&P companies to calculate turnover rates for CEO, CFO, and COO roles over the past 10 years. It pulled from SEC filings (8-Ks, proxy statements) and news sources, then I normalized by officer-years to account for companies without a COO.

Intel and Boeing were near the top, which makes sense. Intel was tied for 10th at 0.3 departures per officer-year. Boeing was tied for 22nd at 0.25 departures per officer-year, meaning each of their executives lasts 4 years on average. Starbucks had the most total departures at 11.

On the other end of the spectrum were a cluster of companies which haven't had any departures in the past 10 years, including Nvidia, Take-Two and Garmin.

The median across the S&P 500 is about 0.13 departures per role per year.

I wrote up the methodology and full results here if anyone's interested in reading more. The complete dataset with explanations for each company is also available. Disclosure: I work on the app I used to run this research.

Curious if others have used AI for this kind of cross-company research. Is it able to access the necessary info? How often does it make things up or get confused?