This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Selects a random element from input list using the weights on T to sway selection. | |
/// T must have a Weight property on it. | |
/// </summary> | |
public T SelectRandom<T>(List<T> objects) | |
{ | |
int totalWeight = 0; | |
T selected = default(T); | |
foreach (T obj in objects) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Selects a random element from input list using the allocations remaining to sway selection | |
/// T must have AllocationRemaining, Weight and Id properties on it. | |
/// </summary> | |
public T SelectRandom<T>(List<T> objects) | |
{ | |
int totalWeight = 0; | |
T selected = default(T); | |
foreach (T obj in objects) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DateTime.From(Number.Round((Number.From([Time]) * 24 * 3600)/RoundToNearestXSecond, 0)*RoundToNearestXSecond/(24*3600)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class AsyncHelpers | |
{ | |
/// <summary> | |
/// Execute an async method which has a void return value synchronously | |
/// </summary> | |
/// <param name="method">Task<T/> method to execute</param> | |
public static void RunSync(Func<Task> method) | |
{ | |
Argument.CheckIfNull(method, nameof(method)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE STATISTICS sys.syscolpars | |
UPDATE STATISTICS sys.sysschobjs | |
UPDATE STATISTICS sys.syssingleobjrefs | |
UPDATE STATISTICS sys.sysiscols | |
GO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertTimestamp(timestamp) { | |
var d = new Date(timestamp * 1000), // Convert the passed timestamp to milliseconds | |
yyyy = d.getFullYear(), | |
mm = ('0' + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0. | |
dd = ('0' + d.getDate()).slice(-2), // Add leading 0. | |
hh = d.getHours(), | |
h = hh, | |
min = ('0' + d.getMinutes()).slice(-2), // Add leading 0. | |
ampm = 'AM', | |
time; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Delete-SqlDatabase($serverName, $databaseName) { | |
Import-Module SQLPS | |
$server = New-Object Microsoft.SqlServer.Management.Smo.Server($serverName) | |
$db = $server.databases[$databaseName] | |
if ($db) { | |
$server.KillAllprocesses($databaseName) | |
$db.Drop() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Run-SqlCommand($serverName, $databaseName, $command, $timeoutSeconds = 30) { | |
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection | |
$SqlConnection.ConnectionString = "Server=$serverName;Database=$databaseName;Integrated Security=True" | |
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand | |
$SqlCmd.CommandText = $command | |
$SqlCmd.Connection = $SqlConnection | |
$SqlCmd.CommandTimeout = $timeoutSeconds | |
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter | |
$SqlAdapter.SelectCommand = $SqlCmd | |
$DataSet = New-Object System.Data.DataSet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update ft | |
set ft.description = 'test' | |
from firstTable ft | |
inner join secondTable st on | |
ft.id = st.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS #toDelete | |
SELECT bmi.* INTO #toDelete | |
FROM [dbo].[BCS_Main_Input_With_absence_Holiday_And_Wage_Elements] bmi | |
INNER JOIN @fiscalWeeksForRelease fw | |
on | |
fw.FISCAL_YEAR = bmi.Fiscal_Year | |
AND fw.FISCAL_WEEK = bmi.Fiscal_Week | |
INNER JOIN @StoresInRelease s | |
on | |
s.Store_Id = bmi.Store_ID |
OlderNewer