7/20/2017

.inputrc file content

set bell-style none  # disable bell
"\e[1;5C": forward-word   # ctrl + right
"\e[1;5D": backward-word  # ctrl + left

7/19/2017

Make gitg settings better

Change the font of the source view part:
gsettings set org.gnome.desktop.interface monospace-font-name "Ubuntu Mono 11"

Segmentation fault (core dumped) Cgiwin/X X11 forwarding fix

The error:
[603333.290448] nautilus[12834]: segfault at 0 ip 00007f6f312959bf sp 00007ffebb652cc8 error 4 in libc-2.23.so[7f6f31200000+1bf000]

How to fix:
ssh to the remote server machine:
cd /usr/lib/x86_64-linux-gnu
sudo ln -s /usr/lib/nvidia-375/libGLX_indirect.so.0 .

Cannot ping a windows 10 machine

haha
1. Make sure the network discovery and file sharing is turned on the Windows 10 machine
2. Make sure the firewall allows the connection.
3. Restart your router to refresh your changes. This is important because Windows can cache the network discovery result.

7/18/2017

How to use X11 forwarding with cygwin/X

Install xinit when install cygwin
Make sure the ssh server has X11Forwarding yes
Make sure "ForwardX11 yes" in the .ssh/config file from the ssh origination machine (not server). Otherwise, copy/paste won't work correctly.

On the client: export DISPLAY=:0.0
Start  XWin Server under Cynwin-X folder in the start menu

Then run ssh with: ssh -Y

In the ssh console, you can start a GUI application, such as xterm, eclipse etc.

X11 forwarding font too small HiDPI HDPI

export GDK_SCALE=2
export QT_SCALE_FACTOR=2
export ELM_SCALE=2

Or
Add, e.g. GDK_SCALE=2 before running an app.
For example GDK_SCALE=2 nautilus

For eclipse, add GDK_DPI_SCALE=2 before running it.
For emacs, add GDK_DPI_SCALE=2 before running it. Also the font size needs to be changed to: height 205

For Filezilla, I have to install Filezilla 3.25 from source code. There are a bunch of dependencies missing because I'm using Ubuntu 16.04.
Important libraries to install:
sudo apt install libgtk-3-dev
Manually installed libfilezilla (version 0.9.1), libgnutls (version 3.4.15), and wdwidgets (version 3.0.2).
Once Filezilla uses GTK 3.0, it can be launched with GDK_SCALE=2 in front of it.
For example:
GDK_SCALE=2 filezilla

For Ubuntu 16.04 Chrome:
  1. sudo gedit /usr/share/applications/google-chrome.desktop
  2. Find this line:
Exec=/usr/bin/google-chrome-stable %U
  1. Change it to this:
Exec=/usr/bin/google-chrome-stable --force-device-scale-factor=2 %U
  1. Save/close, relaunch Chrome. 

7/16/2017

How to setup cygwin

Install Cygwin: https://cygwin.com/install.html
If you need to install new packages, run the installer again!

Packages to install:
python
openssh
emacs

Because the version with cygwin package has slowness problem, to use git:
Install https://gitforwindows.org/
Add:
/cygdrive/c/Program Files/Git/mingw64/bin to PATH environment variable.
Need to change some git colors in cygwin:
git config --global color.diff.meta black
To use gitk:
Make sure gitk runs: /cygdrive/c/Program Files/Git/cmd/gitk (May need to restart the computer or something, not sure why it didn't work for the first try and all of a sudden, it worked)

Change git core.editor to "D://Programs//wscite//scite.exe"
Install meld, then run:
git config --global merge.tool meld
git config --global diff.tool meld

git config --global mergetool.meld.path "C://Program Files (x86)//Meld//Meld.exe"
git config --global --add difftool.prompt false
git config core.symlinks false

In .bash_profile, add
. ~/.bashrc

Download https://onedrive.live.com cygwin_home folder.

Set HOME environment variable set to C:\Users\liangzou (Must be done first. Need to logout and login again)

  1. Verify your Cygwin /etc/passwd does not exist
  2. "mkpasswd -l > /etc/passwd" (this will insert many accounts into your new /etc/passwd)
  3. Change the user name in the /etc/passwd to the one you want.
  4. kill all cygwin shells
  5. bring up a new cygwin shell

If ctrl+arrow appears as ;5C or ;5D, make sure ~ is pointing to C:\Users\liangzou instead of /home/liangzou, which should be pointing to C:\Users\liangzou

Install Windows Terminal, then use the config settings:

===============
{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    // Add custom actions and keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
    "actions": 
    [
        // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
        // These two lines additionally bind them to Ctrl+C and Ctrl+V.
        // To learn more about selection, visit https://aka.ms/terminal-selection
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        // { "command": "paste", "keys": "ctrl+v" },
        // Press Ctrl+Shift+F to open the search box
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 0
            },
            "keys": "alt+1"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 1
            },
            "keys": "alt+2"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 2
            },
            "keys": "alt+3"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 3
            },
            "keys": "alt+4"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 4
            },
            "keys": "alt+5"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 5
            },
            "keys": "alt+6"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 6
            },
            "keys": "alt+7"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 7
            },
            "keys": "alt+8"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 8
            },
            "keys": "alt+9"
        },
        // Press Alt+Shift+D to open a new pane.
        // - "split": "auto" makes this pane open in the direction that provides the most surface area.
        // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
        // To learn more about panes, visit https://aka.ms/terminal-panes
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ],
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{f1c07b24-77de-4f9a-9a53-e9b7788c150e}",
    "disableAnimations": true,
    "largePasteWarning": false,
    "multiLinePasteWarning": false,
    "profiles": 
    {
        "defaults": 
        {
            "antialiasingMode": "cleartype",
            "colorScheme": "liang",
            "cursorColor": "#FF0000",
            "cursorShape": "filledBox",
            "fontFace": "Ubuntu Mono - Bront",
            "fontSize": 11
        },
        "list": 
        [
            {
                "closeOnExit": "graceful",
                "commandline": "C:/cygwin64/bin/bash.exe --login -i",
                "guid": "{f1c07b24-77de-4f9a-9a53-e9b7788c150e}",
                "historySize": 999999,
                "icon": "C:/cygwin64/Cygwin-Terminal.ico",
                "name": "Cygwin",
                "padding": "0, 0, 0, 0",
                "snapOnInput": true,
                "useAcrylic": false
            },
            {
                "commandline": "cmd.exe",
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt"
            },
            {
                "commandline": "powershell.exe",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": true,
                "name": "Windows PowerShell"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": true,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#61AFEF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#56B6C2",
            "foreground": "#DCDFE4",
            "green": "#98C379",
            "name": "One Half Dark",
            "purple": "#C678DD",
            "red": "#E06C75",
            "selectionBackground": "#FFFFFF",
            "white": "#DCDFE4",
            "yellow": "#E5C07B"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        },
        {
            "background": "#F5E7D1",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#000000",
            "green": "#13A10E",
            "name": "liang",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#000000",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        }
    ],
    "showTabsInTitlebar": false,
    "theme": "light",
    "wordDelimiters": " ()$\"';:<>[]\u2502"
}

=======================


7/07/2017

Solve docker mounted volume permission denied issue

docker run -ti \
-v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro \
-u $( id -u $USER ):$( id -g $USER ) \
some-image:lastest bash

Increase Docker container size

sudo service docker stop
sudo dockerd --storage-opt dm.basesize=50G
sudo service docker start

Then delete all images and containers
Then docker pull

http://www.projectatomic.io/blog/2016/03/daemon_option_basedevicesize/

7/06/2017

GIT command autocomplete with alias/aliases

# To Setup:
# 1) Save the .git-completion.bash file found here:
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
# 2) Add the following lines to your .bash_profile, be sure to reload (for example: source ~/.bash_profile) for the changes to take effect:
# Git branch bash completion
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
# Add git completion to aliases
__git_complete g __git_main
__git_complete gc _git_checkout
__git_complete gm __git_merge
__git_complete gp _git_pull
fi
# Make sure you actually have those aliases defined, of course.
alias g="git"
alias gc="git checkout"
alias gm="git merge"
alias gp="git pull"