Skip to content

Instantly share code, notes, and snippets.

View ctolkien's full-sized avatar
👋

Chad Tolkien ctolkien

👋
View GitHub Profile
Program: Starting Squirrel Updater: --install .
Program: Starting install, writing to C:\Users\Chad\AppData\Local\SquirrelTemp
CheckForUpdateImpl: Failed to load local releases, starting from scratch: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Chad\AppData\Local\atom\packages\RELEASES'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Squirrel.Utility.LoadLocalReleases(String localReleaseFile)
at Squirrel.UpdateManager.CheckForUpdateImpl.<CheckForUpdate>d__28.MoveNext()
CheckForUpdateImpl: Reading RELEASES file from C:\Users\Chad\AppData\Local\SquirrelTemp
CheckForUpdateImp
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
# Basic setup
Update-ExecutionPolicy Unrestricted
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-RemoteDesktop
Disable-InternetExplorerESC
var gulp = require('gulp');
var bower = require('gulp-bower');
var less = require('gulp-less');
var sourcemaps = require('gulp-sourcemaps');
var aspnetk = require("gulp-aspnet-k");
gulp.task('bower', function() {
return bower()
.pipe(gulp.dest('wwwroot/lib/'))
});
@ctolkien
ctolkien / HumanizerMetadataProvider
Created December 16, 2014 07:15
HumanizerMetadataProvider
public class HumanizerMetadataProvider : DataAnnotationsModelMetadataProvider
{
protected override ModelMetadata CreateMetadata(
IEnumerable<Attribute> attributes,
Type containerType,
Func<object> modelAccessor,
Type modelType,
string propertyName)
{
var propertyAttributes = attributes.ToList();
@ctolkien
ctolkien / CSV2IISRedirects
Created September 18, 2014 08:15
Converts a CSV File to something compatible with IIS redirects config (and copies to clipboard)
$csv = Import-Csv .\redirects.csv -Header "Orig", "Dest"
$csv | % {
"<add key=""$($_.Orig)"" value=""$($_.Dest)"" />"
} | clip
@ctolkien
ctolkien / owincookieoptions.cs
Created May 8, 2014 06:30
owin cookie options w/o redirecting ajax requests...
var cookieOptions = new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider()
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, UserEntity>(
validateInterval: TimeSpan.FromMinutes(20),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)),
OnApplyRedirect = ctx =>
@ctolkien
ctolkien / port80test
Created March 13, 2014 03:37
Tests if machines respond on port 80
$machines = get-content "machinescsv.txt" #assumes machine names are each on a new line
$fileToLogTo = "logOfIIS.txt" #this is where we'll log machines that respond
set-content $fileToLogTo $null #reset the contents of the file to nothing
$machines | ForEach-Object { #for each machine that we have
$socket = (new-object Net.Sockets.TcpClient) #reach into .net and make a TcpClient
@ctolkien
ctolkien / gist:8487470
Created January 18, 2014 07:39
Simple Injector - sample MVC and WebAPI Wireup.
public class DependencyConfig
{
public static void RegisterDependencies(HttpConfiguration httpConfiguration)
{
var container = new SimpleInjector.Container();
System.Web.Mvc.DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
@ctolkien
ctolkien / gist:8344264
Last active January 2, 2016 18:29
Blocking on async tasks in asp.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace XXX
{
public class AsyncHelper
{
@ctolkien
ctolkien / FakeHttpContext
Created October 25, 2013 06:41
var foo = new SomeController(); foo.SetFakeControllerContext();
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Security.Principal;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Moq;