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 / install_ffmpeg_with_librtmp.sh
Last active July 29, 2021 15:58
shell script to install FFmpeg with librtmp, which is necessary to use it with DaCast. Much of this comes from http://help.dacast.com/hc/en-us/articles/202357380-Stream-on-DaCast-under-Linux-with-ffmpeg
#!/bin/bash
# this scripts assumes Ubuntu 14.04 LTS
# ensure the following sources are in /etc/apt/sources.list
# deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ precise multiverse
# deb http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse
@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'