My Dev Log

Table of Contents

About

Source Repo -> https://github.com/utsavdarlami/dlog

log to track my dev journey

print("hello world")
hello world

2024

2024-10 October

2024-10-10 Thursday

  • 08:17 AM
    • writing my own pre-commit hook

      I created a pre-commit hook that automatically exports my journal Org file to HTML whenever I make a new commit to this dev journal repo. Previously, I often forgot to perform this export manually, which is what you are currently reading.

      Purpose of the Hook:

      • The pre-commit hook ensures that the latest changes in log.org are reflected in an HTML file, eliminating the manual process.

      Here is simple script that i needed to run every time a new changes was about to be committed

      # Run the org to HTML conversion command
      emacsclient -e '(progn (find-file "log.org") (org-html-export-to-html) (bury-buffer))'
      

      This sounds like pre-commit hook right? So i ended up setting my own pre-commit hook following the resources

      I am using pre-commit to set up the follow, which might have been a overkill. You can also modify the hooks provided inside the .git/hooks. Above resources covers it.

      Setting up .pre-commit-config.yaml to run the hook script

      repos:
      - repo: local
        hooks:
          - id: org-to-html
            name: Org File To HTML
            description: This hook converts org file to html
            entry: org_to_html.sh
            language: script
            files: 'log.org'
      

      Here the entry points to the main script that we want to run when we make the commit. More on here https://pre-commit.com/#new-hooks

      Lets look at the final hook script

      # org_to_html.sh
      #!/bin/bash
      
      # Get the list of modified files in the commit
      modified_files=$(git diff --cached --name-only)
      
      # Check if log.org is modified and index.html is NOT modified
      if echo "$modified_files" | grep -q "log.org" && ! echo "$modified_files" | grep -q "index.html"; then
          echo "Running org to HTML export for log.org..."
      
          # Run the org to HTML conversion command
          emacsclient -e '(progn (find-file "log.org") (org-html-export-to-html) (bury-buffer))'
      else
          echo "Skipping org to HTML export. Either log.org is not modified or index.html is modified."
      fi
      

      Complete Code

2024-10-09 Wednesday

2024-08 August

2024-08-03 Saturday

  • 07:24 PM - Log:

    how to set a type-hint for sub-classes in python

    my use-case

    from typing import Dict, Type
    
    class Operator:
    
        @abstractmethod
        def operate():
            raise NotImplementedError
    
    class Add(Operator):
        def operate():
            return +
    
    class Minus(Operator):
        def operate():
            return -
    
     # Dictionary \w the Operator's child as value
     operator_factory: Dict[str, Type[Operator]] = {
         "add": Add,
         "minus": Minus
     }
    
    

2024-07 July

2024-07-06 Saturday

2024-06 June

2024-06-28 Friday

2024-06-26 Wednesday

2024-06-24 Monday

2024-06-22 Saturday

  • 10:01 PM - Log:

    Was thinking about writing my own editor. Why you ask?

    • A fun and challenging project to work on

    I could write it down in python with help of blogs and videos. But i also want to learn new language so maybe i can try in rust.

    Found this good blogs on writing your or TUI based editor in C.

    And of course everything that is in C has a version in rust.

    Both seem to be great work.

2024-06-20 Thursday

Date: 2024-05-21 11:58

Author: felladog

Created: 2024-10-10 Thu 08:42

Validate