Skip to content

Instantly share code, notes, and snippets.

@bungard
bungard / SqlEscape.cs
Last active September 16, 2015 00:45
private static void SQLServerEscapeObject(object obj)
{
foreach (System.Reflection.PropertyInfo property in obj.GetType().GetProperties())
{
try
{
if (property.PropertyType.FullName == "System.String" && property.GetValue(obj, null) != null)
{
property.SetValue(obj, property.GetValue(obj, null).ToString().Replace("'", "''"), null);
}
@bungard
bungard / SplitWordDoc.ps1
Last active February 1, 2022 10:27
Powershell script to split a word document into separate pages. Assumes each page should be its own document and the name for each document can be extracted from each page.
#Author: Matt Bungard / bungard at g-mail d com
#
#Pull bits from various sources, if you've been exluded let me know and I'll cite accordingly
#http://stackoverflow.com/questions/26737239/powershell-add-a-new-document-to-exisitng-word-file-with-page-number-of-2
## -- Settings --
#$fileNamePattern = "ID #:\s+(\d+)"
$fileNamePattern = "Student ID #:\s+# (\d+)"
$pageLength = 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Comparer
{
public class SemiNumericComparer : IComparer<string>
{
public int Compare(string s1, string s2)