Posts for year 2023

Using fdupes to cleanup my file server

The overall problem:

Like many of us, I am guilty of copying files haphazardly, promising myself that I'll organize them later. This has built up to a significant problem over the years, particularly with old smartphone backups. I had a bad habit of dumping photo folder backups onto my server, with each dump containing even more dumps of old photos, resulting in multiple levels of duplication. Using the command-line tool called fdupes I've only just managed to get some of it under control.

fdupes is a command-line application designed to find and identify duplicate files within a directory or a set of directories. It employs various techniques to compare file contents and determine duplicates, enabling efficient cleanup and reclamation of storage space.

To streamline the review process and make sure I know what's about to happen before deleting any files, I created a simple bash wrapper script. This script acts as a nice safety belt, preventing accidental fat finger deletions.

Avoiding the rm -rf Pitfall:

As many of us have learned the hard way, the rm -rf command can have disastrous consequences if misused (goodbye email server with 2000 emails). A simple typo or a wrong path can result in irreversible data loss. To mitigate this risk, the bash wrapper script avoids using rm -rf altogether. Instead, it leverages the safer alternative of moving duplicate files to a temporary trash directory for review and then subsequent manual deletion.



find_files() {
  fdupes -rn "$*" > ${file}
  echo "Duplicate files have listed in ${file}"

remove_files() {
  echo "Reading from ${file}"
  echo ""
  read -p "Type yes to continue" choice
  case "$choice" in
    yes )
      mkdir -p "${TRASH}"
      while IFS= read -r line; do
        mv "${line}" "${TRASH}"
      done < ${file}
      echo "Duplicate files have been moved to ${TRASH}"
      exit ;;
    * )
      echo "Exiting"
      exit ;;

while getopts "rf:" option; do
  case "${option}" in
      remove=true  ;;
      file="${OPTARG:-dupes.txt}"  ;;
shift $((OPTIND - 1))

case "$remove" in
  true )
  false )
    find_files $*

Understanding the Script:

The script utilizes the fdupes command-line tool to identify duplicate files within a given directory or set of directories. Here's how it works:

Finding Duplicate Files:
  • The find_files function invokes the fdupes command with the -rn flags, instructing it to recursively search for duplicates and list the results in a specified file.
  • If no file name is provided as an argument, the script will use the default file name dupes.txt to store the duplicate file list.
  • After the duplicates are found, the script informs us that the duplicate files have been listed in the dupes.txt file.
Removing Duplicate Files:
  • The remove_files function allows us to decide whether to remove the duplicates. Make sure to review the dupes.txt file before running.
  • If no file name is provided as an argument, the script will still refer to the default dupes.txt file to read the duplicate file list.
  • After printing the file listing the duplicates, the script prompts us to confirm our decision by typing "yes."
  • If confirmed, the script creates a temporary trash directory and proceeds to move the duplicate files to it.
  • Finally, it provides a message confirming that the duplicate files have been successfully moved to the trash directory.

Using the Script:

To utilize the script effectively, follow these steps:

  • Copy the script into a text editor and save it as
  • Open a terminal and navigate to the directory containing the script.
  • Make the script executable by running the command: chmod +x
Execute the script with appropriate options:
  • To find duplicate files: ./ <directory>
  • To remove duplicate files: ./ -r

Note: If you don't specify a file name using the -f argument, it will default to using the dupes.txt file for listing duplicate files.

Making a Lazy Dark Theme with Darkreader

Dark Reader is a web browser plugin the analyzes web pages and aims to reduce eyestrain while browsing the web.

I have been using the Dark Reader plugin in firefox for quite some time now and I quite like it. However, there is one drawback - it has made me procrastinate building a dark theme for my blog. As it turns out, exporting and using the Dark Reader generated theme for your website is pretty damn easy.

Frist you need the plugin installed in your browser, you can get it from the Firefox Add-ons page here

Next You have to switch darkreader to the "new design" (the old design looks more modern IMHO) from the dev tools popup in order to access the export button found in the settings dialogue.

  • Click Dark Reader icon.
  • Click Dev tools (in the bottom-right corner).
  • Click Preview new design.
  • Click on settings in the popup
  • Click on Manage Settings
  • Click on Export Dynamic Theme

Source: Question: Export CSS?


Once you have the css, oen it up in an editor and wrap it in the css media rule for the dark perferd color scheme. Then it's a simple matter of adding it to your webpage as you would any other css file, boom a dark theme for your website with little to no effort.

@media (prefers-color-scheme: dark) {
                        /       \
                       .==.    .==.
                      ((  ))==((  ))
                     / "=="    "=="\
                    /____|| || ||___\
        ________     ____    ________  ___    ___
        |  ___  \   /    \   |  ___  \ |  |  /  /
        |  |  \  \ /  /\  \  |  |  \  \|  |_/  /
        |  |   )  /  /__\  \ |  |__/  /|  ___  \
        |  |__/  /  ______  \|  ____  \|  |  \  \
     ___|_______/__/ ____ \__\__|___\__\__|___\__\_______
    |  ___  \ |  ____/ /    \   |  ___  \ |  ____|  ___  \
    |  |  \  \|  |___ /  /\  \  |  |  \  \|  |___|  |  \  \
    |  |__/  /|  ____/  /__\  \ |  |   )  |  ____|  |__/  /
    |  ____  \|  |__/  ______  \|  |__/  /|  |___|  ____  \
    |__|   \__\____/__/      \__\_______/ |______|__|   \__\

    /*! Dark reader generated CSS | Licensed under MIT */


Playing with chatGTP

ChatGTP, impressive if a bit dumb

ChatGTP has been taking the internet by storm with its impressive ability to spit out reasonable sounding text, but it is all that great? is it clippy back from the dead to take revenge on us all?

Key take-aways:

  • It takes all character out of your sentences.
  • It has a habit of dropping key details for a more generic sentence.
  • The longer your inputs are the more likely it's spit out nonsense. Giving it small sections at a time to work on is better.
  • Everything it produces need to be proofread.
  • It really, really likes the work additionally for some reason.

Biggest criticism


ChatGTP has a very strange ability to "corporatize" just about just about anything and remove everything remotely human about a sentence.

Take this for example:

Me: reword and expand: chat gtp is able to produce quite good sentences but has all the contextual intelligence of a flat worm.

ChatGTP: While ChatGPT is capable of generating high-quality sentences through natural language processing, its contextual understanding is still limited compared to human intelligence. In other words, while ChatGPT can produce coherent and grammatically correct responses, it lacks the depth of understanding and nuance that humans possess. This is because ChatGPT relies on a vast database of pre-existing text to generate its responses, rather than having the ability to truly comprehend the meaning behind language like a human brain can. Therefore, while ChatGPT can provide helpful information and engage in conversation, it should be used as a tool to assist human intelligence, rather than a replacement for it.

If that paragraph doesn’t scream corporate press release maybe you need to take a day off from work and let your brain detox.

Final thoughts

ChatGTP is a tool, that, while amazing a first glance has it's issues and bugs. It's certainly a step above clippy and has it's place helping to flesh out emails, memos and cover letters but it's formal and stiff. An article on New Yorker titled "ChatGPT Is a Blurry JPEG of the Web" was close, Chat GTP is actually a smudge tool for text.

Now let's see Chat GTP's take on this article:

Me: write a article regarding the pros and cons of chatgtp in this style: [...]

ChatGTP: ChatGTP has been making waves on the internet with its ability to produce coherent and grammatically correct sentences through natural language processing. However, is it really as impressive as it appears to be? This article will take a closer look at the pros and cons of ChatGTP.

One of the most significant drawbacks of ChatGTP is its tendency to remove all character from your sentences. It has a habit of dropping key details to produce more generic responses, which can result in it missing the point entirely. Additionally, the longer the input, the more likely it is to produce nonsense. Therefore, giving it smaller sections to work on is generally more effective.

Another major drawback of ChatGTP is that everything it produces needs to be proofread. While it can generate coherent and grammatically correct sentences, it can also produce awkward phrasing or sentences that don't quite make sense. This means that anything produced by ChatGTP should always be double-checked to ensure accuracy and clarity.

The biggest criticism of ChatGTP, however, is its tendency to "corporatize" just about anything and remove all human qualities from a sentence. It has a knack for producing sentences that sound like corporate press releases, which can make it difficult to engage in a natural conversation.

In conclusion, while ChatGTP is an impressive tool, it is not as impressive as it initially appears to be. It has some significant drawbacks, including removing character from sentences, producing generic responses, and its tendency to "corporatize" language. Therefore, it should be used as a tool to assist human intelligence, rather