Skip to content

Instantly share code, notes, and snippets.

View timabell's full-sized avatar
🍵
418 I'm a teapot

Tim Abell timabell

🍵
418 I'm a teapot
View GitHub Profile
@timabell
timabell / xml-doc.tt
Created January 16, 2015 19:46
t4 snippet for adding xml doc from .edmx
// heavily modified version of http://forums.asp.net/t/2011994.aspx
...
WriteLine("");
WriteDocumentation(entity.Documentation);#>
...
WriteDocumentation(edmProperty.Documentation, CurrentIndent);
...
WriteDocumentation(complexProperty.Documentation);
...
#!/bin/sh
SKIP="noone"
cd ~/repo/uk-it-recruiter-domains/
cat ~/Documents/config/sieve-part1.txt > ~/Documents/config/sieve.txt
scripts/domains2sieve.py domains.txt | egrep -v "$SKIP|require" >> ~/Documents/config/sieve.txt
gedit ~/Documents/config/sieve.txt &
echo "skipped:"
@timabell
timabell / db-backup-utils.sql
Last active September 13, 2021 09:00
Sql for simplifying and automating the process of loading/backing up multiple databases
USE master;
SET NOCOUNT ON
GO
-- Sql for simplifying and automating the process of loading/backing up multiple databases.
-- Optionally override the restored db name.
-- Also has proc for doing an upgrade of a backup file via an intermediate sql server version.
-- The UI for backup/restore in ssms takes many clicks and doesn't remember anything, this
-- script will allow you to codify repetive actions.
@timabell
timabell / identity-baseline.sql
Last active September 13, 2021 09:00
Script to set the minimum id for all tables in a sql server database
/*
Script to set the minimum id for all tables.
Note that new tables get @baseId as the next id, tables that have had data in get @baseId+1. Ref http://stackoverflow.com/a/13303429/10245
*/
set xact_abort on -- automatically rollback on error
set nocount on -- make it easier to spot errors by reducing output verbosity
BEGIN TRAN
@timabell
timabell / schema-doc-properties.sql
Last active September 13, 2021 09:00
templates for addings sql server schema documentation
-- templates:
-- table description:
exec sys.sp_addextendedproperty @name=N'MS_Description', @level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE',
@level1name=N'TableNameHere', @value=N'Table description here'
-- column description:
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level2type=N'COLUMN',
@level1name=N'TableNameHere', @level2name=N'ColumnNameHere', @value=N'Column description here'
@timabell
timabell / boxstarter.ps1
Last active November 6, 2020 18:29
http://boxstarter.org/ script for .net development in a vm - run it by clicking here: https://is.gd/Zt6ziH
# boxstarter script http://boxstarter.org/
# source: https://gist.github.com/timabell/608fb680bfc920f372ac
# originally tested on win7 x64
# wip on win 10
# dotmatrix (windows branch) https://github.com/timabell/dotmatrix/tree/windows
# powershell profile https://gist.github.com/timabell/56254968905f9066ef88c1ae774a53d1
# This is a start of a build of a box I'm using at the moment.
# Fork this to your own gist, then comment/uncomment/add stuff to suit you.
@timabell
timabell / SqlQuoter.vba
Last active August 29, 2015 14:19
spreadsheet macro for making pretty sql insert blocks
'todo: handle empty properly, handle boolean true/false
' value - the value to turn into quoted and padded sql
' width - the largest item in this field, values will padded to fit.
' - use array formula =MAX(LEN(B290:B295)) to calculate this (ctrl-shift-enter to save an array formula)
' usage - apply this to all the cells you want to turn into sql, then concatenate the result in a final column
' like this =CONCATENATE(" (",P290,Q290,R290,S290,T290,U290,"),")
function SqlQuoter(value, width)
dim result as string
dim padding as integer
@timabell
timabell / FK-validation.sql
Last active September 13, 2021 09:00
misnamed sql server foreign key query
-- https://gist.github.com/timabell/d017038af96196b84e56
SELECT
obj.name,
fk.name
FROM sys.foreign_keys fk
inner join sys.objects obj on obj.object_id = fk.parent_object_id
-- use this where clause to find FKs that aren't named after their table:
where fk.name not like 'FK_' + obj.name + '_%'
Chocolatey (v0.9.8.33) is installing 'VisualStudio2015Professional' and dependen
cies. By installing you accept the license for 'VisualStudio2015Professional' an
d each dependency you are installing.
VisualStudio2015Professional v14.0.22823.0-RC
Write-Error : Package 'VisualStudio2015Professional v14.0.22823.0-RC' did not i
nstall successfully: The term 'Install-ChocolateyPackage' is not recognized as
the name of a cmdlet, function, script file, or operable program. Check the spe
lling of the name, or if a path was included, verify that the path is correct a
nd try again.
-- list indexes
-- http://stackoverflow.com/a/428235/10245
-- https://gist.github.com/timabell/6da05a2b2542c907f179
select
o.name as TableName,
i.name as IndexName,
i.type,
i.is_unique,
ic.key_ordinal as ColumnOrder,
ic.is_included_column as IsIncluded,