Useful snippets

    rename branch locally & remote

    Wed 22. April 2026 | 2026-04-22

    notes:

    1. rename in lazygit
    2. git push $remote --delete $old_name
    3. git push origin HEAD

    This will close any existing PR if exists


    # Source - https://stackoverflow.com/a/30590238
    # Posted by CodeWizard, modified by community. See post 'Timeline' for change history
    # Retrieved 2026-04-22, License - CC BY-SA 4.0
    
    # Names of things - allows you to copy/paste commands
    old_name=feature/old
    new_name=feature/new
    remote=origin
    
    # Rename the local branch to the new name
    git branch -m $old_name $new_name
    
    # Delete the old branch on remote
    git push $remote --delete $old_name
    
    # Or shorter way to delete remote branch [:]
    git push $remote :$old_name
    
    # Prevent git from using the old name when pushing in the next step.
    # Otherwise, git will use the old upstream name instead of $new_name.
    git branch --unset-upstream $new_name
    
    # Push the new branch to remote
    git push $remote $new_name
    
    # Reset the upstream branch for the new_name local branch
    git push $remote -u $new_name

    https://stackoverflow.com/questions/30590083/git-how-to-rename-a-branch-both-local-and-remote/30590238#30590238

    At a glance: Branch renaming commands

    Task Command

    Rename current branch git branch -m new-name Rename specific branch git branch -m old-name new-name Delete remote branch git push origin --delete branch-name Push renamed branch git push origin new-name Set upstream tracking git push --set-upstream origin new-name

    https://www.codecademy.com/article/rename-git-branch

    git branch -m new-branch-name 

    https://www.freecodecamp.org/news/git-rename-branch-how-to-change-a-local-branch-name/

    Media only screen CSS

    Thu 16. April 2026 | 2026-04-16

    @media only screen and (min-width: 500px) {
    
    }
    // X-Small devices (portrait phones, less than 576px)
    // No media query for `xs` since this is the default in Bootstrap
    
    // Small devices (landscape phones, 576px and up)
    @media (min-width: 576px) { ... }
    
    // Medium devices (tablets, 768px and up)
    @media (min-width: 768px) { ... }
    
    // Large devices (desktops, 992px and up)
    @media (min-width: 992px) { ... }
    
    // X-Large devices (large desktops, 1200px and up)
    @media (min-width: 1200px) { ... }
    
    // XX-Large devices (larger desktops, 1400px and up)
    @media (min-width: 1400px) { ... }

    https://getbootstrap.com/docs/5.3/layout/breakpoints/#min-width

    lalala test

    Wed 01. April 2026 | 2026-04-01

    Cloudcannon test add "new post" via UI

    CSS position floatish relative

    Wed 01. April 2026 | 2026-04-01

    https://css-tricks.com/almanac/properties/p/position/#absolute

    To make the child element positioned absolutely from its parent element we need to set this on the parent element itself:

    .element {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
    }
    
    .parent {
      position: relative;
    }

    Now properties such as left, right, bottom and top will refer to the parent element, so that if we make the child element transparent we can see it sitting right at the bottom of the parent:

    markdown

    Tue 10. March 2026 | 2026-03-10

    <mark>Highlighted text</mark>

    ==Highlighted text==

    Highlighted text

    ==Highlighted text==

    [!NOTE] En note

    [!WARNING] Warning!!

    [!IMPORTANT] !!!!!!

    Check if a file exists (pre-push example)

    Tue 03. March 2026 | 2026-03-03

    Bash

    Check existence

    lpo() {
      if [[ -f ".git/hooks/pre-push" ]]; then
        echo ".git/hooks/pre-push was found:"
        echo "pre-push is activated"
      else
        if [[ -f ".git/hooks/pre-push.sample" ]]; then
          echo ".git/hooks/pre-push was not found:"
          echo "but .git/hooks/pre-push.sample was found:"
          echo "pre-push is deactivated"
        else
          echo "Hmmmmm"
        fi
      fi
    }

    Nvim edit file

    po() {
      if [[ -f ".git/hooks/pre-push" ]]; then
        echo ".git/hooks/pre-push was found:"
        nvim .git/hooks/pre-push
      else
        if [[ -f ".git/hooks/pre-push.sample" ]]; then
          echo ".git/hooks/pre-push was not found:"
          echo "but .git/hooks/pre-push.sample was found:"
          nvim .git/hooks/pre-push.sample
        else
          echo "Hmmmmm"
        fi
      fi
    }

    Lua nvim edit file

    function file_exists(name)
       local f=io.open(name,"r")
       if f~=nil then io.close(f) return true else return false end
    end
    
    function open_prepush()
      if file_exists(".git/hooks/pre-push") then
        vim.cmd("vsplit .git/hooks/pre-push")
      elseif file_exists(".git/hooks/pre-push.sample") then
        vim.cmd("vsplit .git/hooks/pre-push.sample")
      else
        vim.cmd("echo 'Hmmmmm'")
      end
    end
    
    vim.keymap.set("n", "<leader><leader>po", open_prepush, { desc = "Open pre-push a new split" })