Skip to content

Instantly share code, notes, and snippets.

View Antaris's full-sized avatar
🎯
Focusing

Matthew Abbott Antaris

🎯
Focusing
View GitHub Profile
@Antaris
Antaris / DotNetCoreVersionExtensions.cs
Created August 12, 2016 07:53
An approach to building .NET Core applications with Cake, XUnit and synchronous `project.json` versionining for both local and on Bamboo
namespace Cake.DotNetVersion
{
using System;
using System.Collections.Generic;
using Cake.Core;
using Cake.Core.Annotations;
using Cake.Core.IO;
/// <summary>
/// Contains functionality required to updating project file versions.
@Antaris
Antaris / Program.cs
Created January 5, 2016 14:13
ASP.NET 5 Dependency Injection / Service Resolving in a Console App package
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
namespace ConsoleApp1
{
public class Program
{
public abstract class StartupBase
{
public virtual void ConfigureService(IServiceCollection services)
{
// Standard registrations
ConfigureEntityFramework(services);
}
public abstract void ConfigureEntityFramework(IServiceCollection services);
public class ConnectionStringProvider
{
private readonly IApplicationEnvironment _appEnv;
private readonly IConfiguration _config;
public ConnectionStringProvider(IApplicationEnvironment appEnv, IConfiguration config)
{
_appEnv = appEnv;
_config = config;
}
namespace CompileModuleExample
{
public class Greeter
{
public string GetMessage()
{
}
}
}
@Antaris
Antaris / Disposable.js
Last active February 6, 2021 19:47
A C#-like dispose pattern implemented in javascript - with underscorejs and qunit. Testable: http://jsfiddle.net/52CnZ/14/
!function(root, _, undefined) {
var Disposable = root.Disposable = function() {
this.disposed = false;
};
Disposable.prototype = {
_dispose: function() {
if (!this.disposed) {
this.dispose();
this.disposed = true;
@Antaris
Antaris / gist:5663603
Created May 28, 2013 15:29
Older Android devices seem to struggle with Cassette's release urls (/cassette.axd/styleseet/*, etc) because of the presence of an underscore. The following re-write rules will rewrite the outbound html to change the urls to something Android 2.* devices will like, and an inbound rewrite to match incoming requests to the CassetteHttpHandler. Thi…
<rewrite>
<outboundRules>
<rule name="CassetteOutboundUrl" preCondition="HtmlContent" stopProcessing="false">
<match filterByTags="Link, Script" pattern="^/cassette.axd/(.*?)/(.*)" />
<action type="Rewrite" value="/cassette.axd/?type={R:1}&amp;data={R:2}" />
</rule>
<preConditions>
<remove name="HtmlContent" />
<preCondition name="HtmlContent">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
@Antaris
Antaris / DependencyList.cs
Created February 6, 2012 14:17
Sorting dependencies using DependencyList
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
/// <summary>
/// Represents a list whose items can be dependant on each other, and enumerating the list will sort the items
/// as per their dependency requirements.
/// </summary>
@Antaris
Antaris / BarConfigurationElement.cs
Created January 23, 2012 16:51
Heterogeneous Configuration Collections
public class BarConfigurationElement : NamedConfigurationElementBase
{
private const string BarValueAttribute = "barValue";
[ConfigurationProperty(BarValueAttribute, IsRequired = true)]
public string BarValue
{
get { return (string)this[BarValueAttribute]; }
}
}
@Antaris
Antaris / HomeController.cs
Created October 22, 2011 09:50
An updated model binder that supports async and non-async file uploads.
namespace AsyncUpload.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}