Skip to content

Instantly share code, notes, and snippets.

View jason-watts's full-sized avatar

Jason Watts jason-watts

  • Nutrien
  • Colorado
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jason-watts on github.
  • I am jason_watts (https://keybase.io/jason_watts) on keybase.
  • I have a public key ASCKTHBTqFRJv6Uvc654Mq_k79zfORmjuCdOHmsrn945-wo

To claim this, I am signing this object:

@jason-watts
jason-watts / gist:d0cbcc58a97ab904e3fb
Created May 20, 2015 12:36
Convert object to dictionary of properties and values (useful for loggly)
var obj = new Object();
obj.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.ToDictionary(prop => prop.Name, prop => Prop.GetValue(obj, null);
select --*
qs.session_id,qs.status,qs.command,qs.blocking_session_id,qs.open_transaction_count,
qs.cpu_time,qs.total_elapsed_time,qs.reads,qs.writes,qs.logical_reads,
SUBSTRING(st.text, (qs.statement_start_offset/2)+1,
((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset
END - qs.statement_start_offset)/2) + 1) AS statement_text
from sys.dm_exec_requests as qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
@jason-watts
jason-watts / gist:149f64dc076a101b3de2
Created January 7, 2015 09:19
Sublime Keybindings for getting out of auto completed matching brackets
{ "keys": ["enter"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)\"\\]]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
}
@jason-watts
jason-watts / gist:4562580
Created January 18, 2013 05:35
show all tables with a specific column name
SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%EmployeeID%'
ORDER BY schema_name, table_name;
@jason-watts
jason-watts / gist:4090866
Created November 16, 2012 20:59
ssh bash setup
SH_ENV="$HOME/.ssh/environment"
eval $(ssh-agent)
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
echo succeeded
@jason-watts
jason-watts / gist:3317403
Created August 10, 2012 20:03
DOS Batch file to run in a temp directory that has exceeded its 65335 limit.
for /d %%D in (*) do echo Y | del "%%D"\*.* & rmdir "%%D"
@jason-watts
jason-watts / gist:3289813
Created August 7, 2012 22:04
change comma delimited file to tab delimited using bash
for file in *.txt; do cat $file | tr '[,]' '[\t]' > new_*.txt; done
@jason-watts
jason-watts / gist:2495866
Created April 26, 2012 04:38
Get real ip; useful when tethering or coffee shop hopping
curl -s whatsmyrealip.com | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | sort --unique
@jason-watts
jason-watts / gist:2345833
Created April 9, 2012 19:21
get schema of views from sql server
select
o.name [Table]
,c.*
,c.name [Column]
,t.name
,c.max_length
,t.precision
,t.scale
from sys.columns c