9/26/2016

GIS frequently used commands

# To read the height file at row 683, column 120
gdallocationinfo N37W122.hgt 120 683

9/21/2016

Virtual box cannot boot to GUI?

haha
1) Find the IP of your virtual box, say, 192.168.1.23
2) From your host machine: ssh 192.168.1.23
3) ssh console: sudo service lightdm start
4) The virtual box should start the GUI

9/07/2016

How to fix Docker

Sometime the Docker won't stop and it just hangs on any commends.

So far I haven't figured out a way to fix it without rebooting the machine.

Even worse: docker daemon won't start after reboot. I need to reinstall docker to get it to work. And I had to use the following commands to uninstall and reinstall to make it work.

$ sudo apt-get autoremove --purge docker-engine
$ rm -rf /var/lib/docker
$ sudo apt-get install docker-engine

Google Maps S2 Cells

It uses Hilbert Curve to get the cell ids.

8/29/2016

GIT commonly used commands

# How to remove unwanted file from last commit
git reset --soft HEAD~1
Then reset the unwanted files in order to leave them out from the commit:
git reset HEAD path/to/unwanted_file
Now commit again, you can even re-use the same commit message:

git commit -c ORIG_HEAD

# How to resolve conflicts
After git rebase "branch", there may be conflicts.
If you want to accept the changes from the "branch" , just run:
git checkout --ours
Or If you want to accept the changes from current branch, just run:
git checkout --theirs

Or
git rebase -s ours

How to fix this error: error: The following untracked working tree files would be overwritten by merge:
git fetch --all
git reset --hard origin/master

# Change the remote

git remote rm origin
git remote add 'the url'
git pull origin main
 
# Set the origin/main as the up stream
git branch -u origin/main main
 
# Push the branch wip to the remote origin
git push origin wip

# Ignore a local folder without checking in the .gitignore file
echo yougood-base >> .git/info/exclude
git update-index --assume-unchanged yougood-base

Submodules
=========

g submodule add https://github.com/google/protobuf.git third_party/protobuf
g submodule update --init  # to clone all submodules


How to re-init submodules
emacs .git/config: delete all submodule related items
Then run: git submodule init


After git pull in the main repo, need to run the following commands:
git submodule sync --recursive
git submodule update --recursive


git diff shows no changes, but git status shows a list of modified files:
Open .git/config and make sure:
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        ignorecase = true
        autocrlf = false
        symlinks = false


======
To setup github ssh access
For error: ex_exchange_identification: Connection closed by remote host
 
I guess GFW make it.
By checking: https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port
which I followed the ~/.ssh/config added the port 443.
and use command like: "proxychains -q git pull", it is working now.

Here is what is working now through https, and through proxy:

❯ proxychains -q ssh -T git@github.com
The authenticity of host '[ssh.github.com]:443 ([20.205.243.160]:443)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[ssh.github.com]:443' (ED25519) to the list of known hosts.
Hi LeisureLinux! You've successfully authenticated, but GitHub does not provide shell access.


8/25/2016

bazel commonly used commands

bazel build foo/bar
bazel build -c opt --strip=always foo/bar/...

# How to verbose log bazel build
bazel build -s //my:target
bazel test --runs_per_test=10