Programming Leftovers
-
Daniel Lemire ☛ How fast is rolling Karp-Rabin hashing?
A hash function maps values (e.g., strings) into a fixed number of strings, typically smaller than the original. It is useful to compare quickly two long strings, for example. Instead of comparing the strings, you may compare the hash values.
-
Jamie Brandon ☛ Zest: notation and representation
One of the fundamental characteristics of a nominal type is that two separate definitions are not equal, even if they have the same name and structure. This means that the entire concept of a nominal type is tied to a compilation model and to a process lifetime. If I compile a program once and run two copies of the executable, should type foo from the first copy be considered equal to type foo from the second copy? What if I compile the same code at two different optimization levels? Or for two different platforms?
-
Ruud van Asseldonk ☛ A reasonable configuration language
About six months ago, I was fed up with it. The particular it was HCL — Hashicorp Configuration Language — but that was just the trigger, it was hardly the only offender. The issue I was struggling with that day was to define six cloud storage buckets in Terraform. They were similar, but not quite identical. The kind of thing you’d do with a two-line nested loop in any general-purpose language, but where all the ways of achieving that in HCL were so much hassle, that is was far simpler to just copy-paste the config six times.
-
Logikal Solutions ☛ C++ – Defaults and Deletes – Pt. 1
Defaults and Deletes tend to be needlessly confusing for new C++ developers. Trying to learn this topic is why so many put on a diaper and go code Python. Hopefully this example series and discussion will allow you to man up. This is a continuation of my C++ series to assist junior/new developers so they can do something meaningful with their lives. No, you can’t use Python for a medical device.
-
Redowan Delowar ☛ Retry function in Go
The following implementation leverages the reflect module to achieve the above goals. We’re intentionally avoiding complex retry logic for brevity: [...]
-
Python
-
University of Toronto ☛ Solving one of our Django problems in a sideways, brute force way
All of this is solving the problem in the obvious way and also a cool thing to (try to) do in Django. Who doesn't want to write Python code that handles exceptional cases by, well, raising exceptions and then having them magically caught and turn into different rendered pages? But Django doesn't particularly support this, although I might have been able to add something by writing an application specific piece of Django middleware that worked by catching our custom 'no such user' exception and rendering an appropriate template as the response. However, this would have been my first piece of middleware, so I held off trying anything here until we updated to a modern version of Django (partly in the hopes it might have a solution).
-
Armin Ronacher ☛ Rye: A Vision Continued
In April of last year I released Rye to the public. Rye, both then and now, represents my very personal vision of what an improved Python packaging and project management solution can look like. Essentially, it's a comprehensive user experience, designed so that the only tool a Python programmer would need to interface with is Rye itself and it gets you from zero to one in a minute. It is capable of bootstrapping Python by automatically downloading different Python versions, it creates virtualenvs, it manages dependencies, and lints and formats. Initially developed for my own use, I decided to release it to the public, and the feedback has been overwhelmingly positive.
-
-
Shell/Bash/Zsh/Ksh
-
Shariq Raza Qadri ☛ Cleansing a Dump of 1.5 Million Email Addresses
Within milliseconds the script extracted all the emails found in the raw dump and compiled them into a new file namely clean_emails.txt
-