Skip to content

Instantly share code, notes, and snippets.

View afreeland's full-sized avatar

Aaron Freeland afreeland

View GitHub Profile
@afreeland
afreeland / gist:5263084
Created March 28, 2013 13:22
SQL: Alter Table Schema
-- Put ContactParameter table into Account Schema
alter schema Account transfer ContactParameter
@afreeland
afreeland / gist:5263184
Created March 28, 2013 13:39
SQL: Create New Schema
-- Create a new schema called API
CREATE SCHEMA API
@afreeland
afreeland / gist:5301824
Last active December 15, 2015 18:09
IIS: Rename IIS Application path
// List IIS Applications
%systemroot%\system32\inetsrv\appcmd list app
// Rename IIS Application Virtual Path
%systemroot%\system32\inetsrv\appcmd set app "Default Web Site/OldApplicationName" -path:/NewApplicationName
@afreeland
afreeland / gist:5303782
Created April 3, 2013 18:22
C#: Web Request Class for REST
public class HTTP
{
public enum Method
{
GET = 3,
POST = 0,
PUT = 1,
DELETE = 2
}
@afreeland
afreeland / gist:fb12c8b8de33eee2b2bc
Created December 16, 2015 17:56
Node Inspector Flags for Success =)
node-debug --no-preload -d 5888 -b false app.js
@afreeland
afreeland / gist:5958892
Created July 9, 2013 16:32
C#: Lambda Update or Create object in collection
// Extension method to interrogate a collection for a particular property and value
// If it does not exist create a new object
// return object found or created
public static T GetOrAdd<T>(this IList<T> list, Func<T, bool> predicate, Func<T> constructor)
{
var match = list.FirstOrDefault(predicate);
if (match == null)
{
match = constructor();
list.Add(match);
@afreeland
afreeland / gist:6071150
Last active December 20, 2015 04:29
C#: Bitshift Permission
public class Permission
{
public class Access
{
public Permission.View.Customer Customer { get; set; }
public Permission.View.Inventory Inventory { get; set; }
public Permission.View.Order Order { get; set; }
}
@afreeland
afreeland / gist:6072282
Last active December 20, 2015 04:39
SQL: Pipe SELECT statement into an INSERT
insert into register
(
fName,lName,sex,bDay,grade,activity,fee,cityRes,tFee,rel,rel_fName,rel_lName,rel_add1,rel_ad2,rel_city,rel_state,rel_zip,rel_phone,rel_altPhone,rel_email
)
select
'Chris' as fName, /* Hardcodes Chris as First Name for new records created */
'Brown' as lName, /* Hardcodes Brown as Last Name for new records created */
@afreeland
afreeland / gist:6073754
Created July 24, 2013 19:35
SQL: Iterate through SQL results and execute Stored Procedure
DECLARE @aid char(11)
SELECT @aid = min(AccountID) from [Security].[Role]
WHILE @aid is not null
BEGIN
exec dbo.FillRoleControlsByAccount @aid
print 'AccountID: ' + @aid + ' has been inflated!'
select @aid = min(AccountID) from [Security].[Role] where AccountID > @aid
END
@afreeland
afreeland / gist:6133327
Last active December 20, 2015 12:39
C#: Extension to Flatten Tree iterating through List of Tree's
public static IEnumerable<T> Flatten<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> childrenSelector)
{
foreach (var item in source)
{
yield return item;
foreach (var child in childrenSelector(item).Flatten(childrenSelector))
{
yield return child;
}
}