Skip to content

Instantly share code, notes, and snippets.

View NickCraver's full-sized avatar
:shipit:
Shipping

Nick Craver NickCraver

:shipit:
Shipping
View GitHub Profile
@NickCraver
NickCraver / TweetDeckDark.css
Last active December 10, 2020 07:52
TweetDeck Dark Theme
@-moz-document domain("tweetdeck.twitter.com") {
html.dark {
color: #e1e8ed;
}
html.dark body:before {
background-image: radial-gradient(circle, #1c6399, #274256);
}
html.dark body,
html.dark .app-header,
html.dark .app-title,
@NickCraver
NickCraver / dashboard-5c5ee7780849a005a92cb1a6.json
Created September 7, 2019 13:24
UniFi Dashboard - Overview
gi{"name":"Overview","desc":"System Overview","controller_version":"5.10.12","modules":[{"id":"default:mega|status","module_id":"mega|status","restrictions":{"removable":false,"draggable":false},"config":{}},{"module_id":"internet-connection","config":{},"id":"dd5f7461-f8f0-4017-859c-3d9271b673bf"},{"module_id":"summary|wifi","config":{},"id":"13a78652-ad84-4fcb-943a-86929c638353"},{"module_id":"clients|freq-distribution","config":{"palette":"BLUE_GRADIENT_10"},"id":"c9626f4f-021f-4d46-b22d-86007570bac7"},{"module_id":"clients|top5|active","config":{"trafficType":"total"},"id":"36a9e071-132e-4b4a-baee-250449a6d44f"},{"module_id":"devices|uap|top5|channel-util","config":{"trafficType":"total"},"id":"9803f077-b9cd-4db0-b466-60d92fae2020"},{"module_id":"devices|uap|top5|active","config":{"trafficType":"total"},"id":"e6133049-cc56-44b3-a4c2-b0843912dac5"},{"module_id":"devices|uap|top5|client-count","config":{},"id":"d39f9c80-1827-4ba0-b573-3209789c56b5"},{"module_id":"summary|switching","config":{},"id":"5966437
@NickCraver
NickCraver / MiniProfiler ReadMe.cs
Last active September 25, 2020 11:24
MiniProfiler README Table Generator
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 / Http.cs
Last active January 17, 2020 01:10
HttpClient Ideas
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 / Svg.cs
Created February 1, 2017 22:36
A simple SVG helper for Stack Overflow that inlines SVGs into Razor views efficiently
using System;
using System.IO;
using System.Web;
using System.Web.Hosting;
namespace StackOverflow.Helpers
{
public static class Svg
{
// NOTE: To add a new SVG icon, copy paste the line below. Paste it after the other ones.
@NickCraver
NickCraver / DelayTest.cs
Created July 22, 2018 12:14
A simple program showing Task.Delay(1) and what really happens
async Task Main()
{
for (var i = 0; i < 20; i++)
{
await Run(); // Just to show it many times
}
}
public async Task Run()
{
@NickCraver
NickCraver / StringSplits.cs
Last active June 19, 2019 20:26
StringSplits is a helper class thought up by Marc Gravell we use in the Stack Overflow/Stack Exchange code base to save on string allocations and relieve the garbage collector on gen 0.
/// <summary>
/// Using a single instance of these arrays prevents an allocation of a new array on every call to something like
/// string.Split(';') which is really calling string string.Split(params char[] separator), causing an allocation
/// of an additional array behind the scenes.
/// </summary>
/// <remarks>
/// For most applications this is a micro-optimization that doesn't matter. However, for very high traffic code paths
/// this can generate a significant amount of items that the gen 0 garbage collector needs to collect, causing micro-stalls
/// in the app domain when it runs, or runs more often.
/// </remarks>
@NickCraver
NickCraver / Examples.cs
Last active April 16, 2019 01:56
SQL Exception handy helpers
// Here are some example usages for unimportant jobs we have where crap happens occasionally:
/// <summary>
/// intended for database commands that might deadlock, but are just "nice to haves"; we don't care if they deadlock every now and then
/// and we DON'T want them to block execution of the rest of /daily or /hourly! this returns -1 if deadlocked, otherwise, returns
/// the # of rows that the SQL command affected
/// </summary>
private int ExecuteIgnoreDeadlocks(string sql, object param = null, bool logDeadlock = false)
{
try
@NickCraver
NickCraver / Overview.json
Created March 12, 2019 01:47
Craver's UniFi dashboard layout
{"name":"Overview","desc":"System Overview","controller_version":"5.10.12","modules":[{"id":"default:mega|status","module_id":"mega|status","restrictions":{"removable":false,"draggable":false},"config":{}},{"module_id":"summary|wifi","config":{},"id":"13a78652-ad84-4fcb-943a-86929c638353"},{"module_id":"clients|freq-distribution","config":{"palette":"BLUE_GRADIENT_10"},"id":"c9626f4f-021f-4d46-b22d-86007570bac7"},{"module_id":"clients|top5|active","config":{"trafficType":"total"},"id":"36a9e071-132e-4b4a-baee-250449a6d44f"},{"module_id":"devices|uap|top5|channel-util","config":{"trafficType":"total"},"id":"9803f077-b9cd-4db0-b466-60d92fae2020"},{"module_id":"devices|uap|top5|active","config":{"trafficType":"total"},"id":"e6133049-cc56-44b3-a4c2-b0843912dac5"},{"module_id":"devices|uap|top5|client-count","config":{},"id":"d39f9c80-1827-4ba0-b573-3209789c56b5"},{"module_id":"summary|switching","config":{},"id":"5966437b-54f7-43e6-9c03-2adbdeb3c0a6"},{"module_id":"devices|usw|top5|active","config":{},"id":"c83ac
@NickCraver
NickCraver / DarkMode.js
Last active February 14, 2019 18:31
A quick and dirty re-purpose of UniFi dark elements to make them global.
// A JS example that shows they're well on their way to a dark theme:
document.body.classList.add("ubnt-mod-dark");
document.querySelectorAll(".appTable").forEach(i => i.classList.add("appTable--dark"));
document.querySelectorAll(".ubntPanelContent").forEach(i => i.classList.add("appForm--dark"));
document.querySelectorAll(".appMainButtonGroup").forEach(i => i.classList.add("appMainButtonGroup--dark"));