Skip to content

Instantly share code, notes, and snippets.

View jacobhackl's full-sized avatar

Jacob Hackl jacobhackl

  • minneapolis, mn
View GitHub Profile
@jacobhackl
jacobhackl / SQL Server memory check
Created January 30, 2011 22:34
Quick sql server check for memory
exec sp_configure
SELECT
( CASE WHEN ( [is_modified] = 1 ) THEN 'Dirty' ELSE 'Clean' END ) AS 'Page State' ,
( CASE WHEN ( [database_id] = 32767 ) THEN 'Resource Database' ELSE DB_NAME ( database_id ) END ) AS 'Database Name' ,
COUNT (*) AS 'Page Count'
FROM sys . dm_os_buffer_descriptors
GROUP BY [database_id] , [is_modified]
ORDER BY [database_id] , [is_modified] ;
GO
@jacobhackl
jacobhackl / Terminal open
Created February 7, 2011 20:33
I forget this all the time
open .
@jacobhackl
jacobhackl / gist:976723
Created May 17, 2011 15:48
Deeper reindex from MFST...not as good as my old one
SET NOCOUNT ON;
DECLARE @tablename varchar(255);
DECLARE @execstr varchar(400);
DECLARE @objectid int;
DECLARE @indexid int;
DECLARE @frag decimal;
DECLARE @maxfrag decimal;
-- Decide on the maximum fragmentation to allow for.
SELECT @maxfrag = 30.0;
@jacobhackl
jacobhackl / SlowQueries
Created June 30, 2011 20:27
Find slow queries
SELECT creation_time
,last_execution_time
,total_physical_reads
,total_logical_reads
,total_logical_writes
, execution_count
, total_worker_time
, total_elapsed_time
, total_elapsed_time / execution_count avg_elapsed_time
,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
@jacobhackl
jacobhackl / gist:1057159
Created June 30, 2011 20:31
SQL Activity mon query
--from http://sqlblog.com/blogs/john_paul_cook/archive/2009/08/24/using-the-processes-query-outside-of-activity-monitor.aspx
/* ACTIVITY MONITOR */
/* Processes */
SELECT
[Session ID] = s.session_id,
@jacobhackl
jacobhackl / gist:5454726
Created April 24, 2013 19:11
Quick Linq to SQL query for element with a namespace
XElement pop = XElement.Parse(xml);
XNamespace ns = "mtvnCWExternInteropResData";
string result = pop.Descendants(ns + "RedirInfo").First().Value;
install-package newtonsoft.json -version 5.0.8
@jacobhackl
jacobhackl / gist:10490973
Created April 11, 2014 18:39
Simple deployment script - windows
REM "press any key to continue with deploy. This will backup current IIS set and move the site from deploy into its place. Hit the X to cancel"
PAUSE
for /f "skip=1" %%d in ('wmic os get localdatetime') do if not defined mydate set mydate=%%d
SET source=C:\inetpub\wwwroot\SetSight3
SET destination=C:\Code\Deploy\Archive\SetSight3_%mydate:~0,8%
REM use Robocopy %source% %destination% /S /MOV /XF web.config /MAX:100000 to ignore web.config
Robocopy %source% %destination% /S /MOVE /XF serverInfo.js web.config /MAX:100000
SET source=C:\Code\Deploy\SetSight3
SET destination=C:\inetpub\wwwroot\SetSight3
Robocopy %source% %destination% /S /XF serverInfo.js web.config /MAX:100000
@jacobhackl
jacobhackl / gist:1715968cdab7c40a57e7
Created September 23, 2014 17:22
couchbase transfer
work in progress
cbtransfer http://192.168.2.91:8091 http://192.168.2.18:8091 -b bucket -B buckett -u Admin -p pw -n
@jacobhackl
jacobhackl / batched deletes
Created October 17, 2014 15:25
SQL - batched deletes
-- Step 1 : Declare the varaibles
use Northwind
Declare @counter int
Declare @RowsEffected int
Declare @RowsCnt int
Declare @CodeId int
Declare @OldCodeId int
Declare @Err int
SELECT @COUNTER = 1