Skip to content

Instantly share code, notes, and snippets.

View ctolkien's full-sized avatar
👋

Chad Tolkien ctolkien

👋
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication2
{
class Program {
static void Main(string[] args) {
var foo = new List<ISupport>();
from prop in docs.Properties
select new {
PropertyName = prop.Name
}
@ctolkien
ctolkien / gist:3910217
Created October 18, 2012 06:49
jquery unobtrusive validation
/*!
** Unobtrusive validation support library for jQuery and jQuery Validate
** Copyright (C) Microsoft Corporation. All rights reserved.
*/
/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */
/*global document: false, jQuery: false */
(function ($) {
var $jQval = $.validator,
@ctolkien
ctolkien / downloadBuild2012.ps1
Created November 3, 2012 00:27
Download all the Build 2012 videos...
(irm http://channel9.msdn.com/Events/Build/2012/RSS/wmvhigh) | where { $_.title -NotLike "*(Repeat)*"} | foreach {
$path = "E:\Build2012\" + ($_.title -replace ":", "") + ".wmv"
if (Test-Path ($path)) {
Write-Output "Skipping" + $_.title
}
else {
Write-Output "Downloading" + $_.title
(New-Object System.Net.WebClient).DownloadFile($_.enclosure.url, $path)
}
}
@ctolkien
ctolkien / FakeDBSet.cs
Created November 4, 2012 04:01
IDbSet<T> implementation
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace XXX
@ctolkien
ctolkien / gist:4186791
Created December 2, 2012 03:16
RX Event Aggregator
public class EventPublisher : IEventPublisher
{
private readonly ConcurrentDictionary<Type, object> subjects
= new ConcurrentDictionary<Type, object>();
public IObservable<TEvent> GetEvent<TEvent>()
{
var subject =
(ISubject<TEvent>) subjects.GetOrAdd(typeof (TEvent),
t => new Subject<TEvent>());
@ctolkien
ctolkien / gist:4211120
Created December 5, 2012 01:25
Profile
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
Import-Model posh-sprintly
Set-SprintlyCredentials "asd@asd" "sdsdsdsdsd" -silent
# If module is installed in a default location ($env:PSModulePath),
# use this instead (see about_Modules for more information):
Import-Module posh-git
Import-Module posh-hg
Overall thoughts - the size of the sites we're working on are not huge, and not complex. A lot of the more complex patterns do not apply.
RE: Multiple projects. I've now come to the descision that splitting out sites into "Core, Web, Data" etc. type projects is something that has persisted from the ASP.Net 1.0 days and isn't needed anymore. Our sites almost never need re-usable components. We never (for instance) have needed to use the data component of a site in a different project. IF we did, we'd know about it up front and could design for it appropriately. Thus, multiple projects is not required. This was one of the points made in the ASP.Net MVC 4 Pro book.
RE: Repository Pattern
Repository offers a few distinct benefits.
a.) does not tie your application to a certain type of persistance.
#CapsLock::Send,{MEDIA_PLAY_PAUSE}
#ScrollLock::Volume_Down
#Break::Volume_Up
#F6::Media_Play_Pause
#F7::Media_Prev
#F8::Media_Next
AppsKey::Ctrl
Insert::
public override int SaveChanges()
{
//this goes through and updates the created on / modified on dates.
this.ChangeTracker.Entries<BaseModel>().ForEach(x =>
{
if (x.State == System.Data.EntityState.Added)
{
x.Entity.CreatedOn = DateTime.UtcNow;
}