Skip to content

Instantly share code, notes, and snippets.

@theuntitled
theuntitled / dotnet-dev-cert.ps1
Created January 14, 2022 00:13
Generate a https certificate with dotnet
dotnet dev-certs https -ep "dev-cert.pfx" -p "d@nK3w1lhELm"
dotnet dev-certs https --trust
@theuntitled
theuntitled / ByteRangesRouteConstraint.cs
Created October 10, 2019 10:20
ASP.NET Core 3 Partial Content Response (Status Code 206) for electron-updater
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
namespace Example
{
public class ByteRangesRouteConstraint : IRouteConstraint
{
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
{
if (!values.TryGetValue("url", out var url) || url == null)
@theuntitled
theuntitled / Measure.sql
Created February 27, 2019 09:37
Measures the elapsed time for a query in milliseconds.
DECLARE @t1 DATETIME;
DECLARE @t2 DATETIME;
SET @t1 = GETDATE();
-- Query to measure
SET @t2 = GETDATE();
SELECT DATEDIFF(millisecond,@t1,@t2) AS elapsed_ms;
@theuntitled
theuntitled / rainbows.css
Created June 9, 2017 12:51
Rainbow text effect for your text
.easteregg {
animation: rainbow 1s infinite linear;
-moz-animation: rainbow 1s infinite linear;
-webkit-animation: rainbow 1s infinite linear;
-o-animation: rainbow 1s infinite linear;
-webkit-transition: color;
-moz-transition: color;
-o-transition: color;
transition: color
}
@theuntitled
theuntitled / CustomSqlErrorLog.cs
Created April 19, 2017 13:54
ASP.NET MVC error page containing the ELMAH error id
using System.Collections;
using System.Web;
using Elmah;
namespace Project
{
/// <summary>
/// A custom implementation of the elamh provided <see cref="SqlErrorLog" />.
/// </summary>
public class CustomSqlErrorLog : SqlErrorLog
@theuntitled
theuntitled / TaxonomySearchResult.ts
Created September 20, 2016 11:50
SharePoint 2013 JSOM Taxonomy Managed Metadata Field Result
class TaxonomySearchResult {
id: string;
label: string;
termSetId: string;
parentTermId: string;
constructor(resultValue: string) {
const informationParts = resultValue.split(";");
for (let i = 0; i < informationParts.length; i++) {
@theuntitled
theuntitled / DataContext.cs
Created August 31, 2016 15:43
Entity Framework Core - Identity AspNet Tables
...
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<User>().ForSqlServerToTable("Users");
builder.Entity<IdentityRole>().ForSqlServerToTable("Roles");
builder.Entity<IdentityUserRole<string>>().ForSqlServerToTable("UserRoles");
builder.Entity<IdentityUserClaim<string>>().ForSqlServerToTable("UserClaims");
builder.Entity<IdentityRoleClaim<string>>().ForSqlServerToTable("RoleClaims");
builder.Entity<IdentityUserLogin<string>>().ForSqlServerToTable("UserLogins");
builder.Entity<IdentityUserToken<string>>().ForSqlServerToTable("UserTokens");
using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
@theuntitled
theuntitled / query.sql
Created July 7, 2016 11:15
Get all logical database file names
SELECT DB_NAME(database_id) AS DatabaseName, name AS LogicalFileName, physical_name AS PhysicalFileName
FROM sys.master_files AS mf
@theuntitled
theuntitled / CookieJar.cs
Created April 27, 2016 08:32
ASP.NET CookieJar Class
using System;
using System.Linq;
using System.Web;
namespace Project
{
public class CookieJar
{
public HttpRequest Request => return HttpContext.Current.Request;