Monday, April 9, 2018

CentOS 6 - Change hostname

To check the host name of CentOS 6,

hostname
hostname -f

To change the host name on CentOS 6,
  1. sudo vi /etc/sysconfig/network
    1. Update HOSTNAME=[hostname.domain.com] to match the FQDN.
    2. For example,
      1. HOSTNAME=cent6.contoso.edu
  2. :wq
  3. If necessary, update /etc/hosts file for internal networking. Change the host that is associated with the IP address.
    1. sudo vi /etc/hosts
    2. change the host name as needed.
  4. Run the hostname command to change the hostname on the server. For example,
    1. sudo hostname cent6.contoso.edu
  5. Restart network 
    1. sudo /etc/init.d/network restart


CentOS 6 - Add a user to sudoers

Here are steps in adding a user to sudoers in CentOS 6


  1. Log on as root ( or switch to su with root password).
  2. On the command window, do the following.
  3. Enter "visudo". 
  4. vi loads the sudoer file.
  5. Look for %wheel in the sudoer file by entering " /%wheel "
  6. Remove # from the line "#  %wheel  ALL=(ALL)  ALL" to enable the wheel group with same privileges as root.
  7. Save and exit vi via  :wq.
  8. To create a new user:
    1. adduser   [new_user_name]
    2. passwd    [new_user_name]   [password]
  9. Use the usermod command to add the user to the wheel group:
    1. usermod   -aG   wheel   [user_name]
  10. Switch to the non-root user by entering "su  -  [user_name]"
  11. Test by running a command that's allowed for root only.
    For example, /root is generally accessible only by root user. Try listing the content of /root. 
    1. sudo  ls  -al  /root

Friday, March 9, 2018

Git could not pull because there were uncommitted changes

Recently, I could not pull from origin master on my Visual Studio 2017. Git could not pull because there were uncommitted changes. I forgot that every change in my local repo must first be committed before pull.

One easy way to commit uncommited changes and then pull was using command-line on the Visual Studio solution folder as follows.

git add -A
git commit -m "your message"
git fetch origin master
git pull origin master
git push origin master //To push to the git

Saturday, December 16, 2017

Broken Korean Text Fix

Due to a unique character encoding widely used for Korean text in Korea, you may run into broken, unrecognizable text when opening a file (txt, smi, hwp, doc, etc) created on the Korean Windows platform.

Use Notepad++ to fix such broken Korean text. Notepad++ is an open-source software freely available to download (https://notepad-plus-plus.org). It is available for Windows only.

  1. Download and install Notepad++ on Windows.
  2. Open the original text in another text editor like the "Notepad".
  3. Copy all broken Korean text.
  4. On Notepad++, start a new blank file. 
    1. Go to Menu --> Encoding --> Character Sets --> Western Europe --> Windows 1252.
    2. Paste the copied broken Korean text on Notepad++'s new file.
    3. Go to Menu --> Encoding --> Encode in UTF-8
    4. When prompted to save the file, go ahead and save it.
    5. As the file is saved, the broken Korean text are fixed.


Wednesday, December 6, 2017

Age calculation based on today's date and birthday

To calculate the exact age based on today's date and birthday, it might be a little tricky to implement it in SQL. Below is one way to do it.
declare @BirthDate datetime = '12/1/2016'
declare @Today datetime = DateAdd(dd, DateDiff(dd, 0, getdate()), 0)

declare @age int = 
  ( CONVERT(int,CONVERT(char(8),@Today,112)) - CONVERT(char(8), @BirthDate, 112)) /10000

select @age 
/* returns 1 if today's date is 12/1/2017. */
/* returns 0 if today's date is 12/2/2017. */


Sunday, November 19, 2017

Full-Page Background Image CSS

Using CSS3, the following can be used for most modern browsers to produce full-page background image.
html {
  background-image: url('images/background-image.jpg') no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
Make sure to start the style with background-image: url(''). This style should work with IE9 or above.

Tuesday, October 3, 2017

Excel Services Issues Troubleshooting (2013/2010)

After updating Excel file on SharePoint from which a chart is published on SharePoint through Excel Service webpart, you run into an error "We're sorry. We ran into a problem completing your request. Please try that again in few minutes."

Solution: give it 3-5 minutes. If the worksheet chart used to work on SharePoint webpart before and if you did not modify the data connection(s), try again later. It seems to take a while for SharePoint to handle the updated Excel files in the back-end.

If the problem persists...

1. Check if Excel Services is running.
Central Administration -> System Settings -> Manage Services on Server -> Excel Calculation Service -> Check if "Started"

2.  Check if Excel Service Application is associated to Web Application in question.
Central Administration -> Application Management -> Manage Web Applications -> Select Web Application -> Configure Service Associations

3. Check if Trusted File Location is configured for Excel Service Application.
Central Administration -> Application Management -> Manage Service Applications -> Excel Service Application  -> Trusted file location -> Add  trusted file location -> Add address as https:// and Location Type as Microsoft SharePoint Foundation -> Keep the rest as is

4.  Check if document library configured to open documents in browser.
Site -> Library -> Library Settings -> Advanced Settings -> Check for "Opening Documents in the Browser"  Use either Server Default(Open in Browser) or Open in the Browser.

5. Grant "Excel Service Account" access to SharePoint Content database via PowerShell.

$wp = Get-SPWebApplication -identity
$wp.GrantAccessToProcessIdentity("Domain\Account that runs Excel Service")

**To check for service account - Central Administration -> Security -> Configure service accounts

6. Check if SharePoint Web Services in IIS has ASP.NET Impersonation disabled.
Select SharePoint Web Services from list of available of sites. -> Select Authentication from right panel and available authentications are displayed. -> Disable ASP.NET Impersonation if enabled.