All posts by Roman

powercfg

Disable hibernation

powercfg /hibernate off

What sleep states are available?

powercfg /availablesleepstates

What device caused last wake?

powercfg /lastwake

What device blocks sleep?

powercfg /requests

# Ignore driver
powercfg /requestsoverride DRIVER "Realtek High Definition Audio" System

# View ignored drivers
powercfg /requestsoverride

git

Configure

# Config username and email
git config --global user.name jdoe
git config --global user.email john.doe@example.com

# To avoid detected dubious ownership warning
git config --global --add safe.directory "*"

Initialize Repository

git init                     # Create a new Git repository
git clone <url>              # Clone an existing repository

Working with Changes

git status                   # Show the working directory status
git add -A                   # Stage all changes
git add <file>               # Stage a specific file
git reset                    # Unstage all files (keep changes)
git reset <file>             # Unstage a specific file
git mv <source> <dest>       # Rename file
git checkout -- <file>       # Revert local file changes
# Revert changes on single file to previous commit
git checkout <commit-hash> <file>

# Revert changes made by specified commit
git revert <commit-hash>

Commit & History

git commit -m "Message"       # Commit with a message
git log                       # View commit history
git log --oneline             # Compact log view
git log -3 --name-status      # Last 3 changes with file names
git log --follow -p -- <file> # Follow file history

Blame

# Blame from line X to Y
git blame -L X,Y <file>

# Show changes on a file from a specified commit
git show <commit-hash> -- <file>

Push & Pull

git push origin <branch>    # Push changes to the remote branch
git push origin -u <branch> # Push new branch
git pull                    # Fetch and merge changes from remote
git fetch --all             # Fetch all from remote
# Delete branch from remote
git push origin --delete <branch>

Patching

# Patch from uncommitted changes
git diff > changes.patch

# Patch from changes between two commits
git diff commit1 commit2 > changes.patch

Branching

git branch                 # List all branches
git branch <name>          # Create a new branch
git branch -d <name>       # Delete a branch
git checkout <branch>      # Switch to a branch
git checkout -b <name>     # Create and switch to a new branch
git merge <branch>         # Merge a branch into the current one

Tagging

git tag <name>             # Create new tag
git push origin --tags     # Push tags to remote
# Tag with current date / time
git tag PUB_$(date -Format 'yyMMdd')
git tag PUB_$(date -Format 'yyMMdd-HHmm')

Undoing Changes

git restore <file>           # Discard changes in a file
git reset --hard             # Discard all uncommitted changes

Remote Repositories

git remote -v                # Show remote repositories
git remote add origin <url>  # Add a remote repository
git remote rm origin         # Remove a remote repository

ClickOnce and file association issues

I was trying to setup .sql file association working for our lightweight SQL editor, but it took me more time than expected. Below are steps that I applied to make it work:

  • Configure the file association
  • Make sure at least .NET Framework 3.5 is used
  • Activate ClickOnce Full Trust
  • Read arguments using activation data
  • Make sure no app is associated with the extension you want to use!

The last step was probably the biggest problem from the start, so I am not sure all of the other steps are required. I enabled ClickOnce logging and found out there is a warning regarding the extension.

File association for ".sql" skipped, since another application is using it.

I had to remove association information from registry (HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.sql) and restart!

Activate Synapse on Super (Win) key only

It cannot be done directly from Synapse settings, but you can do it manually by editing Synapse configuration.

  1. Close Synapse
  2. Edit ~/.config/synapse/config.json
  3. Set activate to Super_L
{
  "ui" : {
    "shortcuts" : {
      "activate" : "Super_L",
      ...
    }
  }
}

There is a disadvantage of this solution. You basically can’t use any other global key combinations with Win key, because it will always trigger Synapse.

If that is a problem you can use xcape to assign an additional one-click function to a modifier key.

xcape -e 'Super_L=Super_L|space'

MikroTik and L2TP alternative for Android

Android 12 dropped support for L2TP. If you are looking for alternative and OpenVPN is not possible, because it’s setup in TAP mode, which is not supported on Android nor iPhone, you may try SSTP instead. SSTP (Secure Socket Tunneling Protocol) is protocol developed by Microsoft.

There is a open source client Open SSTP available Google Play. However MikroTik’s PAP implementation does not seem to work, so your only option is to use MS-CHAPv2, but it is more secure anyway!