Skip to content

Instantly share code, notes, and snippets.

View danielmackay's full-sized avatar

Daniel Mackay [SSW] danielmackay

View GitHub Profile
@danielmackay
danielmackay / Clean Visual Studio.ps
Created March 10, 2015 23:22
Clean visual studio build artifacts with power shell.
Get-ChildItem .\ -include bin,obj,bld,Backup,_UpgradeReport_Files,Debug,Release,ipch -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
@danielmackay
danielmackay / Date Time Helpers.cs
Created March 4, 2015 06:56
Date Time helper methods for getting the start/end date of the week/month/year. #datetime
[TestClass()]
public class DateTimeExtTests
{
private const int CurrentYear = 2015;
private const int CurrentMonth = 3;
private const int CurrentDay = 4;
private DateTime CurrentDate
{
get { return new DateTime(CurrentYear, CurrentMonth, CurrentDay); }
@danielmackay
danielmackay / Delete Join.sql
Created March 3, 2015 05:59
Delete join #sql
delete a
from tbla a
inner join tblb b
on b.id = a.ID
where b.Name = 'Test'
@danielmackay
danielmackay / JSON Data File Reader.cs
Created March 3, 2015 01:44
JSON Data File Reader
public class JsonDataReader
{
private readonly string baseDir;
public JsonDataReader(string directory)
{
var dir = Assembly.GetExecutingAssembly().GetDirectory();
baseDir = Path.Combine(dir, directory);
}
public static class AssemblyExt
{
public static string GetAssemblyDirectory(this Assembly assembly)
{
var uri = new Uri(assembly.CodeBase);
return uri.LocalPath;
}
}
@danielmackay
danielmackay / Data Module.cs
Last active August 29, 2015 14:16
MVC Autofac
public class DataModule : Autofac.Module
{
protected override void Load(ContainerBuilder builder)
{
var asm = Assembly.GetExecutingAssembly();
builder.RegisterAssemblyTypes(asm)
.Where(t => t.Name.EndsWith("Repository"))
.AsImplementedInterfaces()
.InstancePerRequest();
@danielmackay
danielmackay / EF Include Multiple
Created December 5, 2014 01:14
Type safe extension method that allows you to pass a list of expressions to determine navigation properties for EF to load. #ef
internal static class QueryableExt
{
public static IQueryable<T> IncludeMultiple<T>(this IQueryable<T> query, params Expression<Func<T, object>>[] includes) where T : class
{
if (includes == null)
return query;
foreach (var include in includes)
{
query = query.Include(include);
@danielmackay
danielmackay / DB Context Factory
Created December 5, 2014 00:52
Standard DB Context factory. #ef
public static osram_devEntities Create()
{
var db = new osram_devEntities();
// By turning off lazy loading entities must be explicitly loaded by using Include(). This means we don't accidently make
// calls to the DB that we're not aware of
db.Configuration.LazyLoadingEnabled = false;
#if DEBUG
db.Database.Log = (s) => Debug.WriteLine(s);
<a href="link.html" class="disabled">Link</a>
a.disabled {
pointer-events: none;
cursor: default;
}
@danielmackay
danielmackay / HTML Tag Extensions
Last active August 29, 2015 14:06
Html Tag Extensions. #htmltag
We couldn’t find that file to show.