Docker basic commands

docker run [-d runs on background deamon, -p expose_port:docker_port , –name ]
docker start
docker stop
docker ps [-a include stopped containers]
docker rm
docker build -t
docker push

Examples:

docker run -p 2181:2181 -p 9092:9092 –env ADVERTISED_HOST=localhost –env ADVERTISED_PORT=9092 spotify/kafka
docker start kafka
docker stop kafka
docker rm kafka
docker build -t vlknbcr/test . #. represents I am in the folder where docker file it is.
docker push vlknbcr/test

Windows Service Operations

Create windows service
sc create <service_name> binpath= "<path_to_binary_executable>" [option1] [option2] [optionN]

Ex:
sc create Test binPath= "C:\Program Files\Aspera\Enterprise Server\bin\Debug\test.exe" DisplayName= "Test Central" start= auto

Delete windows service
sc delete <service_name>

Query windows service configuration:
sc qc <service_name>

Change configuration
sc config<service_name> binpath= “<path_to_binary_executable>”

Chek service status
sc query <service_name>

Unix commands

UNIX Directory Commands

Command What It Does
ls Lists the names of the files in the working directory. For more
complete information, use ls –alF (.
cd directoryname Changes the working directory to the one you named.
cd .. Brings you up one directory level.
cd Returns you to your home directory.
pwd Displays the pathname of the current directory.
mkdir newdirectoryname Makes a new directory.
rmdir directoryname Removes (deletes) an empty directory.

Working with Files

Command What It Does
cp filename1 filename2 Copies a file.
chmod Changes permissions for access to a file. Study the man page
before using this one.
diff Compares two files line by line (assumes text).
more filename Displays a text file one page at a time. Press the spacebar to
see the next page; press Q to quit. The man command works through
more.
mv filename1 filename2 Moves a file or changes its name.
rm filename Removes (deletes) a file.

Miscellaneous Commands

Command What It Does
Control+C Terminates most operations.
date Displays the current date and time.
echo Repeats whatever appears after the command (after
expansion).
help Displays a partial list of bash commands.
history Displays the last commands you typed. You can redo a command by
typing an exclamation point (!) followed immediately (no space) by
the number of that command in the history list. To repeat the last
command, type !!. To repeat the last filename, type
!*.
pico A simple UNIX text editor.
ps Displays a list of running processes.
sudo Lets you carry out commands for which the account you are using
lacks authority. You will be asked for an administrator’s
password.

List of all index & index columns in SQL Server DB

SELECT
TableName = t.name,
IndexName = ind.name,
IndexId = ind.index_id,
ColumnId = ic.index_column_id,
ColumnName = col.name,
ind.*,
ic.*,
col.*
FROM
sys.indexes ind
INNER JOIN
sys.index_columns ic ON ind.object_id = ic.object_id and ind.index_id = ic.index_id
INNER JOIN
sys.columns col ON ic.object_id = col.object_id and ic.column_id = col.column_id
INNER JOIN
sys.tables t ON ind.object_id = t.object_id
WHERE
ind.is_primary_key = 0
AND ind.is_unique = 0
AND ind.is_unique_constraint = 0
AND t.is_ms_shipped = 0
ORDER BY
t.name, ind.name, ind.index_id, ic.index_column_id

Latitude/Longitude Distance Calculation in SQL Server

Here’s the SQL function:

CREATE FUNCTION CoordinateDistanceMiles(
@Latitude1 float,
@Longitude1 float,
@Latitude2 float,
@Longitude2 float
)
RETURNS float 
AS  
BEGIN 
-- CONSTANTS
DECLARE @EarthRadiusInMiles float;
SET @EarthRadiusInMiles = 3963.1
DECLARE @PI  float;
SET @PI = PI();
-- RADIANS conversion
DECLARE @lat1Radians float;
DECLARE @long1Radians float;
DECLARE @lat2Radians float;
DECLARE @long2Radians float;
SET @lat1Radians = @Latitude1 * @PI / 180;
SET @long1Radians = @Longitude1 * @PI / 180;
SET @lat2Radians = @Latitude2 * @PI / 180;
SET @long2Radians = @Longitude2 * @PI / 180;
RETURN Acos(
Cos(@lat1Radians) * Cos(@long1Radians) * Cos(@lat2Radians) * Cos(@long2Radians) + 
Cos(@lat1Radians) * Sin(@long1Radians) * Cos(@lat2Radians) * Sin(@long2Radians) + 
Sin(@lat1Radians) * Sin(@lat2Radians)
) * @EarthRadiusInMiles;
END

Here is how to use it.

SELECT * FROM Hotels
WHERE dbo.CoordinateDistanceMiles(Latitude, Longitude, @ZipLatitude, @ZipLongitude)  @Radius 
--@Radius is miles.