Skip to content

Instantly share code, notes, and snippets.

View samirbehara-zz's full-sized avatar

Samir Behara samirbehara-zz

View GitHub Profile
def test_kubernetes_master_components_are_healthy(k8s_client):
ret = k8s_client.list_component_status()
# Iterate through the K8s Master components in the cluster and verify if the components are reporting healthy
for item in ret.items:
assert item.conditions[0].type == "Healthy" # Verify status of Scheduler, Controller and Etcd
print("%s\t%s\t" % (item.metadata.name, item.conditions[0].type))
# Check for Homebrew and install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Make sure we are using the latest Homebrew.
brew update
# Check for Minikube and install if we don't have it
// Install Minikube
brew cask install minikube
// Verify that minikube is properly installed
minikube version
// Install the Kubernetes Command Line Utility - kubectl
brew install kubectl
// Start Minikube
DECLARE @tracefile VARCHAR(256)
SELECT @tracefile = CAST(value AS VARCHAR(256))
FROM ::fn_trace_getinfo(DEFAULT)
WHERE traceid = 1
AND property = 2 -- filename property
SELECT *
FROM ::fn_trace_gettable(@tracefile, DEFAULT) trc
INNER JOIN sys.trace_events evt ON trc.EventClass = evt.trace_event_id
WHERE trc.EventClass IN (102, 103, 104, 105, 106, 108, 109, 110, 111)
@samirbehara-zz
samirbehara-zz / List of all Security Audit Events from SQL Default Trace
Last active December 5, 2017 01:49
List of all Security Audit Events from SQL Default Trace
--List all Security Audit Events
DECLARE @id INT;
SELECT @id = id
FROM sys.traces
WHERE is_default = 1;
SELECT DISTINCT eventid AS 'EventID' ,
name AS 'Event Name'
FROM fn_trace_geteventinfo(@id) GEI
-- Identifying Unused Indexes in SQL Server
SELECT OBJECT_NAME(s.[object_id]) AS [Table Name] ,
i.name AS [Index Name] ,
i.fill_factor ,
user_updates AS [Total Writes] ,
user_seeks + user_scans + user_lookups AS [Total Reads] ,
user_updates - ( user_seeks + user_scans + user_lookups ) AS [Difference]
FROM sys.dm_db_index_usage_stats AS s WITH ( NOLOCK )
INNER JOIN sys.indexes AS i WITH ( NOLOCK ) ON s.[object_id] = i.[object_id]
AND i.index_id = s.index_id
DROP TABLE IF EXISTS dbo.EmployeeSkills
--Create a sample table
CREATE TABLE dbo.EmployeeSkills
(
EmployeeID INT IDENTITY PRIMARY KEY,
FirstName VARCHAR(50),
Email VARCHAR(50),
Skills VARCHAR(100)
-- String splitting function
SELECT * FROM STRING_SPLIT('SQL SERVER 2016 ROCKS', ' ')
--Demonstration of COMPRESS and DECOMPRESS Features
SELECT COMPRESS ('New Features of SQL Server 2016')
SELECT CAST(DECOMPRESS(0x1F8B0800000000000400F34B2D57704B4D2C292D4A2D56C84F53080EF451084E2D2A4B2D52303230340300FD90F96A1F000000) AS VARCHAR(MAX))
-- Modify your existing masked columns
ALTER TABLE dbo.Customer
ALTER COLUMN LastName ADD MASKED WITH (FUNCTION = 'partial(2,"X-XXX-X",1)')
-- View the unmasked data in Customer table
SELECT * FROM dbo.Customer;