8,384 karma · joined December 3, 2010
I like automating things. Currently building lots of software in Python / Typescript / Postgres.
Contact me: aidankane on that google hosted email platform.
You might have more pages due to the extra size of each tuple, but it’s not likely to be a big difference.
I’d used an external int id that was syncing down into our system. There were then a bunch of other tables referencing it as a foreign key.
Overnight it turned into a sting. Clearly I was going to have some reconciliation work to do in any case and it may be that I maintained the old id as the primary key at that point (can’t recall).
It was just a good lesson in mitigating the blast radius - especially wrt things that are out of your control.
As an analogy, imagine that you’re dealing with dates in the same system (we were), you wouldn’t let their date format bleed into your other tables.
You draw a line at the boundary between the systems. In a way, natural keys break that rule.
For what it’s worth we use xlsxwriter and are happy with it.
The nice thing about both the ternary and the list compression is that they become statements of the form derived_thing = some_computation. The code flows better when you’re skimming it at a high level and thinking “then we get this”, “then pluck this”. You can think more about your reformed data and less about how it was reformed.
The alternative is that the branching obscures what you’re trying to create at each step.
Sometimes I’ll even use 2 list comprehensions instead of a loop (even though it’s slower) because it’s clearer to read something like:
odds = […]
evens = […]
That’s my experience, anyway.From what I’ve seen of htmx, we did have something in the same vein back in those days, albeit in a more adhoc manner.
For our part we built a lot of sites that were quite content heavy with a sprinkling of interactivity. Think blogs with comment sections. By the time I stopped doing that, the pattern we had settled on was loading the comments with the page (server rendered html). When someone posted a new comment (json) we returned the rendered comment as html and injected it in place. It worked well because we could share the same template fragment for a single comment and use it in the initial render loop.
As I say, don’t have experience with htmx so maybe my understanding is off.
Given that graphql is often shortened to gql is feel this is going to get confusing!
The article felt like it was fumbling around when the initial explain pointed right at the issue. I didn’t know this specific trick, so I did learn something I guess.
type Hash = Branded<string, "Hash">;On the whole I do agree with you about all this mess. The JS stdlib has a lot to answer for.
isOdd coerces to a number using Math.abs, so the string checks in isNumber don't apply.
function isOdd(value) {
const n = Math.abs(value);
if (!isNumber(n)) {
throw new TypeError('expected a number');
}
if (!Number.isInteger(n)) {
throw new Error('expected an integer');
}
if (!Number.isSafeInteger(n)) {
throw new Error('value exceeds maximum safe integer');
}
return (n % 2) === 1;
}
function isNumber(num) {
if (typeof num === 'number') {
return num - num === 0;
}
if (typeof num === 'string' && num.trim() !== '') {
return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
}
return false;
} isOdd = x => x % 2 === 1
...
It's one of those things that doesn't pop up all that often and never changes. I've looked through my whole codebase and there are 3 occurrences.Aside: I don't use Dart, but does that mean that you have to rely on each different type of iterable to implement these functions?
I know that during the exception you can pry into the variables from the stack. When do they get cleaned up?
Countfire makes software for the construction industry. Our software is well loved because we try to design solutions that are a magnitude more efficient than existing tools.
We use all sorts of tech, but mostly MobX, React, Typescript, Python, Hasura, Postgres, Terraform, and AWS.
We have a great loyal customer base and lots of exciting ideas that need bringing to life.
Previously based in London, now seeking remote devs across the UK.
More info here https://www.countfire.com/careers/
Feel free to contact me directly aidan@countfire.com
Note, applicants must be resident in the UK. No recruiters.
To our surprise, every winter the pond freezes over and the fish are fine come spring. In fact they’re thriving and we don’t touch the pond at all - it doesn’t even have a pump.
The other pond could definitely do with cleaning out, but again it’s teaming with wildlife. There’s not a huge window between when the newts leave for the summer and when it freezes in winter. By the time it thaws and we think to do something about it the newts are back again.
So much of what happens in house construction is about water management and without understanding it, it’s common for people to create issues. Regularly see patios that cover airbricks, causing suspended timber floors to rot.
Now that I have ruff giving me a bunch of instant feedback, pyright has become a bit of a distraction due to the lag.
My point is that for most usecases you can go a lot further by looking at the code that’s running rather than the language that’s running it.