Skip to content

Instantly share code, notes, and snippets.

View ScottGuymer's full-sized avatar

Scott Guymer ScottGuymer

View GitHub Profile

Keybase proof

I hereby claim:

  • I am scottguymer on github.
  • I am scottguymer (https://keybase.io/scottguymer) on keybase.
  • I have a public key whose fingerprint is FBE4 0DF3 CBCA A52B A7E5 8A0A 73FF 01E7 676C 624F

To claim this, I am signing this object:

@ScottGuymer
ScottGuymer / ExampleQuery.cs
Last active May 24, 2022 22:01
Selector pattern for testable linq statements
using System.Linq;
public class ExampleQuery : ISelect<in Post, out IEnumerable<Post>>
{
public IEnumerable<Post> Run(IQueryable<Post> objects)
{
return objects.Where(x => x.Published);
}
}
@ScottGuymer
ScottGuymer / DatabaseUtils.cs
Created October 24, 2015 13:12
Database Utils
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
/// <summary>
/// Data Helper methods.
/// </summary>
@ScottGuymer
ScottGuymer / HubExample.cs
Last active October 24, 2015 13:13
SignalR notifications framework example.
using StratComm.Notification.Hubs.Clients;
public class ExampleHub : SubscriptionHub<IHubClient>
{
}
public interface IFileHubClient
{
void Complete();
@ScottGuymer
ScottGuymer / ICommandHandler.cs
Last active October 24, 2015 13:13
Design Patterns and Useful Methods
public interface ICommandHandler<TCommand> where TCommand : ICommand
{
void Handle(TCommand command);
}
public interface ICommand
{
}
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Linq;
@{
Layout = null;
Response.ContentType = "text/xml";
}<?xml version='1.0' encoding='UTF-8' ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
@ListChildNodes(Umbraco.TypedContent(UmbracoContext.Current.PageId).AncestorOrSelf(1))
@ScottGuymer
ScottGuymer / DumpTablesToCsv.sql
Last active October 24, 2015 13:14
Create a list of commands to dump all tables to csv
select 'exec master..xp_cmdshell'
+ ' '''
+ 'bcp'
+ ' "' + TABLE_CATALOG + '.' + TABLE_SCHEMA + '.[' + TABLE_NAME + ']"'
+ ' out'
+ ' "C:\temp\'
+ TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME + '.csv"'
+ ' -c -t,'
+ ' -T'
+ ' -S' + @@servername
@ScottGuymer
ScottGuymer / DateInterceptor.js
Created July 3, 2014 07:23
Angular interceptor to reformat ISO 8601 strings into Javascript date objects
angular.module('dateInterceptor',[])
.config(['$httpProvider', function ($httpProvider) {
var regexIso8601 = /^(\d{4}|\+\d{6})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2}):(\d{2})\.(\d{1,})(Z|([\-+])(\d{2}):(\d{2}))?)?)?)?$/;
// function to parse through response json and replace ISO8601 date strings with date objects
var convertDateStringsToDates = function(input) {
// Ignore things that aren't objects.
if (typeof input !== "object") return input;
@ScottGuymer
ScottGuymer / gist:9910569
Created April 1, 2014 09:04
angular directive to format a number in an input
var common = angular.module('common', []);
/** allows numbers to be displayed from a model value with the correct decimal rounding */
common.directive('inputCurrency', function ($filter, $locale) {
return {
terminal: true,
restrict: 'A',
require: '?ngModel',
link: function (scope, element, attrs, ngModel) {
@ScottGuymer
ScottGuymer / index.html
Created March 26, 2014 15:31
Angular $http interceptor to allow for a loading spinner whenever any ajax request is made. Could be extended to provide request logging and error handling.
<div id="loadingWidget" loading-widget>
<div class="loadingContent">
<p>
Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....Loading....
</p>
</div>
</div>