Skip to content

Instantly share code, notes, and snippets.

public class Employee
{
public int Id { get; set; }
// ...
}
public class EmployeeComparer : IEqualityComparer<Employee>
{
public bool Equals(Employee x, Employee y)
{
@OdeToCode
OdeToCode / ShowEditWidgets.cshtml
Created May 24, 2018 15:44
ASP.NET Core Binding Collections
@using WebApp1.Controllers
@model IList<Widget>
@{
ViewData["Title"] = "ShowEditWidgets";
Layout = null;
}
<h2>Dump of Widgets</h2>
<table>
@OdeToCode
OdeToCode / index.cshtml
Created May 22, 2018 16:19
Showing videos
@{
ViewBag.Title = "Home Page";
}
Route: @Url.RouteUrl("DefaultApi", new { httproute= "", controller = "Videos" })
<div id="videoTableOutput">
public void Configure(IApplicationBuilder app)
{
app.Run(SayHello);
}
public Task SayHello(HttpContext ctx)
{
return ctx.Response.WriteAsync("Hi World!!!");
}
{
"name": "psrsjx5",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "webpack-dev-server --watch --inline",
"postinstall": "typings install"
},
"dependencies": {
"rxjs": "5.0.0-beta.12"
<environment names="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment names="Staging,Production">
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
using (var db = new ThingDb())
{
// just need this once for all instances to log:
var serviceProvider = db.GetInfrastructure();
var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
loggerFactory.AddConsole();
}
@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)}");
}
ALFA ROMEO Italy 2016
Aston Martin Lagonda Ltd UK 2016
Audi Germany 2016
BMW Germany 2016
Chevrolet USA 2016
Dodge USA 2016
Ferrari Italy 2016
Honda Japan 2016
Jaguar UK 2016
Lamborghini Italy 2016
@OdeToCode
OdeToCode / fuel.csv
Last active September 26, 2022 11:08
Model Year Division Carline Eng Displ # Cyl City FE Hwy FE Comb FE
2016 ALFA ROMEO 4C 1.8 4 24 34 28
2016 Aston Martin Lagonda Ltd V12 Vantage S 6.0 12 12 18 14
2016 Aston Martin Lagonda Ltd V8 Vantage 4.7 8 14 21 16
2016 Aston Martin Lagonda Ltd V8 Vantage 4.7 8 13 19 15
2016 Aston Martin Lagonda Ltd V8 Vantage S 4.7 8 14 21 16
2016 Aston Martin Lagonda Ltd V8 Vantage S 4.7 8 13 19 15
2016 Aston Martin Lagonda Ltd Vantage GT 4.7 8 14 21 16
2016 Aston Martin Lagonda Ltd Vantage GT 4.7 8 13 19 15
2016 Audi TT Roadster quattro 2.0 4 23 30 26