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
using System.Runtime.InteropServices; | |
using System.Diagnostics; | |
static public class FileUtil | |
{ | |
[StructLayout(LayoutKind.Sequential)] | |
struct RM_UNIQUE_PROCESS | |
{ | |
public int dwProcessId; | |
public System.Runtime.InteropServices.ComTypes.FILETIME ProcessStartTime; |
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
<script src="//ajax.aspnetcdn.com/ajax/jquery/jquery-2.0.0.min.js"></script> | |
<script>window.jQuery || document.write('<script src="js/jquery-2.0.0.min.js">\x3C/script>')</script> |
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
angular.element('#orders').scope().$emit('getorderreport') |
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 void SmartAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value) | |
{ | |
try | |
{ | |
dictionary.Add(key, value); | |
} | |
catch (ArgumentException e) | |
{ | |
throw new ArgumentException("The key '{0}' already exists.".ToFormat(key), e); | |
} |
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
CREATE TABLE #Test (CompanyID INT, CompanyName VARCHAR(20), LinkedCompanyID INT) | |
INSERT INTO #Test | |
SELECT 1, 'Company A', NULL UNION | |
SELECT 2, 'Company B', 1 UNION | |
SELECT 3, 'Company C', 2 UNION | |
SELECT 4, 'Company D', 2 UNION | |
SELECT 5, 'Company E', 4 UNION | |
SELECT 6, 'Company F', 3 UNION | |
SELECT 7, 'Company G', NULL |
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
-- SQL 2008 | |
DECLARE @CurrentDate DATETIME = (cast(GETDATE() as date)) | |
-- Pre SQL 2008 | |
DECLARE @CurrentDate DATETIME = DateAdd(Day, Datediff(Day, 0, GetDate()), 0) |
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
using (Microsoft.VisualBasic.FileIO.TextFieldParser parser = new Microsoft.VisualBasic.FileIO.TextFieldParser("C:\\testfile.txt")) { | |
parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; | |
parser.SetDelimiters(","); | |
string[] currentRow = null; | |
while (!parser.EndOfData) { | |
try { | |
currentRow = parser.ReadFields(); | |
string currentField = null; | |
foreach (string field in currentRow) { | |
currentField = field; |
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
/****** Object: UserDefinedTableType [dbo].[IndexedDictionary] ******/ | |
IF EXISTS (SELECT * FROM sys.types st JOIN sys.schemas ss ON st.schema_id = ss.schema_id WHERE st.name = N'IndexedDictionary' AND ss.name = N'dbo') | |
DROP TYPE [dbo].[IndexedDictionary] | |
GO | |
/****** Object: UserDefinedTableType [dbo].[IndexedDictionary] ******/ | |
CREATE TYPE [dbo].[IndexedDictionary] AS TABLE( | |
[Index] [int] NULL, | |
[Key] [nvarchar](255) NULL, | |
[Value] [nvarchar](255) NULL |
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
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' | |
GO | |
EXEC sp_MSForEachTable 'TRUNCATE TABLE ?' | |
GO | |
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL' | |
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
namespace Web.Extensions.Control | |
{ | |
using System.Collections.Generic; | |
using System.Web.Mvc; | |
// Usage: foos.Select(x => new SelectListItemWithAttributes | |
// { | |
// Attributes = new Dictionary<string, object>() { { "foootherid", x.SomeOtherId } }, | |
// Text = x.Name, |