All posts tagged #python all posts RSS-feed

What is async/await?

I've been pretty active on Hashnode and inactive here lately. So I'm going to repost an answer I gave on Hashnode here, because I'm lazy like that... This is a conceptual explanation, not a beginner tutorial. Yes, async/await a way for the thread to not sit idle while waiting for something (usually IO like files, database or network). When you read a file synchronously, your code does not do anything while the disk is busy. This means that for programs... full post»

PyCharm

I've started a draft about PyCharm 5 months ago. I really love PyCharm, it's the best! Everything is just so smooth. But it's hard to summarize what makes it great, and I don't want to list all the little details. I used Eclipse before, which wasn't bad, and there's not really any giant thing in PyCharm that Eclipse lacked (stability maybe). Rather, it's the hundred little details that add up to a much better experience. I also used Wing for... full post»

Dory backup removal

Daily backups, even if incremental, can fill up your disk space pretty quickly. So I've added some functionality to Dory to remove old backups. I wanted a way to keep a number of backups, with recent backups being closer together and past ones further apart. I've ended up using the reciprocal time-distance to each neighbour, multiplied by the square root of the age, as a 'redundancy score'. This way, if there are close neighbours (e.g. .two backups made on the... full post»

Minimal logging server & clients

Having solved backups, I attacked the the next important thing that gets in the way of building actual functionality: error logging. I've had some trouble setting up Sentry (possibly more my fault than Sentry's, but it does much more than I need so it's more work). I also tried Loggly which doesn't need server setup, but it captured mostly irrelevant syslog stuff and I'd need to pay a lot to keep logs for more than 7 days. So I figured... full post»

Reset static files cache each version (Django)

Ideally, you'd want your static files to be cached so that clients don't need to request them at all. In Apache, you can achieve this with: ExpiresActive on ExpiresDefault "access plus 1 year" Header append Cache-Control public But you also want the clients to request the new version as soon as anything changes. Since this can't be achieved with cache headers (they'll not request the files, so they never get the header), you can change the name instead. There's a... full post»

JSON: comments, order & numpy

Natively, JSON files do not support comments. Douglas Crockford removed them early on to prevent parsing directives, and the json standard is frozen now so they'll never return. Douglas Crockford is, of course, a pretty smart guy, so I'm not going to argue that decision. But like many other people, I want comments anyway. There's a package commentjson, but unfortunately it does not support Python 3. There are several other json tricks I like, so I made my own package... full post»