Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Shipping

Nick Craver NickCraver

:shipit:
Shipping
View GitHub Profile
@NickCraver
NickCraver / SODailyRep.user.js
Created Oct 27, 2010
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 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 Dec 9, 2010
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 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 Aug 9, 2011
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 http://stackoverflow.com/*
// @include http://*.stackoverflow.com/*
// @include http://*.stackexchange.com/*
// @include http://serverfault.com/*
// @include http://superuser.com/*
// @include http://stackapps.com/*
View SQL-Login-Replication.sql
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 Jan 29, 2014
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,
ExecutionCount,
ExecutionsPerMinute,
PlanCreationTime, LastExecutionTime,
SUBSTRING(st.text,
(StatementStartOffset / 2) + 1,
@NickCraver
NickCraver / StringSplits.cs
Last active Jun 19, 2019
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
NickCraver / gist:65a497c86a4762f97019
Last active Aug 29, 2015
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
CUMULATIVE DATA:
throughput metrics:
@NickCraver
NickCraver / Notes.txt
Last active Aug 29, 2015
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
NickCraver / pre-push
Created Mar 19, 2015
pre-push git hook for CloudFlare purging
View pre-push
#!/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 Mar 27, 2015
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)
You can’t perform that action at this time.