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 / master-id.diff
Created August 21, 2015 11:12
MASTER MODE enabled (user request from '<client>') redis patch
diff --git a/src/replication.c b/src/replication.c
index 8102fc2..d9545b8 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -1250,8 +1250,10 @@ void slaveofCommand(redisClient *c) {
if (!strcasecmp(c->argv[1]->ptr,"no") &&
!strcasecmp(c->argv[2]->ptr,"one")) {
if (server.masterhost) {
+ sds client = getClientInfoString(c);
replicationUnsetMaster();
@NickCraver
NickCraver / SE Cluster 2 D-Drive (Tier 1).log
Last active August 29, 2015 14:27
Stack Overflow SQLIO Numbers
# Dual Intel P3700 2TB PCIe NVMe SSD Drives in a RAID 0
C:\Program Files (x86)\SQLIO>echo BUFFERED
BUFFERED
C:\Program Files (x86)\SQLIO>sqlio -kW -t8 -s120 -o8 -frandom -b8 -BH -LS -Fparam-D.txt
sqlio v1.5.SG
using system counter for latency timings, 3125001 counts per second
parameter file used: param-D.txt
file D:\testfile.dat with 2 threads (0-1) using mask 0x0 (0)
@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 / sp_Refresh_Database.sql
Created October 23, 2015 10:48
Stack Exchange Data Explorer - database import stored procedure.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_Refresh_Database] @DBName nvarchar(100)
AS
BEGIN
SET NOCOUNT ON;
@NickCraver
NickCraver / dnx.log
Created October 25, 2015 22:02
DNX "Failed to start CLR host" log
C:\DNXTest\Client\runtimes\dnx-coreclr-win-x86.1.0.0-beta8\bin>dnx
The default servicing root does not exist.
Loaded module: dnx.win32.coreclr.dll
Found export: CallApplicationMain
Failed to start CLR host
@NickCraver
NickCraver / Top By Query Hash.sql
Last active October 27, 2015 20:49
SQL Top Queries
DECLARE @MaxResultCount int = 500;
SELECT AvgCPU, AvgDuration, AvgReads, AvgCPUPerMinute,
TotalCPU, TotalDuration, TotalReads,
PercentCPU, PercentDuration, PercentReads, PercentExecutions,
ExecutionCount,
ExecutionsPerMinute,
PlanCreationTime, LastExecutionTime,
SUBSTRING(st.text,
(StatementStartOffset / 2) + 1,
@NickCraver
NickCraver / results.txt
Created November 3, 2015 20:11
string.Format() vs string.Concat() quick perf tests for Abstractions
string.Concat(): 3011 ms
string.Format(): 18337 ms
string.Concat(): 2885 ms
string.Format(): 18312 ms