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 / 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.
// ==UserScript==
// @name SO Daily Reputation
// @namespace soRepDaily
// @description Shows reputation for the current day.
// @include http://stackoverflow.com/*
// @include http://serverfault.com/*
// @include http://superuser.com/*
// @include http://meta.stackoverflow.com/*
// @include http://*.stackexchange.com/*
// ==/UserScript==
@NickCraver
NickCraver / enter-comments.user.js
Created December 9, 2010 18:47
User Script - Disable Enter key on comments on StackExchange.
// ==UserScript==
// @name Disable Enter key on comments on Stack Exchange.
// @namespace http://networkpx.googlecode.com
// @description Disable Enter key on comments on Stack Exchange.
// @include http://*.stackexchange.com/*
// @include http://stackoverflow.com/*
// @include http://meta.stackoverflow.com/*
// @include http://serverfault.com/*
// @include http://meta.serverfault.com/*
// @include http://superuser.com/*
@NickCraver
NickCraver / se-disable-search-animation.user.js
Created August 9, 2011 02:03
Stack Exchange search box animation disabler
// ==UserScript==
// @name Stack Exchange search box animation disabler 1.0
// @namespace stackoverflow
// @description Removes Stack Exchange search box animation shenanigans
// @include http://stackoverflow.com/*
// @include http://*.stackoverflow.com/*
// @include http://*.stackexchange.com/*
// @include http://serverfault.com/*
// @include http://superuser.com/*
// @include http://stackapps.com/*
@NickCraver
NickCraver / SQL-Login-Replication.sql
Created October 3, 2012 12:17
SQL Login Replication
SET NOCOUNT ON;
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
NickCraver / CurrentQuery
Created January 29, 2014 03:08
SQL 2014 Top Queries DB Filter Test
Declare @MaxResultCount int = 50;
SELECT AvgCPU, AvgDuration, AvgReads, AvgCPUPerMinute,
TotalCPU, TotalDuration, TotalReads,
PercentCPU, PercentDuration, PercentReads, PercentExecutions,
ExecutionCount,
ExecutionsPerMinute,
PlanCreationTime, LastExecutionTime,
SUBSTRING(st.text,
(StatementStartOffset / 2) + 1,
@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 / gist:65a497c86a4762f97019
Last active August 29, 2015 14:07
Initial SQLIO Results from an Intel 800GB P3700
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
CUMULATIVE DATA:
throughput metrics:
@NickCraver
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
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
NickCraver / pre-push
Created March 19, 2015 23:20
pre-push git hook for CloudFlare purging
#!/bin/sh
sleep 10s && curl https://www.cloudflare.com/api_json.html \
-d 'a=fpurge_ts' \
-d 'tkn=<insert API token>' \
-d 'email=<insert email>' \
-d 'z=<insert domain>' \
-d 'v=1' &
exit 0
@NickCraver
NickCraver / HTTPMuter.cs
Created March 27, 2015 03:51
A simple HTTPListener to enable muting remotely
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)