Bonus Drop #79 (2025-03-16): Weekend Hodge Podge
Prettier; krep; Distilled Flexoki
The Weekend Bonus Drop makes up for referencing one resource many times but never covering for it, showcases a C-based string search tool faster than ripgrep, and has a short update regarding my {hrbrthemes} package.
Oh, and Trump invoked “the act” I mentioned the other day. We’ll just leave it at that for now.
TL;DR
(This is an AI-generated summary of today’s Drop using Ollama + llama 3.2 and a custom prompt.)
Prettier is an opinionated code formatter that enforces consistent style across projects with minimal configuration, supporting multiple languages and integrating with editors and pre-commit hooks (https://prettier.io/)
Krep is a high-performance C-language string search utility that outperforms traditional tools like ripgrep by using optimized algorithms and hardware capabilities, dynamically selecting the best approach based on pattern characteristics (https://davidesantangelo.github.io/krep/)
The hrbrthemes package now includes “distiller” ggplot2 color and fill scales for Flexoki, providing smoothly interpolated continuous scales from the Flexoki color palette (https://tangled.sh/@hrbrmstr.dev/hrbrthemes)
Prettier
Every so often, I scan through the Drop archive looking for particularly themed resources to see if I took for granted folks would know about some piece of tech by just referencing it in some other tech section. I cover “formatters” a few times a year, and in each Drop, I just assume folks know about Prettier (GH), but have never covered it. We fix that today!
Prettier is an opinionated code formatter that enforces a consistent style by parsing your code and re-printing it with its own rules. It has gained popularity among developers for its ability to maintain code consistency across projects with minimal configuration.
The tool takes care of all your formatting needs without any manual intervention. It ensures consistent spacing and indentation throughout your code, while automatically handling line wrapping based on your specified maximum line length. The tool standardizes your use of quotes, choosing either single or double quotes consistently across your codebase. Prettier also adds proper semicolons where needed and formats object structures with uniform styling, resulting in clean, readable code that follows consistent conventions.
The tool supports multiple languages and file types including JavaScript, TypeScript, HTML, CSS, JSX, and more.
To add Prettier to your project:
Install Prettier locally:
npm install --save-dev --save-exact prettier
Create an empty config file:
echo '{}\n' > .prettierrc
Create a .prettierignore file to exclude certain files:
echo -e "# Ignore artifacts:\nbuild\ncoverage\n" > .prettierignore
Format all files with Prettier:
npx prettier . --write
Prettier will also follow rules specified in .gitignore if it exists in the same directory.
I’ll stress again that it is opinionated. So much so that you may not need a config file at all. A minimal config might look like:
{ "singleQuote": true, "trailingComma": "es5", "tabWidth": 2, "semi": true}
which defines the following formatting rules:
singleQuote: true – Uses single quotes (') instead of double quotes (") for string literals
trailingComma: “es5” – Adds trailing commas where valid in ES5 (objects, arrays, etc.), but not in function parameters
tabWidth: 2 – Sets indentation to 2 spaces
semi: true – Ensures semicolons are added at the end of statements
Prettier can also be integrated with code editors through extensions, most of which will run the tool on save, paste, and as you type (which are all also usually configurable options).
If you use pre-commit hooks, Prettier is handy if you also want to all committed code is properly formatted:
Install husky and lint-staged:
npm install --save-dev husky lint-stagednpx husky init
Add to your package.json:
{ "lint-staged": { "**/*": "prettier --write --ignore-unknown" }}
Now, Prettier will run on project files before they’re committed.
As we’ve noted in other Drops, adopting a standardized code formatter has some real benefits, “consistency” being paramount, as tools like Prettier help ensure a uniform code style throughout the entire codebase regardless of who contributed the code. This approach saves valuable time by eliminating often lengthy debates about formatting styles and preferences. With formatting handled automatically, we can focus our mental energy on what truly matters—the logic and functionality of their code. The consistent styling also truly does improve code readability, making it easier for anyone to understand and maintain the codebase. Finally, standardized formatting simplifies the onboarding process for new team members, who no longer need to learn and adapt to custom style guides before making meaningful contributions.
Prettier’s opinionated approach removes the burden of decision-making about code style, allowing development teams to focus on what truly matters: writing functional, maintainable code.
I’m making heavy use of Prettier in my painfully show conversion of Project 2025 PDFs to markdown.
krep
Krep (GH) is a high-performance string search utility developed by Davide Santangelo that outperforms traditional search tools. It implements multiple optimized search algorithms and makes full use of modern hardware capabilities.
If you’re thinking — “ah! another cool Rust-based tool” — you’d be wrong. It’s written in the C language.
I’ll let that set in a bit before continuing.
So, aboot (see, I’m Canadian! Let me in, pls!) those algorithms…
Krep dynamically selects the most appropriate search algorithm based on pattern characteristics and available hardware. For very short patterns (less than 3 characters), it employs the Knuth-Morris-Pratt (KMP) algorithm, while longer patterns (over 16 characters) trigger the Rabin-Karp algorithm. Medium-length patterns utilize SIMD instructions (AVX2 or SSE4.2) when available, or fall back to the Boyer-Moore algorithm.
Along with the SIMD speedup, Krep also uses memory-mapped file I/O to avoid costly read() system calls and has minimal allocations to reduce memory overhead while maintaining performance.
For files larger than 1MB, Krep splits the search into chunks and processes them concurrently, with intelligent chunk boundaries to ensure accurate results.
Benchmark tests demonstrate Krep’s superior performance compared to traditional search tools:
ToolTime (seconds)Speed (MB/s)Relative Performancekrep0.781,2825.0xripgrep1.486762.0xgrep2.953391.0xYes. It beats ripgrep.
I will also let that set in a bit before continuing.
Davide explains the whole thing (in detail) in this blog post.
It is important to note that Krep won’t replace ripgrep for you any time soon, since you likely use ripgrep (or grep) to actually see the results. Krep — at present — just provides summary results like this:
$ krep -i state *.mdFound 12 matchesSearch completed in 0.0002 seconds (255.55 MB/s)Search details: - File size: 0.05 MB - Pattern length: 5 characters - Using Boyer-Moore-Horspool algorithm - Case-insensitive search
However, you should poke at the -s option to see if it’s worth adding Krep as a system/project dependency if you regularly search within strings in scripts.
Distilled Flexoki
(If you do not know what Flexoki is, hit up these Drops, though it will be painfully obvious what it is here).
My {hrbrthemes} package was updated on Friday to include “distiller” {ggplot2} color and fill scales for Flexoki.
Per the official {ggplot2} docs:
The distiller scales extend brewer scales by smoothly interpolating 7 colours from any palette to a continuous scale. The distiller scales have a default direction = -1. To reverse, use direction = 1. The fermenter scales provide binned versions of the brewer scales.
NOTE: I have not made fermenter versions (file an issue on the Knot if you’d like those).
The distiller scales use a single color from either the light or dark Flexoki palettes, and a spectrum equivalents interpolate across the full palettes.
library(ggplot2)library(hrbrthemes)library(patchwork)faithfuld |> ggplot() + geom_tile( aes(waiting, eruptions, fill = density), show.legend = FALSE ) + scale_x_comma() + scale_y_comma() + labs(x = NULL, y = NULL) + theme_ipsum_gs(grid="") -> gg(gg + scale_fill_flexoki_dark_distiller()) + (gg + scale_fill_flexoki_dark_spectrum()) + (gg + scale_fill_flexoki_dark_distiller("red", -1)) + (gg + scale_fill_flexoki_dark_spectrum(-1)) + (gg + scale_fill_flexoki_light_distiller()) + (gg + scale_fill_flexoki_light_spectrum()) + (gg + scale_fill_flexoki_light_distiller("red", -1)) + (gg + scale_fill_flexoki_light_spectrum(-1)) + plot_layout( ncol = 2 ) + plot_annotation( title = "Flexoki Distiller Scales", theme = theme_ipsum_gs(grid="XY") )
The functions are fully documented, but the README still needs to be updated.
Should have this up on CRAN in a couple weeks.
FIN
Remember, you can follow and interact with the full text of The Daily Drop’s free posts on:
🐘 Mastodon via @dailydrop.hrbrmstr.dev@dailydrop.hrbrmstr.dev
🦋 Bluesky via https://bsky.app/profile/dailydrop.hrbrmstr.dev.web.brid.gy
Also, refer to:
to see how to access a regularly updated database of all the Drops with extracted links, and full-text search capability. ☮️