Sunday, January 5, 2020

GVim is tiny on 4k monitors (Windows fix without any config file editing or commands)

After installing gvim in windows, the default scaling is too tiny in 4k monitors. To fix correct scaling, so windows looks normal, follow below

  1. Locate the gvim.exe binary (right click desktop shortcut and select "Open file location") it typically is found in "C:\Program Files\Vim\vim82" or "C:\Program Files (x86)\Vim\vim82"
  2. Right click file gvim.exe and select properties
  3. Select "Compatibility" tab
  4.  Click "Change High DPI Settings"
  5. In the popup, section "High DPI Scaling Override", select option "Override High DPI Scaling Behavior"
  6. In Drop-down "Scaling Performed by", select option "System (Enhanced)"
  7. Click OK and then OK to close
 Checked on Windows 10 Version 1909 and Vim 8.2



Tuesday, December 31, 2019

Copy windows directory (folder tree) preserving the directory source time stamps

If you copy a folder in windows, you may notice that the newly copied (created) folders will have the timestamp when the copy was done (not the original timestamps from source). However, the files inside would have kept the original timestamps.

To have the folder (directory) timestamp as well to reflect the same as the source folder, do below in command line

Robocopy E:\Source\Dir1 D:\Dest\Dir1 /DCOPY:DAT /COPY:DAT /E /R:0


Note: If you already had copied the files using explorer, this will not copy the files again. It will check all and copy only if there is a newer file; plus (more importantly) will also update the destination folder with source folder time stamp. It ran much faster too as it didn't do any new copies... just had to set the timestamps

Tested in windows 10 version 1909

Thursday, September 12, 2019

SAP Authentication with ODATA services

SAP ODATA service Authentication is a two step process

Step 1 - Get token
  1. Make a GET request to the service URL
  2. Make sure Authentication is set as Basic and username and Password are passed
  3. Set a header "X-CSRF-Token" with value "Fetch"
  4. Send the request to SAP
  5. Examine the response headers
  6. You should see a header "X-CSRF-Token"
  7. Get the value from this header

This token value is typically valid for 30 mins

Step 2: Send request with token
  1. Change GET to POST (if you are sending a payload to SAP ODATA Service)
  2. Authentication is set as Basic and username and Password are passed
  3. Set a header "X-CSRF-Token" and value received from last step
  4. Send the POST request


You may get "CSRF token validation failed" if CSRF validation is enabled (in SAP) and the token is not send in header.


Below shows the same steps as done via Postman

Getting the token in Postman
  1. Use a GET request to the Service URL
  2. Set header "X-CSRF-Token"
  3. Set value as "Fetch"
  4. Hit Send
  5. Examine the response headers 
  6. Pick the value for "X-CSRF-Token"


 Using the token for a service request
  1. Change service to POST
  2. In header, set "X-CSRF-Token" to value from last reponse header value
  3. Set the payload body and submit request



Tuesday, July 30, 2019

SQL Server database went to Recovery Pending State


My SQL server went to "Recovery Pending" state after I mistakenly enabled folder compression for the folder where the database files are residing.
To recover,

  1. Stop SQL services
  2. Disable folder compression in the folder where SQL database files are stored
  3. Start SQL services
  4. Execute below recovery steps if still having trouble to use the DB. in case the DB went to single user mode, just the last step from below is needed

ALTER DATABASE [SQL-DB-Name] SET EMERGENCY;
GO

ALTER DATABASE [SQL-DB-Name] set single_user
GO

DBCC CHECKDB ([SQL-DB-Name], REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS;
GO

ALTER DATABASE [SQL-DB-Name] set multi_user
GO

Turn on Windows 11 Fast Boot

If windows starting is slow, to enable windows 11 fast startup/boot,  Press Windows + R, type powercfg.cpl, and hit Enter.  This will direct...