Skip to content

Instantly share code, notes, and snippets.

View NickCraver's full-sized avatar

Nick Craver NickCraver

View GitHub Profile
NickCraver / SODailyRep.user.js
Created October 27, 2010 10:43
Adds a "total rep today" number in the top bar for all StackExchange sites - Only works in Chrome, only makes a request every 30 min or when your total rep changes.
View SODailyRep.user.js
// ==UserScript==
// @name SO Daily Reputation
// @namespace soRepDaily
// @description Shows reputation for the current day.
// @include*
// @include*
// @include*
// @include*
// @include http://**
// ==/UserScript==
NickCraver / enter-comments.user.js
Created December 9, 2010 18:47
User Script - Disable Enter key on comments on StackExchange.
View enter-comments.user.js
// ==UserScript==
// @name Disable Enter key on comments on Stack Exchange.
// @namespace
// @description Disable Enter key on comments on Stack Exchange.
// @include http://**
// @include*
// @include*
// @include*
// @include*
// @include*
NickCraver / se-disable-search-animation.user.js
Created August 9, 2011 02:03
Stack Exchange search box animation disabler
View se-disable-search-animation.user.js
// ==UserScript==
// @name Stack Exchange search box animation disabler 1.0
// @namespace stackoverflow
// @description Removes Stack Exchange search box animation shenanigans
// @include*
// @include http://**
// @include http://**
// @include*
// @include*
// @include*
NickCraver / SQL-Login-Replication.sql
Created October 3, 2012 12:17
SQL Login Replication
View SQL-Login-Replication.sql
DECLARE @name sysname,
@PWD_varbinary varbinary (256),
@PWD_string varchar (514),
@SID_varbinary varbinary (85),
@SID_string varchar (514),
@sqlString varchar (1024),
@is_policy_checked varchar (3),
@is_expiration_checked varchar (3),
@defaultdb sysname;
NickCraver / CurrentQuery
Created January 29, 2014 03:08
SQL 2014 Top Queries DB Filter Test
View CurrentQuery
Declare @MaxResultCount int = 50;
SELECT AvgCPU, AvgDuration, AvgReads, AvgCPUPerMinute,
TotalCPU, TotalDuration, TotalReads,
PercentCPU, PercentDuration, PercentReads, PercentExecutions,
PlanCreationTime, LastExecutionTime,
(StatementStartOffset / 2) + 1,
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.
View StringSplits.cs
/// <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 / gist:65a497c86a4762f97019
Last active August 29, 2015 14:07
Initial SQLIO Results from an Intel 800GB P3700
View gist:65a497c86a4762f97019
sqlio v1.5.SG
using system counter for latency timings, 2636721 counts per second
8 threads writing for 120 secs to file E:\TestFile.dat
using 8KB random IOs
enabling multiple I/Os per thread with 8 outstanding
buffering set to use hardware disk cache (but not file cache)
using current size: 24576 MB for file: E:\TestFile.dat
initialization done
throughput metrics:
NickCraver / Notes.txt
Last active August 29, 2015 14:07
SQLIO Performance tests of a 2 TB Intel P3700 NVMe PCIe SSD on a Dell r710
View Notes.txt
Notes: this is on a Dell R710 server running Windows 2012 Server Core (latest patches as of 2014-10-12) - access to NVMe drives is via a mini driver on this OS version.
We'll re-run these tests when these SSDs migrate to some new R730xd servers in about a month, when we rebuild the cluster on Windows 2012 R2 which has native NVMe support.
This is also in a currently inactive server while we do a burn-in test on the primary to ensure there are no issues with this storage setup. If you have additional SQLIO test configurations you want to see - ping me via @Nick_Craver and I'm happy to run when until we stick this into production on 2014-10-14 (2 days from now).
NickCraver / pre-push
Created March 19, 2015 23:20
pre-push git hook for CloudFlare purging
View pre-push
sleep 10s && curl \
-d 'a=fpurge_ts' \
-d 'tkn=<insert API token>' \
-d 'email=<insert email>' \
-d 'z=<insert domain>' \
-d 'v=1' &
exit 0
NickCraver / HTTPMuter.cs
Created March 27, 2015 03:51
A simple HTTPListener to enable muting remotely
View HTTPMuter.cs
using System;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
class Program
static readonly HttpListener httpListener = new HttpListener();
static void Main(string[] args)