Skip to content

Instantly share code, notes, and snippets.

@OdeToCode
OdeToCode / Program.cs
Created September 16, 2016 19:04
Some quick code to show assembly name, version, and load path in Program.cs of AspNet Core
var assemblies = Assembly.GetEntryAssembly().GetReferencedAssemblies();
foreach (var assembly in assemblies)
{
Console.WriteLine($"{assembly.Version} {assembly.Name}");
var codebase = Assembly.Load(assembly).CodeBase.Replace("file:///", "");
Console.WriteLine($"\t{Path.GetDirectoryName(codebase)}");
}
@OdeToCode
OdeToCode / gist:7538117
Created November 19, 2013 00:40
Restrict OWIN CORS to Token endpoint.
app.UseCors(new CorsOptions()
{
PolicyProvider = new CorsPolicyProvider()
{
PolicyResolver = request =>
{
if (request.Path.StartsWithSegments(new PathString("/token")))
{
return Task.FromResult(new CorsPolicy { AllowAnyOrigin = true });
}
let PeriodValue payment rate period =
payment / ((1.0 + rate) ** period)
let PresentValue (factors: AnnuityFactors) =
[1 .. factors.Periods]
|> List.map (fun period -> PeriodValue factors.Payment factors.InterestRate (float period))
|> List.sum
@OdeToCode
OdeToCode / gist:5024867
Last active December 14, 2015 03:59
AngularJS Snippet
<div ng-app="videoApp" ng-controller="VideoController">
<table>
<thead>
<th>Title</th>
<th>Length</th>
<th></th>
</thead>
<tbody>
<tr data-id="{{video.Id}}" ng-repeat="video in videos">
public class FlexRoleUserStore<TContext, TRole, TUser> : IFlexRoleDataStore
where TRole : class, IFlexRole<TUser>, new()
where TUser : IFlexMembershipUser
where TContext : DbContext
{
// ...
}
public class OwershipVerification : IActionFilter
{
public void OnActionExecuting(ActionExecutingContext filterContext)
{
foreach(var paramter in filterContext.ActionParameters)
{
var haveAnOwner = paramter.Value as IHaveAnOwner;
if(haveAnOwner != null)
{
var ownedParameter = haveAnOwner;
using System;
using System.Linq;
using System.Data.Entity;
namespace TestEF
{
public class Thing
{
public int Id {
get;
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
"Microsoft.Framework.Logging.Console": "1.0.0-beta7",
"Microsoft.AspNet.Authorization": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta7"
},
using static System.Console;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
WriteLine("This works...");
}
public class Foo
{
public Foo(int value)
{
_value = value;
}
int _value;
}