Website Blocker using Python (Focus Booster)

General / 19 October 2025

Introduction:

Hello there! Most recently I have been having a hard time focusing whilst working from home. My home computer being both my work hub and my gateway into the deep webs of the internet (primarily YouTube with hour long documentaries on obscure vintage tech) has ended up making it difficult to focus back on work or personal projects. I've installed digital health blockers on my phone which has helped me get off of that, but the main issue remains, the PC is a hard battle of discipline that I am slowly losing.

I have tried extensions that block sites for a period of time, but I found them annoying to navigate and activate before I have had my coffee in the morning. They are also quite easy to switch off and only work on the browser the extensions are installed into. So I went looking for apps that can do what I need but found many to be paid/subscription based on Windows or worse require the internet to run which I found sketchy as all I wanted was a local way to block sites I've put in.

So, over the weekend I've written a script which can do all that. It's easy to use but requires to be ran as admin to take effect.

I am sharing it here to hope it can help someone else too!

The Guidelines:

When developing the script, I wanted it to not only work but also:

  • be easy to use.
  • be quick to run - one executable.
  • be reversable and easy to switch off.
  • track the minutes saved from doomscrolling.

Setup:

Disclaimer: This application is for Windows ONLY.

You can either paste the script from here into your Python terminal and run.

RUN AS ADMIN

Paste Bin Link: https://pastecode.io/s/p7e4pqwf

Ensure you started your terminal as administrator such as Visual Studio.

Or you can download the .zip from here and unzip it. Click the .exe to run inside the folder. RUN AS ADMIN

Zip Link: https://www.jolchawa.site/post/block-sites-with-python-productivity-script

Demo Video:

Here is a quick show of how it works, the blocking is global on the machine so no matter the browser the websites will no longer load. It may take some time to update on browsers such as Firefox so give it a minute or two and refresh as needed.


Start Guide:

Press the backup host file button to make a backup before you begin to block sites. This file contains data on how traffic is directed on your local machine so we need a backup copy in the event something goes wrong. In the event sites are not unblocking despite the button being pressed you can click the restore host button to restore everything to before you started to block. Changes can take a few minutes to work.

Adding Sites to the List:

The block list is a txt that contains all the sites loaded into the host file to block. This can be edited by the user by clicking on the button to find it then opening the file. The file is inside the installation directory and called block_list.txt. You can add a new website per line and save the file to be able to block those sites as well. You must reload the program for changes to take effect.

How it Works:

The script this builds upon is from is Patrick Loeber from Python Engineer.

Check out his site here for more great automation you can do with Python.

https://www.python-engineer.com/posts/website-blocker-in-python/

The script goes to the machines hosts folder and redirects traffic from those addresses to local host. The default local host address does not have a server connection (typically) so if loaded on a browser it shows a blank page. The unblocking process removes those sites from the file.

This script also keeps a counter keeps track of how long you have been blocking sites for and how many minutes you have saved by writing the minutes to the top of the block list file. The minutes saved data is read and returned every time the user unblocks the program and hits save minutes. The program must remain open to continue blocking. To check if the program is blocking the coloured box should shine green. If red the program is not blocking or has failed to do so.

Closing Notes:

This script has definitely helped me a lot already, I'm writing this blog post instead of watching another star trek next generation clips compilation after all! Discipline is important so let this tool help you reclaim your focus and put it into what really matters.


Convert Images with Python Script

General / 13 July 2025
This post reads better on my tech art blog!

Recently I've ran into a issue when using conversion sites to bulk convert a lot of my pictures to webp. Due to my large blogging habits I tend to run out of enough "credits" to convert the rest of all my pictures. Webp is a brilliant format, super optimised probably one of my top ones if I had a tier list (gif is number 1 moving funny images are hard to beat) so I made my own converter. It uses Python 3.11 but may run on lower versions too.

How the Script Looks


This script can:

  • Convert images solo or in bulk to desired format.
  • Auto prevents converting a image if it already matches the format.
  • Toggle on saving a folder to default selection to (useful on frequent conversions)

Theres two steps on getting it running: install PIL to your Python and paste my script into your Python terminal. 

Installing PIL:

If you're on Windows like me you can open up command prompt and type in.

pip install pillow

If you're not then I suggest heading over to this page for more info on installing Pillow PIL Fork.


Image Converter Script:

Now for my script, it uses TKinter for a GUI interface. I prefer visual widgets and tools so TKinter was perfect for my needs. 

Paste Script from Here


Demo Video:

Heres a video of using the script. I'm running Python inside Visual Studio Code as I prefer its syncing capabilities with Unreal Engine. 




Bibliography:

Useful links I used to build the tool and troubleshoot it.

Codecademy (2025). Getting Started with Image Processing in Python using Pillow. [online] Codecademy. Available at: https://www.codecademy.com/article/getting-started-with-image-processing-in-python-using-pillow.

Conyers, B. (2012). How to select a directory and store the location using tkinter in Python. [online] Stack Overflow. Available at: https://stackoverflow.com/questions/11295917/how-to-select-a-directory-and-store-the-location-using-tkinter-in-python.

GeeksforGeeks (2020). File Explorer in Python using Tkinter. [online] GeeksforGeeks. Available at: https://www.geeksforgeeks.org/python/file-explorer-in-python-using-tkinter/ [Accessed 12 Jul. 2025].

GeeksforGeeks (2021). Get Last N characters of a string Python. [online] GeeksforGeeks. Available at: https://www.geeksforgeeks.org/python/python-get-last-n-characters-of-a-string/ [Accessed 12 Jul. 2025].

TKDocs (2024). TkDocs Tutorial - Basic Widgets. [online] Tkdocs.com. Available at: https://tkdocs.com/tutorial/widgets.html#checkbutton [Accessed 12 Jul. 2025].

TKinter, J.W.L. updated T.G. started with (2022). Grid Layout Manager in Tkinter. [online] Python GUIs. Available at: https://www.pythonguis.com/tutorials/create-ui-with-tkinter-grid-layout-manager/.

TutorialPoint (n.d.). Python - Tkinter Checkbutton - Tutorialspoint. [online] www.tutorialspoint.com. Available at: https://www.tutorialspoint.com/python/tk_checkbutton.htm.

Ulhaq, M. (2012). How do I check if a directory exists in Python? [online] Stack Overflow. Available at: https://stackoverflow.com/questions/8933237/how-do-i-check-if-a-directory-exists-in-python.

Verma, A. (2019). Image Conversion (JPG ⇄ PNG/JPG ⇄ WEBP) with Python. [online] Medium. Available at: https://medium.com/@ajeet214/image-type-conversion-jpg-png-jpg-webp-png-webp-with-python-7d5df09394c9 [Accessed 12 Jul. 2025].

W3Schools (n.d.). Python - Global Variables. [online] www.w3schools.com. Available at: https://www.w3schools.com/python/python_variables_global.asp.

Final Major Project - Making Retro FOH Machines (Week 10)

General / 09 May 2023

Full Title: Game 3004 Final Major Project  - Making Retro FOH Machines (Week 10) (13/03/2023)

Research) FOH Machines

Having gone into laborious detail researching my Wurlitzer 1015 I decided I wanted to do justice to the remaining machines at work in my diner. This helped ensure they were fit to the period and would have been seen in diners also. The first order of business being the tills which had a bulky, low light LED and button clad design as the “THBNCRCR01” National Cash Register. Quite a catchy name and its design, unfortunately yellow with time, was very well documented online and I was able to get plenty of references to its design. Its buttons being unique for every dollar press would mean they would need separate unwraps however this would be a small price to pay getting the detail I need. As for the dime box, a model close to the Wurlitzer 1015 has previously been lurking in my research but I had yet to go into detail of documenting other machines such as the Sunbeam coffee maker, Kenmore Sears Microwave and much more. By searching sites such as Ebay.com and Worthpoint I was able to gather a lot of ref from individuals selling these relics that show off a lot of surface detail texture providing useful later on.

Modelling and Texturing) FOH Machines

As for my cash machine, I already had quite a high poly variant modelled beforehand but its mesh was very unoptimised. Much of the surface was bevelled in that was great for baking detail but served unnecessary geometry in the long run. I opted to target weld these extra tris out whilst also keeping the silhouette. For my dimebox much optimised had to be done as well since the irregular shape of the dimebox mad geometry difficult to bend at lower cost. With a lot of welding and cutting with a final symmetry this was achieved but I ended up having to separate the inside rotator of songs next to the mesh. This is to prevent baking issues. A element I had to research and consider mid model was the inclusion of a tap. For a diner sporting and advertising a large soda fountain it would be impossible to serve said soda with dispensers and ice cream. So I went on to model this in from cylinders also. The texturing process was quite simple however for many of the alphas with pictures/text from the product itself I would have to recreate these elements in Photoshop. Or utilise Photoshop with an AI upscaling tool to use the original referenced pictures as texturing base colour alphas. 

Lighting Updates) Increasing Indirect Lighting

One element I grew to learn more about was the indirect lighting element of the Unreal engine. Turns out a lot of my shadows and general scene was horrendously dark and unrealistic due to the nature of the low bounces. This was a simple fix as all it took was increasing the value of indirect lighting bounces on my lights, predominantly directional to 8-20 more. This was a hard element to balance since too little would prove dark but having too much could overblow the scene. Additionally static lighting suffered if too much was being bounced/overlapped. So I ended up removing a lot of lights to try to keep things simple, with improving indirect lighting it ended up filling the scene way more. So the ultimate cost was very performance efficient.

Bug) Emissive Fonts

To cut down on having to make alphas and textured geometry of elements that could change in font, my sign posted neon came about as a test of the Unreal text tools. These tools worked quite well at first until I realised the fonts I had gathered refused to be imparted into my scene without being set as offline first. Following setting the fonts as offline the project baked every single character down onto a sheet that at first made them appear black but then followed up with a blocked line. I had to use some old forum posts (Dj-Mindar, 2015) to resolve the issue of fixing the fonts by manually reviewing a lot of default settings and upscaling them. Strangely generating mesh distance fields for text was also disabled which rendered them unable by regular to be used as alphas in the font material hence getting rid of the glow. Really buggy overall but with a lot of tweaking I was able to use custom fonts of which I have linked below in my bibliography. These fonts were sourced from Dafont.com. 

Bibliography:

Dj-Mindar, dj-mindar (2015) How to make clean big text renderers with custom fonts?, Epic Developer Community Forums. Available at: https://forums.unrealengine.com/t/how-to-make-clean-big-text-renderers-with-custom-fonts/328859 (Accessed: 13 March 2023). 

Studio, D. (2022) Batuphat script, Batuphat Script Font. Available at: https://www.dafont.com/batuphat-script.font (Accessed: 13 March 2023). 

Dafont, D. (2005) Loki Cola, Loki Cola Font. Available at: https://www.dafont.com/loki-cola.font (Accessed: 13 March 2023).