This file contains 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
-- Naming: | |
-- #TableName : local temp table | |
-- ##TableName: global temp table | |
-- @TableName: table variable | |
-- TableName: permanent table | |
CREATE TABLE #Employees | |
( | |
Name varchar(30), | |
Age INT |
This file contains 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
-- taken from: http://www.databasejournal.com/features/mssql/article.php/10894_3502676_2/Common-Table-Expressions-CTE-on-SQL-2005.htm | |
-- recursive CTEs are divided in two parts 1. above "UNION ALL", and 2. below that | |
-- the statements on part 1 should be run without recursion to the CTE itself, this is our so-called recursion exit condition (anchor member) | |
-- the statements on part 2 use the CTE name in their select clause, this is the main recursion (recursive member) | |
-- the script below lists employees as well as their direct managers. | |
USE AdventureWorks ; | |
GO | |
WITH DirectReports(LoginID, ManagerID, EmployeeID) AS |
This file contains 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
// searches an arbitrary string | |
public static void FindStringAndSetColor(RichTextBox rtb, string key, Color color) | |
{ | |
int lastIndex = -1; | |
do | |
{ | |
int found = rtb.Find(key, lastIndex + 1, RichTextBoxFinds.None); | |
if (found >= 0) | |
{ | |
rtb.Select(found, key.Length); |
This file contains 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> | |
/// Returns a visible version of the string, by making | |
/// its whitespace and control characters visible | |
/// using well known escape sequences, or the equivalant | |
/// hexa decimal value. | |
/// </summary> | |
/// <param name="str">The string to be made visible.</param> | |
/// <returns></returns> | |
public static string MakeStringVisible(string str) | |
{ |
This file contains 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> | |
/// Provides tools to detect the kind of the overlap between two intervals | |
/// </summary> | |
public static class IntervalOverlap | |
{ | |
/// <summary> | |
/// Detects kind of the overlap that the specified two ranges have. | |
/// </summary> | |
/// <param name="start1">The inclusive start of the first interval.</param> | |
/// <param name="end1">The exclusive end of the first interval.</param> |
This file contains 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 string TrimFullString(string str) | |
{ | |
int start = 0; | |
int end = str.Length - 1; | |
for (; start <= end; start++) | |
{ | |
if (!Char.IsWhiteSpace(str[start]) && | |
!Char.IsControl(str[start])) | |
break; |
This file contains 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
// taken from: http://msdn.microsoft.com/en-us/library/ms996467.aspx | |
using System.Collections; | |
using System.Windows.Forms; | |
namespace ListViewControlling | |
{ | |
/// <summary> | |
/// This class is an implementation of the 'IComparer' interface. | |
/// </summary> |
This file contains 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
private static readonly Random s_rnd = new Random(); | |
/// <summary> | |
/// Divides numbers from 0 to length - 1 into k random folds. | |
/// This method is a helper method for K-fold cross validaiton. | |
/// </summary> | |
/// <param name="length">The length of the data to fold into k divisions. </param> | |
/// <param name="k">number of divisions</param> | |
/// <returns>K arrays of indices. Each of the arrays contain 0-based indices of the | |
/// data to be put in each division.</returns> |
This file contains 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> | |
/// Calculates the mean of an array of values | |
/// </summary> | |
/// <param name="v">the array of values to calculate their mean</param> | |
/// <returns>The mean of the array of values</returns> | |
public static double Mean(double[] v) | |
{ | |
double sum = 0.0; | |
for (int i = 0; i < v.Length; i++) |
This file contains 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 TestHelpers | |
{ | |
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue) | |
{ | |
ShouldEqualWithDiff(actualValue, expectedValue, DiffStyle.Full, Console.Out); | |
} | |
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue, DiffStyle diffStyle) | |
{ | |
ShouldEqualWithDiff(actualValue, expectedValue, diffStyle, Console.Out); |