Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Shipping

Nick Craver NickCraver

:shipit:
Shipping
View GitHub Profile
@NickCraver
NickCraver / OptInRelationalModelSource.cs
Last active Aug 22, 2018
OptInRelationalModelSource.cs - Making EF Core opt-in instead of opt-out for properties
View OptInRelationalModelSource.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal;
View keybase.md

Keybase proof

I hereby claim:

  • I am nickcraver on github.
  • I am nickcraver (https://keybase.io/nickcraver) on keybase.
  • I have a public key ASAVMojHFRx86OeapA0fAbGblg0VzqFn4agNkah58X9ixQo

To claim this, I am signing this object:

@NickCraver
NickCraver / DelayTest.cs
Created Jul 22, 2018
A simple program showing Task.Delay(1) and what really happens
View DelayTest.cs
async Task Main()
{
for (var i = 0; i < 20; i++)
{
await Run(); // Just to show it many times
}
}
public async Task Run()
{
@NickCraver
NickCraver / Craver-Paradox.ps1
Last active Jun 15, 2021
My PowerShell PoshGit theme (used with Cmder)
View Craver-Paradox.ps1
#requires -Version 2 -Modules posh-git
# This is a tweaked version of https://github.com/JanJoris/oh-my-posh/blob/master/Themes/Paradox.psm1
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
@NickCraver
NickCraver / MiniProfiler ReadMe.cs
Last active Sep 25, 2020
MiniProfiler README Table Generator
View MiniProfiler ReadMe.cs
var packages = new[] {
"MiniProfiler",
"MiniProfiler.AspNetCore",
"MiniProfiler.AspNetCore.Mvc",
"MiniProfiler.EF6",
"MiniProfiler.EntityFrameworkCore",
"MiniProfiler.Mvc5",
"MiniProfiler.Providers.MongoDB",
"MiniProfiler.Providers.MySql",
"MiniProfiler.Providers.Redis",
@NickCraver
NickCraver / notblue.css
Last active Oct 6, 2018
TweetDeck Dark Theme - Revert the Blue
View notblue.css
html.dark .column, html.dark .stream-item {
background-color: #222426;
}
html.dark .detail-view-inline-text {
background: #fff;
color: #8899a6;
}
html.dark a, html.dark a:hover,
html.dark .other-replies-link, html.dark .other-replies-link:hover,
html.dark .btn-neutral-positive, html.dark .btn-neutral-positive:hover, html.dark .btn-neutral-positive:focus {
@NickCraver
NickCraver / Http.cs
Last active Jan 17, 2020
HttpClient Ideas
View Http.cs
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
@NickCraver
NickCraver / .editorconfig
Created Sep 26, 2017
Stack Overflow's .editorconfig
View .editorconfig
# editorconfig.org
root = true
# Don't use tabs for indentation.
[*]
indent_style = space
[*.less]
charset = utf-8
end_of_line = lf
@NickCraver
NickCraver / Stylus.StackExchange.css
Created Jul 7, 2017
My Stylus theme for Stack Exchange MiniProfiler and Chat
View Stylus.StackExchange.css
@-moz-document domain("stackoverflow.com"), domain("stackexchange.com"), domain("serverfault.com"), domain("askubuntu.com"), domain("stackapps.com"), domain("superuser.com") {
.profiler-result tr[style*='display: block;'] {
display: table-row !important;
}
.profiler-result th[style*='display: block;'], .profiler-result td[style*='display: block;'] {
display: table-cell!important;
}
}
@-moz-document domain("chat.meta.stackexchange.com"), domain("chat.stackexchange.com"), domain("chat.stackoverflow.com") {
@NickCraver
NickCraver / Query.sql
Created Jun 1, 2017
SQL Divide By Zero Glitch with aggregates
View Query.sql
SELECT [tag.iface], [tag.host], Sum([value]) [value], [timestamp]
FROM (SELECT [tag.iface], [tag.host], [tag.direction], [dateDiff], Max([value]) [value],
DateAdd(Second, DateDiff(Second, GETUTCDATE(), [timestamp]) / 15 * 15, GETUTCDATE()) [timestamp]
FROM (SELECT [tag.iface],
[tag.host],
[tag.direction],
[timestamp],
DateDiff(Second, [LastTime], [timestamp]) [dateDiff],
--(([value] - [LastValue]) / NullIf(DateDiff(Second, [LastTime], [timestamp]), 0)) [value]
(([value] - [LastValue]) / DateDiff(Second, [LastTime], [timestamp])) [value]