Skip to content

Instantly share code, notes, and snippets.

View Dillie-O's full-sized avatar

Sean Patterson Dillie-O

View GitHub Profile
@Dillie-O
Dillie-O / gist:5679216
Created May 30, 2013 16:26
Refactored SearchParameter object
public class SearchParameter
{
public string VariableName { get; set; }
public string WhereClause { get; set; }
public bool IsWildcardSearch { get; set; }
public bool IsRangeSearch { get; set; }
public bool AllowsMultipleValues { get; set; }
public Type ParameterType { get; set; }
}
@Dillie-O
Dillie-O / gist:5679296
Last active December 17, 2015 22:08
Refactored SearchParameter dictionary declaration
// All site search criteria in a dictionary for easy lookup/manipulation
// when dynamically building the query.
public static Dictionary<string, SearchParameter> GetSearchCriteria()
{
var results = new Dictionary<string, SearchParameter>
{
{
"SiteID", new SearchParameter
{
VariableName = "site_uid",
@Dillie-O
Dillie-O / gist:5679454
Last active December 17, 2015 22:09
Refactored BuildObjectQuery method
public static ObjectQuery<T> BuildObjectQuery<T>
(ObjectQuery<T> query, NameValueCollection parameters,
Dictionary<string, SearchParameter> searchCriteria)
{
var results = query;
// If there are parameters in our collection, build a where clause
// using the search criteria dictionary. Otherwise the method ends
// and the query remains the same.
if (parameters.Count > 0)
@Dillie-O
Dillie-O / gist:5700625
Created June 3, 2013 19:25
Refactored Advanced Duplicate Row Query in SQL
SELECT COUNT(application_id) as duplicate_count,
application_id,
lock_version,
asset_id,
customer_id,
received_date,
fee_amount,
created_at,
updated_at
@Dillie-O
Dillie-O / gist:5700776
Last active December 18, 2015 00:59
Refactored Advanced Remove Duplicate Row Script in SQL
-- Algorithm --
-- 1. Run query to get all duplicate count values. Since we're getting cloned
-- rows, we can run the query based off of all fields in the table. Store
-- in table variable.
--
-- 2. Iterate through table.
--
-- 2a. Use DELETE TOP(x - 1) remove all duplicates.
--
-- 3. Done
@Dillie-O
Dillie-O / gist:5700786
Created June 3, 2013 19:45
Advanced Remove Duplicate Row Delete Snippet
DELETE application_versions FROM
(
SELECT TOP (@duplicate_count - 1) id
FROM application_versions
WHERE (@application_id IS NULL OR application_id = @application_id)
AND (@lock_version IS NULL OR lock_version = @lock_version)
AND (@asset_id IS NULL OR asset_id = @asset_id)
AND (@customer_id IS NULL OR customer_id = @customer_id)
@Dillie-O
Dillie-O / gist:5709773
Created June 4, 2013 21:29
Set focus to username and map enter key to login on ASP.Net WebForm Login Control
AppLogin.Focus();
this.Form.DefaultButton = "ctl00$BodyPlaceHolder$AppLogin$LoginButton";
@Dillie-O
Dillie-O / gist:6106435
Last active December 20, 2015 09:18
Find all file names with spaces in a directory, call SVN rename to replace with _ Note: Text provided is multiline, you can delete the new line characters to run at the command prompt.
Get-ChildItem | Where-Object {-Not $_.PsIscontainer -AND $_.name -match "\s"} |
foreach {
$fixedname = $_.name.Replace(' ','_');
iex "svn rename '$_' $fixedname"
}
@Dillie-O
Dillie-O / gist:6140774
Last active November 6, 2016 20:14
Mount ReadyShare network drives and TimeMachine sparsebundle script
try
mount volume "smb://readyshare/MacBackup"
end try
do shell script "hdiutil attach -mountpoint /Volumes/MacBackup/ /Volumes/MacBackup/TimeMachine.sparsebundle"
@Dillie-O
Dillie-O / isgovtdown.py
Last active December 24, 2015 10:49 — forked from eduardkoller/isgovtdown.py
Revised to work with Python 2.7
#!/usr/bin/env python
#
# file: isgovtdown.py
#
# description: checks usa.gov for the "Government has shut down" message
# Forked from https://gist.github.com/eduardkoller/6784503
# and modified to work with Python 2.7
#
# usage: ./isgovtdown.py
#