YAML Syntax

I’ll use this post to summarize some YAML syntax:

1. The dash in a sequence counts as indentation, so you can add a sequence inside of a mapping without needing spaces as indentation.

1: 
- 2: 3
  4: 5
- 6: 7
  8: 9
- 10
=> {1 => [{2 => 3, 4 => 5}, {6 => 7, 8 => 9}, 10]}

Basically, dashes delimit objects, and indentation denotes the “value” of the key-value pair.

Posted in Uncategorized | Leave a comment

Remote desktop toolbar hidden

It is because the MustBeSeen flag is turn on for some app and you need to follow the instructions below:

As a best practice suggestion, hit Ctrl+Shift+Escape and disable anything on the Startup tab you don’t need autorunning. That limits how many things load there, and lessens how many programs can raise the MustBeSeen flag.”

Posted in Uncategorized | 1 Comment

Angular server cannot start

If you get “ng.ps1 cannot be loaded because running scripts is disabled on this system”, you execute the following command:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

Now you can run “ng serve -o”.

Posted in Uncategorized | Leave a comment

pgAdmin 4 loading forever

  1. Open the Registry Editor (Run -> regedit)
  2. Find HKEY_CLASSES_ROOT.js and change the ContentType value as text/javascript
  3. Restart the pgAdmin server
Posted in Uncategorized | Leave a comment

Powershell script didn’t run

Normally, I can run it by either right-click it and choose “run with powershell” or in the Powershell window, run “.\myscript.ps1”. My only choice now is in the powershell window and run “Powershell.exe -File .\myscript.ps1”. I’m using powershell 5.1. Any idea?

It turned out I don’t have permission to the target directory. I have manually share the target directory with myself and then I can run the powershell script. It doesn’t make any sense to me.

Posted in Uncategorized | Leave a comment

Useful Git commands

git diff origin/master
git diff master..Prod -- web\en-US\docs\faq.txt

git push --dry-run

git push origin <tag_name>
git push origin --delete <tagname>
git tag -d <local tagname>
git tag -d release/aug2002

git branch --set-upstream-to=origin/master
git restore hello.c
git remote rm origin
#how to add existing git folder to remote
git remote add origin <REMOTE_URL> 
git checkout -b subbranch_of_b1 branch1

git clean -df
git checkout -- .

git reset --hard HEAD~  # if you accidently push your commit to another branch (not current) and don't want to keep it

git pull origin Prod-OS  # then you need to fetch head (pull branch explicitly)

git remote show origin
git rebase origin/develop
git rebase --continue
git rebase --abort
git add/rm <conflicted_files>

#if you get this message - "Your branch and 'origin/develop' have diverged"
git fetch --all
git branch backup-develop
git reset --hard origin/develop
git pull

#if you have local changes when switching branches
git stash mycurrentBranch
git checkout -f anotherBranch

#how to delete a remote branch called "fun_feature"
git checkout master
git branch -d fun_feature
#Delete a remote branch
git push origin --delete remoteBranchName
git branch --all

#undo last commit and don't want to save it for future use
git reset --hard HEAD~1

#revert commit on featured branch and merge with current develop branch
#On branch feature/googleTagManager
git revert --no-commit c99f68fb
git merge develop

#revert most recent commit
git revert c99f68fb..HEAD
git commit

#Always checkout single file from origin to avoid getting old version
#Remember to pull first!!!
git pull
git checkout origin/master web\en-US\docs\faq.txt

#Reset local files to match the remote branch
git reset --hard origin/phobos

#how to find the date a commit is done
git show -s --format=%ci <commit>

#if you get SSL local certificate error, run this:
git config --global http.sslbackend schannel

#stash
git stash
git stash list
git stash apply

#how to delete remote and local branch
git push -d <remote_name> <branchname>
git branch -d <branchname>

#If your editor can exit with an error code -- Git will abort the commit. When using VIM, type
:cq
#to exit with an non-zero error code and abort the commit.

#How to override last local commit message
git commit --amend -m "DCPE-2773"

#How to reset token - Encode your Email Address: • user@example.com becomes user%40exam
git remote set-url origin https://<your_encoded_email>:<your_token>@gitlab.com/<username>/<repository>.git

#If you found your local branch is clean but is not matching remote 
git branch --set-upstream-to=origin/mergeMain mergeMain

#if your local branch and remote branch are diverged, you can reset it to remote (do not rebase)
git reset --hard origin/<branch-name>

#Remove untracked files and directories:
git clean -fd

#User token to clone (here my user id is 75xxxxx)
git clone https://userid:token@gitlab.com/username/repo.git

#How to revert auto-merge when you are using the git merge command
git reset --soft HEAD~1

#How to include token in pull
git remote set-url origin https://<YOUR_GITHUB_USERNAME>:YOUR_PERSONAL_ACCESS_TOKEN>@github.com/<YOUR_REPO>.git

#If you're doing a merge and found conflicts
#You can override the file that has conflicts with either in the current branch (ours) or the incoming branch (theirs)
git checkout --ours <file>
git checkout --theirs <file>

#How to get back the file you deleted but haven't pushed to remote yet
#Find the commit before you delete your file and then check it out
git log -- path/to/your/file
git checkout <commit-hash> -- path/to/your/file

#I tried to commit a change but I was using another account so it failed.
#Need to update the configured email:
git config user.email "YOUR_EMAIL"

#How to find a corresponding commit of Prod on a dev branch
#On prod branch and the exact commit, run the following and you'll get the commit
git merge-base prod dev

#How to rollback to a previous commit, make change to it, and push it to override master
git push origin HEAD:master --force

Posted in Uncategorized | Leave a comment

Gitlab – how to bring a local folder to remote repository

$ git remote add origin <remote repository URL>
# Sets the new remote
$ git remote -v
# Verifies the new remote URL
$ git push origin master

Posted in Uncategorized | Leave a comment

Angular Issue – error TS2591: Cannot find name ‘module’.

It takes me a lot of time to fix it. Thanks to https://fireflysemantics.medium.com/adding-types-node-to-angular-84a629976c86 for the solution below:

Approach

npm i -S @types/node

Then in tsconfig.json

"angularCompilerOptions": {
"types" : ["node"]
....
}
Posted in Uncategorized | Leave a comment

Car camera I bought in Feb. 2020

VIOFO A119 V3 2560 x 1600P Quad HD+ Dash Camera with GPS Logger 2020 EditionVIOFO

Posted in Uncategorized | Leave a comment

Sharepoint Powershell Permission issue

See screenshot

Posted in Uncategorized | Leave a comment