bitten by system case sensitivity twice today

Today i was bitten by system case insensitivity twice:

  1. Maven test does not pick up Spring boot test profile properties
  2. git commit does not get the file name change.

Spring boot profile based config

In spring boot, we can have different resource files(.properties or .yml ) to hold properties. More over, we could have profile specific ones, like application-dev.yml will be loaded if dev is in the ActiveProfiles.

In our project, I passed in TEST as profile when doing junit test and the resource file name happens to be application-test.yml. Things work prefect in my local(OSX) as well as my colleagues(Windows). However when we do our CI build in a Docker container which has CentOS, I get exceptions for database url which is environment specific is not loaded. Spent more than 1 hour working with our CM to figure this out. So I changed test profile name to test and it worked.

git commit ignore file name case change

I was trying to change a class name from ReportdaoTest to ReportDaoTest but after check in, CI build failed again since only the class name changed but the file name remains the same.

GIT is case-sensitive but some file systems, like HFS, are not. Git can’t detect your changes, because the file names didn’t change really.

The two most popular operating systems that have case-insensitive file systems that I know of are

  • Windows
  • OS X

So to fix this, we can do either:

  1. git mv -f OldFileNameCase newfilenamecase
  2.  git config –global core.ignorecase false

For this SO question.


A good lesson. Previously never thought about this could cause trouble. I was thing it was char encoding problem and turns out not.

windows powershell vs cmd

CMD vs Powershell


  1. Does powershell support all commands as cmd.exe does?
  2. How do I quickly start PowerShell? (something like Windows-Key + R -> cmd)
  3. Is there any case where I would favor cmd over powershell?


  1. Yes, you can mostly use all the external commands that you would use in cmd much the same way in Powershell and Powershell has equivalents for cmd internal commands like dir. And of course Powershell comes with whole lot of cmdlets and the power of the .Net framework.
  2. If you are on Windows 7, pin it to your taskbar and use Win + Position to start. Or just press Winkey, type powershell ( mostly it is even shorter) in the start menu and hit enter. Win + R -> powershell would work as well.
  3. You might have to prefer cmd when running some batch / cmd files which may not run fine in Powershell ( but I would say, better write a powershell script to do the same.). Since I have started using powershell, I have never had the need to use cmd. And of course, you can always do cmd /c command from Powershell.

powershell vs bash

PowerShell basically is a playground for a .NET developer and Microsoft System Administrator. It’s very focused on system administration and tasks for Microsoft systems, not much for the individual workstation.

It is much heavier than cmd.exe, that’s why we need both.


  • Object-Oriented
  • .NET Objects and Forms supported
  • More Functions compared to cmd.exe and VBScript.
  • More Extensible via cmdlets, plugins.
  • Background Jobs

Bash is mostly not worth comparing to PowerShell, because Bash is mostly text-based and not object-based, and so you are sorting in a different way by delimiters, by position, by regular expressions and not by individual objects properties.

A good trick is the win + position(1/2/3…etc) to launch the programs in the taskbar.

set up mongo db in windows and osx


1. download mongo and unzip to some folder, rename folder to mongodb. i put it under ~/Documents/develop/mongodb

2. create  folder “data” under “mongodb”.  create folder “db” under “data”

create folder “logs” under “mongodb”. create file “mongodb.log”

3. create file mongodb.conf under ~/Documents/develop/mongodb/bin with content:

dbpath = ~/Documents/develop/mongodb/data/db
directoryperdb = true
logpath = ~/Documents/develop/mongodb/logs/mongodb.log
logappend = true
rest = true

now you can run mongo db server under bin folder: “mongod -f mongodb.conf”

and start mongo by run “mongo” under bin folder.

to make it easier to start.

1. add a file “.profile” under ~/ with content:

# MongoDB server Alias
alias mongod=”`/Documents/develop/mongodb/bin/mongod –config=~/Documents/develop/mongodb/bin/mongod.conf”

#MongoDB instance Alias
alias mongo=”~/Documents/develop/mongodb/bin/mongo”

restart the shell, you should be able to run mongod and mongo directly .

Note: if you also have .bash_profile, then write the above content there since it has higher priority. More info HERE


step 1-3 is similar.

To make mongod a windows service, we can run:

C:\mongodb\bin\mongod.exe --config C:\mongodb\mongod.cfg --install

To run the MongoDB service:

net start MongoDB

Stop or Remove the MongoDB Service

To stop the MongoDB service:

net stop MongoDB

To remove the MongoDB service:

C:\mongodb\bin\mongod.exe --remove

copy file through ssh

I use winscp or secure shell client.


sftp is (and works) similar to ftp

scp is a neat little program:

copy from a remote machine to my machine:
scp user@ /home/me/Desktop/file.txt

copy from my machine to a remote machine:
scp /home/me/Desktop/file.txt user@

copy all file*.txt from a remote machine to my machine (file01.txt, file02.txt, etc.; note the quotation marks:
scp “user@*.txt” /home/me/Desktop/file.txt

copy a directory from a remote machien to my machine:
scp -r user@ /home/me/Desktop/.



SCP Introduction

scp stands for secure cp (copy), which means you can copy files across ssh connection. That connection will be securely encrypted, it is a very secure way to copy files between computers

You can use scp to copy files from or to a remote server. You can also copy files from one remote server to another remote server, without passing traffic through your PC.

You can use scp on Linux, Mac and Windows (using WinSCP).

SCP Usage

scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]
Is the name or IP of the host where the source file is, this can be omitted if the from-host is the host where you are actually issuing the command
Is the user which have the right to access the file and directory, that is supposed to be copied in the case of the from-host, and the user who has the rights to write in the to-host
Is the file or files that are going to be copied to the destination host, it can be a directory but in that case you need to specify the -r option to copy the contents of the directory
Is the name that the copied file is going to take in the to-host, if none is given all copied files are going to keep its names

SCP Options

Preserves the modification and access times, as well as the permissions of the source-file in the destination-file
Do not display the progress bar
Recursive, so it copies the contents of the source-file (directory in this case) recursively
Displays debugging messages

JAVA_HOME in windows 7


  • The SetX command would do so:

    setx /M JAVA_HOME “C:\Program Files (x86)\Java\jdk1.6.0_17”

    /m means machine level.

  • To check the settings, use “set” command for all the variables.

    Use “echo %JAVA_HOME%” to check it specifically.

  • To append to the PATH:

    setx path “%PATH%;c:\home” /m

Here is a good site for windows commands 



In Unix, go to “/etc/profile” and add “export PATH=$PATH:/usr/java/jdk1.5.0_07/bin”.


useful Windows Run commands

System Configuration Utility  —————–  msconfig
Microsoft Powerpoint (if installed) —————–  powerpnt
Microsoft Word (if installed) —————– winword
Microsoft Paint —————– mspaint
Add Hardware Wizard —————– hdwwiz.cpl
Add/Remove Programs —————– appwiz.cpl
Control Panel —————– control
Calculator —————– calc

add tomcat to auto start in centos VPS

This article assumes that you have already installed the Apache Tomcat Server on your Linux Centos machine. If you need help with your with Apache Tomcat Setup then please click on the Link below.


Step 1: Create a file named tomcat6 in your /etc/init.d directory

$ cd /etc/init.d
$ gedit tomcat6 

If this file is created in windows, make sure the file be converted to UNIX format.  Otherwise,  following would happen:

/bin/bash^M: bad interpreter: No such file or directory

Below is one way to do the conversion in Notepad++

Step 2: Copy the following script and save the file

# chkconfig: 2345 80 20
# Description: Tomcat Server basic start/shutdown script
# /etc/init.d/tomcat6 -- startup script for the Tomcat 6 servlet engine

TOMCAT_HOME=/usr/local/apache-tomcat-6.0.35/bin START_TOMCAT=/usr/local/apache-tomcat-6.0.35/bin/ STOP_TOMCAT=/usr/local/apache-tomcat-6.0.35/bin/

start() {
 echo -n "Starting tomcat6: "
 echo "done."

stop() {
 echo -n "Shutting down tomcat6: "
 echo "done."

case "$1" in



 sleep 10

 echo "Usage: $0 {start|stop|restart}"

exit 0

Change the settings for the chkconfig based on your requirements. In a scenario where Apache Web server is in the front of Tomcat server with MySQL database usually the startup sequence should be MySQL then Tomcat and Apache Web Server in last. Also make sure you change the TOMCAT_HOME, START_TOMCAT and STOP_TOMCAT variables based on your Tomcat Install.

Step 3: Update the file permissions to make it executable by any user

$ chmod 755 tomcat6

Step 4: Make sure you have chkconfig command installed

$ chkconfig --help

otherwise just install it
$ sudo apt-get install chkconfig


Step 5: Run chkconfig command to add the script to the startup services

$ chkconfig --add tomcat6

(double dash before add )

Basically the chkconfig command automatically adds the symbolic links for starting and stopping the service based on the paramaters passed to it. Here is the list of links created from the above link. You can run the find command to check.

关于 chkconfig
$ find . -name “*tomcat6”

Response from the above command …

Step 6: Make sure scripts got added to the startup services

Type the following command on the Terminal

$ chkconfig --list tomcat6 

   (double dash before list)
Response should be something like this
tomcat6         0:off   1:off   2:on    3:on    4:on    5:on    6:off

Step 7: Verify your service is working

To start the Tomcat server
$ service tomcat6 start
To stop the Tomcat server
$ service tomcat6 stop