Skip to content

Instantly share code, notes, and snippets.

@zommarin
zommarin / gist:1195238
Created September 5, 2011 15:23 — forked from shbaz/gist:1188369
git snippets
#
# Misc good to have commands when using git
#
# Setup user
git config --global user.name "First Last"
git config --global user.email first.last@domain.com
# Setup useful aliases
git config --global alias.ci commit
@zommarin
zommarin / gist:1236805
Created September 23, 2011 05:33 — forked from shbaz/gist:1188041
All objects not in dbo or sys schema
SELECT s.name, o.name, o.type, o.type_desc, s.schema_id
FROM sys.objects AS o
INNER JOIN sys.schemas AS s ON o.schema_id = s.schema_id
WHERE s.name NOT IN ( 'dbo', 'sys' )
@zommarin
zommarin / gist:1236807
Created September 23, 2011 05:34 — forked from shbaz/gist:1188006
Size of tables in a SQL Server database
--
-- Count rows in all tables, display tables with rows
--
CREATE TABLE #T (
name NVARCHAR(255),
[rows] INT,
reserved NVARCHAR(255),
data NVARCHAR(255),
index_size NVARCHAR(255),
@zommarin
zommarin / gist:1236808
Created September 23, 2011 05:34 — forked from shbaz/gist:1188035
Remove all non-dbo schemas, views and stored procedures
--
-- Remove non dbo tables, views and stored procedures
--
BEGIN TRANSACTION
DECLARE @Cmd NVARCHAR(max);
DECLARE [CmdCursor] CURSOR FAST_FORWARD READ_ONLY FOR
SELECT 'DROP TABLE [' + s.name + '].[' + t.name + '];'
@zommarin
zommarin / gist:1236809
Created September 23, 2011 05:34 — forked from shbaz/gist:1188016
Find non-dbo tables, views and procedures [SQL Server]
--
-- Select the tables, views and stored procedures that are not in the [dbo] schema
--
-- Useful when double checking that prople has not run scripts with the wrong user
-- for databases that have everything in the [dbo] schema.
--
SELECT 'Table' AS [Type] ,
'[' + s.name + '].[' + t.name + ']' AS [Name]
FROM sys.tables AS t
@zommarin
zommarin / gist:1236810
Created September 23, 2011 05:34 — forked from shbaz/gist:1188006
Size of tables in a SQL Server database
--
-- Count rows in all tables, display tables with rows
--
CREATE TABLE #T (
name NVARCHAR(255),
[rows] INT,
reserved NVARCHAR(255),
data NVARCHAR(255),
index_size NVARCHAR(255),
@zommarin
zommarin / .gitconfig
Created October 10, 2011 11:06
git config snippets
[diff]
guitool = BeyondCompare3
[difftool "BeyondCompare3"]
path = C:/Program Files/Beyond Compare 3/bcomp.exe
cmd = \"C:/Program Files/Beyond Compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
tool = BeyondCompare3
[mergetool "BeyondCompare3"]
path = C:/Program Files/Beyond Compare 3/bcomp.exe
cmd = \"C:/Program Files/Beyond Compare 3/bcomp.exe\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
@zommarin
zommarin / Get-FileEncoding.ps1
Created December 15, 2011 12:43
Get-FileEncoding
function Get-FileEncoding($Path) {
$bytes = [byte[]](Get-Content $Path -Encoding byte -ReadCount 4 -TotalCount 4)
if(!$bytes) { return 'utf8' }
switch -regex ('{0:x2}{1:x2}{2:x2}{3:x2}' -f $bytes[0],$bytes[1],$bytes[2],$bytes[3]) {
'^efbbbf' { return 'utf8' }
'^2b2f76' { return 'utf7' }
'^fffe' { return 'unicode' }
'^feff' { return 'bigendianunicode' }
@zommarin
zommarin / gist:1589286
Created January 10, 2012 14:16
Run a exe from powershell....
function Run-Exe() {
$Executable = $args[0]
$Arguments = @( $args | Select -Skip 1 )
Write-Host "RUNNING COMMAND: $Executable $Arguments"
$Output = & $Executable @Arguments 2>&1
if ($LASTEXITCODE) {
Write-Error "COMMAND FAILED: $Executable $Arguments`nExit code = $LASTEXITCODE`nOutput = $Output"
throw "COMMAND FAILED: $Executable $Arguments`nExit code = $LASTEXITCODE`nOutput = $Output"
}
Write-Host "COMMAND OUTPUT: $Output"
@zommarin
zommarin / gist:1759470
Created February 7, 2012 12:30
NTSD / WinDbg SOS Stuff
# Before - setup environment (PowerShell syntax):
$env:_NT_SYMBOL_PROXY = "webproxy.mycompany.com:8080"
# Start NTSD
& 'C:\Program Files\Debugging Tools for Windows (x64)\ntsd.exe' -p <pid>
& 'C:\Program Files\Debugging Tools for Windows (x64)\ntsd.exe' -z <dumpfile>
# Fix symbol path
.symfix
# Reload symbols