Skip to content

Instantly share code, notes, and snippets.

public static class ObservableCollectionExt {
public static void Populate<T>(this ObservableCollection<T> collection, IEnumerable<T> itemsToAdd) {
collection.Clear();
foreach (T item in itemsToAdd)
{
collection.Add(item);
}
}
}
using System;
using System.Globalization;
using System.Windows.Data;
/// <summary>
/// Converts a boolean value to a string value. For example, if the paramter passed in is "Elephant,Giraffe"
/// then a boolean true would convert to "Elephant" and false to "Giraffe"
/// </summary>
public class BooleanToStringCustomValueConverter : IValueConverter
{
@aroder
aroder / CacheProvider.js
Created March 15, 2011 18:58
An implementation of Dustin Diaz's CacheProvider with a simplified interface
/**
* {Boolean} useLocalStorageIfAvailable - optional, defaults to true. The CacheProvider object will
* use the HTML5 localStorage object, if available
*/
function CacheProvider(useLocalStorageIfAvailable) {
// values will be stored here
this._cache = {};
this._useLocalStorage = 'undefined' == typeof(useLocalStorageIfAvailable) ? true : useLocalStorageIfAvailable;
}
@aroder
aroder / eclgautologin.js
Created March 18, 2011 20:19
auto login to the test page
!(function(d) {
d.getElementsByName('clientstring')[0].value = 'parku';
d.getElementsByName('courseid')[0].value = '2022037';
d.getElementsByName('pagetoload')[0].selectedIndex = 1;
d.forms[0].submit();
})(document);
/* paste into a bookmarklet javascript: <the code> */
@aroder
aroder / fnDbVars.sql
Last active August 9, 2016 14:07
fnDbVars - get database variables from Markit EDM database
/**
summary:
fnDbVars returns database variable names and values from a Markit EDM database
parameters:
- name : variableName
type: nvarchar(MAX)
description: the name of the database variable you want returned
ifNull: the function will return all database variables
author: Adam Roderick
examples:
@aroder
aroder / Reset Matcher.sql
Created September 27, 2016 21:32
Reset the Markit EDM Matcher. Originally from https://supportlibrary.markit.com/display/EDM/Data+Matcher+Scripts, but that script throws an error if executed more than once on the same matcher
drop table cadis_proc.dm_mp7_result_temp
drop table cadis_proc.dm_mp7_result_audit_temp
drop table cadis_proc.dm_mp7_proposed_temp
exec SPDM_CLEARRESULTS @ProcessName = 'TESTER2', @SourceName = 'All', @ResetIds = 1, @PrintOnly = 0
@aroder
aroder / GetInfoOnPrimaryKey.sql
Created November 18, 2016 16:42
SQL - Query to get detailed info on primary keys
SELECT
PK.CONSTRAINT_NAME,
COLS.TABLE_SCHEMA,
COLS.TABLE_NAME,
COLS.COLUMN_NAME,
COLS.DATA_TYPE,
COLS.COLUMN_DEFAULT,
COLS.CHARACTER_MAXIMUM_LENGTH,
COLS.NUMERIC_PRECISION,
COLS.IS_NULLABLE,
@aroder
aroder / spDmRealign
Created January 4, 2017 21:09
Stored Procedure for Markit EDM Realign
if exists (select 1 from INFORMATION_SCHEMA.ROUTINES where ROUTINE_SCHEMA = 'dbo' and ROUTINE_NAME = 'spDmRealign')
drop procedure dbo.spDmRealign
go
create procedure dbo.spDmRealign
@oldCadisId int,
@newCadisId int, /* Set @newCadisId = 0 below to get a *new* CadisID generated and assigned, or alternatively set to an existing target CadisID */
@matcherName nvarchar(100),
@sourceName nvarchar(100)
as begin
@aroder
aroder / Data Porters set to auto truncate columns.sql
Created January 10, 2017 21:54
Best practice for Markit EDM Data Porters is to turn off auto truncate. But the default settings turn it on. This query finds Data Porters with the setting turned on
SELECT DP.NAME,
m.c.value('ProcType[1]', 'varchar(max)') AS ProcType,
m.c.value('AutoTruncate[1]', 'varchar(max)') AS AutoTruncate,
m.c.value('Name[1]', 'varchar(max)') AS [Input Name]
FROM [CADIS_SYS].[DP_DATAPORT] DP
CROSS APPLY DP.[DEFINITION].nodes('CadisXml/Content/Inputs/list/Item') AS m(c)
WHERE m.c.value('AutoTruncate[1]', 'varchar(max)') = 'True'
@aroder
aroder / FindReferences.sql
Created February 15, 2017 18:20
Find references to a column *anywhere* in SQL Server. Uses text search rather than hard dependencies. Originally from http://stackoverflow.com/questions/1883700/in-sql-server-how-can-i-find-everywhere-a-column-is-referenced, answer by Anar Khalilov
SELECT sys.objects.object_id,
sys.schemas.NAME AS [Schema],
sys.objects.NAME AS Object_Name,
sys.objects.type_desc AS [Type]
FROM sys.sql_modules(NOLOCK)
INNER JOIN sys.objects(NOLOCK) ON sys.sql_modules.object_id = sys.objects.object_id
INNER JOIN sys.schemas(NOLOCK) ON sys.objects.schema_id = sys.schemas.schema_id
WHERE sys.sql_modules.DEFINITION COLLATE SQL_Latin1_General_CP1_CI_AS LIKE '%.PartyTitleTxt%' ESCAPE '\'
ORDER BY sys.objects.type_desc,
sys.schemas.NAME,