How to Configure Network Connection After Centos Minimal Install

After I install Centos 6.8 on my virtual machine, I don’t have a network connection ready for use. Following is the steps that I did to configure my network connection.

  1. Configure DHCP client on the default network interface eth0
    dhclient eth0
  2. Make sure that the networking is enabled
    # cat /etc/sysconfig/network
    NETWORKING=yes
    HOSTNAME=xxx.sd.dev
  3. Edit the network config file for the default network interface eth0
    vi /etc/sysconfig/network-scripts/ifcfg-eth0

    with the following value

    ONBOOT=yes
  4. Restart the network service
    service network restart
  5. Make sure that the
    ifconfig

Favorite Git Config

Having used to type git commands won’t make us able to remember those long line commands. I always relies on git alias. I would like to share with you my favorites git aliases.

You can either type the following command to add the alias into your git config.

git config --global alias.lol "log --pretty=format:'%C(green)%h %C(red)%ad %C(cyan)%an%C(green)%d %Creset%s' --date=short --graph"
git config --global alias.recent "for-each-ref --sort=-committerdate refs/heads --format='%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)'" git config --global alias.lg-tag "log --no-walk --tags --pretty='%h %d %s' --decorate=full" git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit

Or, you can also add new line to~/.gitconfig

Finally, to double check you can try the alias directly, or simply list them down.

$ git config --list | grep alias

alias.lg=!git lg1

alias.lg1=!git lg1-specific --all

alias.lg2=!git lg2-specific --all

alias.lg3=!git lg3-specific --all

alias.lg1-specific=log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'

alias.lg2-specific=log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'

alias.lg3-specific=log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'

alias.lg-tag=log --no-walk --tags --pretty='%h %d %s' --decorate=full

alias.lol=log --pretty=format:'%C(green)%h %C(red)%ad %C(cyan)%an%C(green)%d %Creset%s' --date=short --graph

alias.recent=for-each-ref --sort=-committerdate refs/heads --format='%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)'

 

Line Ending Issue with VSTO on Git

I have been taking for granted about line ending till I stumble upon a manifest mismatch on VSTO project. I used to think that storing in Unix-style in the remote Git repo, but working on Windows-style is the way to go. That way, I was allowing collaborators to choose their own style. But hey, VSTO only lives in Windows. Who cares about this generic rule of thumb!

*enough rambling*

I cloned a installer project for VSTO from a Git repo. All went well, but I got this error when trying to test the VSTO project on my Microsoft Word.

System.Deployment.Application.InvalidDeploymentException: Application manidest has either a different computed hash than the one specified or no has specified at all.

wordaddin

The above error tells that the manifest file does not match because of different computed hash. In a plain English, the manifest file might have been changed. And, the Git handling on line ending is the culprit.

git config core.autocrlf

The rule of thumb is to set it to ‘true’ for Windows and ‘input’ for Mac or Linux. Below is the

  1. ‘true’ => Checkout Windows-style, commit Unix-style
  2. ‘input’ => Checkout as-is, commit Unix-style
  3. ‘false’ => Checkout as-is, commit as-is

Having set the value to true would make the manifest file being modified while committing this file. Hence, we can specify this autocrlf in this particular project to false. Don’t try to change the value globally to false.

However, this solution is not quite elegant. Fortunately, Git offers more flexibility on dealing with this issue: adding .gitattributes file.

*.dll.manifest -text

This -text means that the files will not get normalized.

Further readings: https://help.github.com/articles/dealing-with-line-endings/#platform-windows

Remote Access on MySQL Database

While working on console is simple and fast, having a flexibility to visualize data through some kind of workbench is also powerful. Following is the steps to enable remote access on MySQL database.

  1. Create new user ‘myuser’ with password ‘mypass’
    CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
    CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';

    For older MySQL version, like  4.0.15, you need to use the following command and skip the grant command in step 2.

    GRANT ALL ON * to myuser@'localhost' IDENTIFIED BY 'mypass';
    GRANT ALL ON * to myuser@'%' IDENTIFIED BY 'mypass';
  2. Grant privileges for this new user
    GRANT ALL ON *.* TO 'myuser'@'localhost';
    GRANT ALL ON *.* TO 'myuser'@'%';
    FLUSH PRIVILEGES;
    FLUSH HOSTS;
    
  3. Modify the MySQL config (somewhere like etc/my.cnf or /etc/my.cnf.d/server.cnf) to enable the incoming connection from a certain ip address, or perhaps any IP address by setting it to 0.0.0.0 (not recommended for production).
    #Replace xxx with your IP Address 
    bind-address = xxx.xxx.xxx.xxx

    Don’t forget to restart mysql!

    service mysql restart
  4. Opening the port  by adding the following line in the iptables (/etc/sysconfig/iptables). This needs root access.
    -A INPUT -p tcp -m state --state NEW,ESTABLISHED -m tcp --dport 3306 -j ACCEPT

    Don’t forget to restart the iptables!

    service iptables restart


If all goes well, you can should be able to see your new user in the following table.

MariaDB [(none)]> select Host,User from  mysql.user;
+-----------------------+-------------+
| Host                  | User        |
+-----------------------+-------------+
| %                     | root        |
| 127.0.0.1             | root        |
| ::1                   | root        |
| localhost             | myuser      |
| localhost             | root        |
| localhost.localdomain |             |
| localhost.localdomain | root        |
+-----------------------+-------------+


To check the current user, we can check with the following command.

MariaDB [(none)]> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

From the other machine, you can can now access the sql using CLI or workbench.

mysql -h (ip-address) -u myuser -p

Personally, I like to use HeidiSQL in my Windows machine for accessing MySQL database remotely.

database
source: http://www.heidisql.com/screenshots.php?which=database



Access denied for user: 'root@xxx.xxx.xxx.xxx' (Using password: YES)

If you still cannot connect to you MySQL server, you may want to check the connection to your remote machine via telnet.

telnet (ip-address) 3306