This is taken from the Intrepid individual’s github blog1
I was working on something when I suddenly needed some regex-fu. I opened a new browser tab, typed regex101 and pressed enter, and then I realized, I am at a place where sites usually take five fucking minutes to load up. I thought:
We need to improvise
I needed something that could work offline. I googled around (which took ages) to find an offline tool, but none of the results impressed me, and then I found this - a way of getting regex101 itself working offline. Turns out, some wget magic is all that we needed.
Cloning the site locally took around 10 minutes:
I used python’s http.server module to host the site:The site loaded, but a few things were still out of place, like it still tried fetching jquery, font awesome, a font from google fonts etc.
I then manually fetched each and every dependency, and edited the index.html to use the local ones.
Thirty minutes later I had a fully offline version up and running.
But we’re not done yet. I am not gonna
cdinto some directory and run
python3 -m http.server 8090everytime I need regexes.
We need to improvise.
Thanks to Linux Utility Lab, I learnt how to host sites using Apache this semester. I already had
apache2installed. The rest was easy:
Create a directory that will host all the files:
Put all the site required files there:
Create a site configuration:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/101regex.com.conf
sudo vim /etc/apache2/sites-available/101regex.com.conf
Here’s how my config looked:
Now edit the hosts file to have a working url:
sudo vim /etc/hosts
Add line: 127.0.0.1 101regex.com
Enable the site
sudo a2ensite 101regex.com.conf
restart the server.
sudo service apache2 restartI now have a fully functional Regex101 running locally at: 101regex.com
I don’t even remeber what I wanted to do with regexes in the first place. So, I decided to write down a blog post.
By the way, It’s Four In The Morning.