Paying my bills with 'free' ebooks
TL;DR: Small victories are more precious when you have nothing. Instead of burning through my savings, I'm now adding to it. The relief is priceless.
learnbyexample
TL;DR: Small victories are more precious when you have nothing. Instead of burning through my savings, I'm now adding to it. The relief is priceless.
This post shows how you can use ripgrep
, perl
and sd
commands to perform multiline fixed string search and replace operations from the command line. Solution with GNU sed
is also discussed, along with its limitations.
This stackoverflow Q&A got me thinking about various ways to construct a solution in GNU sed
if lookarounds are needed.
Only single line (with newline as the line separator) processing is presented here. Equivalent lookaround syntax with
grep -P
orperl
is also shown for comparison. Cases where multiple lines and/or ASCII NUL characters are present in the pattern space is left as an exercise.
ripgrep (command name rg
) is a grep
tool, but supports search and replace as well. rg
is far from a like-for-like alternate for sed
, but it has nifty features like multiline replacement, fixed string matching, PCRE2
support, etc. This post gives an overview of syntax for substitution and highlights some of the cases where rg
is a handy replacement for sed
.
Poster created using Canva
Either you've already heard of pandoc
or if you have searched online for markdown
to pdf
or similar, you are sure to come across pandoc
. This tutorial will help you use pandoc
to generate pdf
and epub
from a GitHub style markdown file. The main motivation for this blog post is to highlight what customizations I did to generate pdf
and epub
versions for self-publishing my ebooks. It wasn't easy to arrive at the setup I ended up with, so I hope this will be useful for those looking to use pandoc
to generate pdf
and epub
formats. This guide is specifically aimed at technical books that has code snippets.
Poster created using Canva
Above diagram created using Regulex
Above visualization created using debuggex for the pattern r'\bpar(en|ro)?t\b'
Photo Credit: Tranmautritam on Pexels
The above image was generated using matplotlib
courtesy code provided by Doing Math with Python book.