Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Shipping

Nick Craver NickCraver

:shipit:
Shipping
View GitHub Profile
@NickCraver
NickCraver / UDFPerf.sql
Last active Aug 29, 2015
UDF Performance and why to avoid use in WHERE clauses
View UDFPerf.sql
-- Here, the function is run once, and using the result for row comparisons
Declare @RayId BIGINT = dbo.fnToRay('1D7370C08D710779-EWR');
Select *
From Log_2015_04_15
Where RayId = @RayId;
-- (1 row(s) affected)
-- Table 'Log_2015_04_15'. Scan count 41, logical reads 7808338, physical reads 0, read-ahead reads 126, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
-- SQL Server Execution Times:
-- CPU time = 24124 ms, elapsed time = 2752 ms.
@NickCraver
NickCraver / jQuery.logHandlers.js
Created Apr 25, 2015
A simple jQuery plugin to print bound event handlers, including on parent elements
View jQuery.logHandlers.js
$.fn.logHandlers = function() {
var result = {};
this.parents().andSelf().each(function(_, e) {
var events = $._data(e, 'events') || {};
if ($.isEmptyObject(events)) return;
var cur = result[this.outerHTML.split($(this).html())[0]] = {};
Object.keys(events).forEach(function(k) {
cur[k] = events[k].map(function(ev) {
return ev.handler.toString();
});
@NickCraver
NickCraver / install.log
Created May 5, 2015
npm install -g yo grunt-cli generator-aspnet bower
View install.log
ncraver@CraverBook:~$ sudo npm install -g yo grunt-cli generator-aspnet bower
Password:
npm WARN engine yo@1.4.6: wanted: {"node":">=0.10.0","npm":">=2.1.0"} (current: {"node":"v0.10.26","npm":"1.4.3"})
npm http GET https://registry.npmjs.org/resolve
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/findup-sync
npm http 304 https://registry.npmjs.org/resolve
npm http 304 https://registry.npmjs.org/findup-sync
npm http 200 https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/abbrev
@NickCraver
NickCraver / Startup.cs
Last active Aug 29, 2015
IFTTT WordPress faker for listening to Amazon Echo - Empty OWIN App's Startup.cs
View Startup.cs
using System;
using System.Threading.Tasks;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Framework.DependencyInjection;
namespace IFTTTEndpoint
{
@NickCraver
NickCraver / extension.log
Created May 10, 2015
GitHub.VisualStudio.UI.Views.Controls.TwoFactorControl
View extension.log
2015-05-09 23:03:22.1357|INFO|thread:32|LoginTabViewModel|Error logging into 'https://github.com/' as 'nrcraver@gmail.com'
Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "GitHub.VisualStudio.UI.Views.Controls.TwoFactorControl". ---> System.InvalidOperationException: The calling thread must be STA, because many UI components require this.
at System.Windows.Input.InputManager..ctor()
at System.Windows.Input.InputManager.GetCurrentInputManagerImpl()
at System.Windows.Input.KeyboardNavigation..ctor()
at System.Windows.FrameworkElement.FrameworkServices..ctor()
at System.Windows.FrameworkElement.EnsureFrameworkServices()
at System.Windows.FrameworkElement..ctor()
at System.Windows.Controls.Control..ctor()
at GitHub.UI.SimpleViewUserControl..ctor() in c:\Users\shana\Documents\GitHub\VisualStudio\src\GitHub.UI.Reactive\Controls\SimpleViewUserControl.cs:line 23
@NickCraver
NickCraver / haproxy.cfg.example
Created May 20, 2015
HAProxy SSL/TLS Setings for Stack Overflow as of 2015-05-20
View haproxy.cfg.example
ssl-default-bind-ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
tune.ssl.default-dh-param 2048
tune.ssl.maxrecord 1400
@NickCraver
NickCraver / Win10-DisableLockScreen.ps1
Created Aug 3, 2015
Disable the lock screen (the one before the password prompt) in Windows 10 for faster login and not dropping the first password character.
View Win10-DisableLockScreen.ps1
# Disable the Lock Screen (the one before password prompt - to prevent dropping the first character)
If (-Not (Test-Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization)) {
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows -Name Personalization | Out-Null
}
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization -Name NoLockScreen -Type DWord -Value 1 -Force
@NickCraver
NickCraver / Windows10-Setup.ps1
Last active Oct 25, 2020
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
View Windows10-Setup.ps1
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
@NickCraver
NickCraver / NuGet-Unrelated-Source-Fail.log
Created Aug 5, 2015
Log showing NuGet failure when an unrelated source fails to pull, when nuget.org is fine.
View NuGet-Unrelated-Source-Fail.log
Installing NuGet package Microsoft.Owin.Host.SystemWeb.3.0.1.
Successfully installed 'Microsoft.Owin.Host.SystemWeb.3.0.1' to WebApplication2
========== Finished ==========
PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git
C:\Users\ncraver.STACKEXCHANGE\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta5\bin\dnx.exe "C:\Users\ncraver.STACKEXCHANGE\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta5\bin\lib\Microsoft.Framework.PackageManager\Microsoft.Framework.PackageManager.dll" restore "c:\users\ncraver.stackexchange\documents\visual studio 2015\Projects\WebApplication2\src\WebApplication2" -f "C:\Program Files (x86)\Microsoft Web Tools\DNU"
Microsoft .NET Development Utility CLR-x86-1.0.0-beta5-12103
Restoring packages for c:\users\ncraver.stackexchange\documents\visual studio 2015\Projects\WebApplication2\src\WebApplication2\project.j
@NickCraver
NickCraver / master-id.diff
Created Aug 21, 2015
MASTER MODE enabled (user request from '<client>') redis patch
View master-id.diff
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();
You can’t perform that action at this time.