Skip to content

Instantly share code, notes, and snippets.

@petervandivier
Last active September 30, 2022 12:40
Show Gist options
  • Select an option

  • Save petervandivier/8220fde5dab0c3bad017d5b9dfefad6a to your computer and use it in GitHub Desktop.

Select an option

Save petervandivier/8220fde5dab0c3bad017d5b9dfefad6a to your computer and use it in GitHub Desktop.
# based on https://dba.meta.stackexchange.com/revisions/3e578461-07e9-46f2-b81d-a5f3e582171a/view-source
Set-Location ~/repos/git/sqlserver-kit
# https://stackoverflow.com/a/43737097/4709762
# $regexUrl='(http[s]?)(:\/\/)([^\s,]+)(?=")'
# https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url
$regexUrl = 'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)'
$allUrls = (Get-ChildItem -Recurse . | Select-String -Pattern $regexUrl).Matches.Value | Select-Object -Unique
$counter=1
$urlStatusCsv = '~/Desktop/url-status.csv'
if(-not (Test-Path $urlStatusCsv)){
Write-Host '"URL,StatusCode"' | Export-Csv $urlStatusCsv
}
$status = Import-Csv $urlStatusCsv
# $status | Export-Csv $urlStatusCsv
$allUrls = $allUrls | Where-Object {$status.URL -notcontains $PSItem}
$status += foreach($url in $allUrls){
Write-Verbose "Testing URL $counter/$($allUrls.Count): $url" -Verbose
$statusCode = try {
(Invoke-WebRequest $url -UseBasicParsing -Method Head).StatusCode
} catch {
$_.Exception.Response.StatusCode.value__
}
$counter++
$row = [PSCustomObject]@{
URL = $url
Status = $statusCode
}
$row | Export-Csv $urlStatusCsv -Append
$row
}
($status | where-object Status -ne 200).Count # 33
# $status | where-object Status -ne 200 | Export-csv ~/Desktop/bad-urls.csv
# Get-ChildItem . -Recurse | Select-String "https://StorageAccount.blob.core.windows.net/Container/FileName.xel" # 'example link'
<#
$updates =@'
[{
"oldLink":"https://github.com/ktaranov/sqlserver-kit/blob/master/Stored_Procedure/sp_BlitzInMemoryOLTP.sql",
"newLink":"https://github.com/ktaranov/sqlserver-kit/blob/master/Stored_Procedure/dbo.sp_BlitzInMemoryOLTP.sql",
"commitMsg":"renamed at 79b1d55 \n https://github.com/ktaranov/sqlserver-kit/commit/79b1d551780aae28117e4bca835ea4d4c180f630"
},
{
"oldLink":"",
"newLink":"",
"commitMsg":""
}]
'@ | ConvertFrom-Json
$updates=$updates| Where-Object {-not [string]::IsNullOrWhiteSpace($_.commitMsg)}
# $updates.Count
function Repair-Link {
param (
[string]$oldLink,
[string]$newLink,
[string]$commitMsg
)
Get-ChildItem -Recurse |
Select-String $oldLink |
Select-Object -Unique -Property Filename |
ForEach-Object {
(Get-Content $_.FileName).replace($oldLink,$newLink) |
Set-Content -LiteralPath $_.FileName
}
git stage .
git commit -m "$commitMsg"
}
$updates | ForEach-Object {
$o = $_.oldLink
$n = $_.newLink
$c = $_.commitMsg
Repair-Link -oldLink $o -newLink $n -commitMsg $c -Verbose
}
git log --pretty=oneline --abbrev-commit
$status | where-object Status -ne 200 | Export-Csv ~/Desktop/los-links-con-carne.csv
#>
Set-Location '~/Desktop/'
$counter=1
$urlStatusCsv = 'sqlserver-kit-bad-urls.csv'
$exportCsv = 'export.csv'
$status = Import-Csv $exportCsv
$testUrls = (Import-Csv $urlStatusCsv).URL | Where-Object {$status.URL -notcontains $PSItem }
$testUrls.Count
$newStatus=foreach($url in $testUrls){
Write-Verbose "Testing URL $counter/$($testUrls.Count): $url" -Verbose
try {
$statusCode = (Invoke-WebRequest $url -UseBasicParsing -TimeoutSec 10).StatusCode
} catch {
$statusCode = $_.Exception.Response.StatusCode.value__
}
$counter++
$row = [PSCustomObject]@{
URL = $url
Status = $statusCode
}
$row | Export-Csv $exportCsv -Append
$row
}
# $newStatus=Import-Csv 'sqlserver-kit-bad-urls.csv'
$newStatus | Where-Object Status -NotIn ("200","301") | Export-Csv $urlStatusCsv
URL Status
https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/blob/dev/Documentation/sp_Blitz%20Checks%20by%20Priority.md. 404
https://www.BrentOzar.com/go/blitztour 404
http://FirstResponderKit.org. 404
https://BrentOzar.com/go/poison/# 400
https://BrentOzar.com/go/nas 404
https://BrentOzar.com/go/planlimits 301
https://BrentOzar.com/go/makeparallel 301
https://BrentOzar.com/go/dbscope 404
https://www.BrenOzar.com/go/azurevm
https://www.brentozar.com/go/rowgoals/ 404
http://www.BrentOzar.com/go/blocking 301
http://www.brentozar.com/go/poison/# 400
https://BrentOzar.com/go/garbage/ 404
https://BrentOzar.com/go/aborted/ 404
https://BrentOzar.com/go/suboptimal/ 404
https://BrentOzar.com/go/maxedout 404
https://StorageAccount.blob.core.windows.net/Container/FileName.xel 400
https://github.com/ktaranov/sqlserver-kit/blob/master/Stored_Procedure/sp_BlitzInMemoryOLTP.sql 404
https://www.BrentOzar.com/go/planlimits 301
https://www.BrentOzar.com/go/makeparallel 301
https://www.BrentOzar.com/go/nas 404
https://www.BrentOzar.com/go/reportservertempdb 301
https://www.BrentOzar.com/go/alerts/ 404
https://www.BrentOzar.com/go/endpoints/ 404
https://www.BrentOzar.com/go/dbscope 404
https://BrentOzar.com/go/blocking 301
https://BrentOzar.com/go/logsize 404
https://BrentOzar.com/go/garbage 301
https://BrentOzar.com/go/freeproccache 404
https://BrentOzar.com/go/ple 404
https://BrentOzar.com/go/aborted 301
https://BrentOzar.com/go/suboptimal 301
https://BrentOzar.com/sql/wait-stats/# 400
URL Status
https://my.visualstudio.com/downloads?q=sql%20server%20developer 203
https://go.microsoft.com/fwlink/?LinkID=799011 302
http://purl.org/dc/elements/1.1/ 303
http://dba.fyicenter.com/Interview-Questions/SYBASE/What_is_Trace_Flag_Definitions_in_Sybase.html#1.3.4#1.3.4 400
https://dba.stackexchange.com/a/141533/107045 400
http://www.w3.org/1999/02/22-rdf-syntax-ns# 400
http://stackoverflow.com/a/10489767/266882 400
https://stackoverflow.com/questions/1324063/generating-random-strings-with-t-sql/1324390#1324390 400
https://stackoverflow.com/a/793362/2298061 400
https://dba.stackexchange.com/a/36578/107045 400
https://stackoverflow.com/a/219740/2298061 400
https://stackoverflow.com/a/52320673/2298061 400
http://www.sqlshack.com/ 403
http://www.databasejournal.com/features/mssql/ 403
http://dallasdbas.com/blog/ 403
https://www.exploit-db.com/ 403
http://usergroup.tv/ 403
http://en.community.dell.com/techcenter/storage/w/wiki/5018.sc-series-technical-documents 403
http://www.imgroup.com/author/stephen-leach/ 403
http://databene.org/databene-benerator 403
https://assets.red-gate.com/products/sql-development/sql-source-control/entrypage/assets/RG_Guide_to_SQL_Server_Dev.pdf 403
https://assets.red-gate.com/offerings/transaction-log-management.pdf 403
http://assets.red-gate.com/products/dba/assets/Accidental_DBA_EBook.zip 403
http://www.databasejournal.com/features/mssql/tsql-coding-style.html 403
http://www.sqlapprentice.net/ 403
http://www.databasejournal.com/features/mssql/article.php/1547551/Troubleshooting-SQL-Server-BackupRestore-Problems.htm 403
http://www.databasejournal.com/features/mssql/article.php/1443351/SQL-Server-65-Some-Useful-Trace-Flags.htm 403
https://www.databasejournal.com/features/mssql/what-to-do-when-you-get-a-cache-is-out-of-date-error-message.html 403
http://referencesource.microsoft.com/symbols 403
http://www.databasejournal.com/features/mssql/how-to-read-a-transaction-log-backup.html 403
http://www.databasejournal.com/tips/how-to-find-out-which-database-object-got-deleted.html 403
https://www.databasejournal.com/tips/how-to-turn-on-instant-file-initialization.html 403
https://www.databasejournal.com/features/mssql/step-by-step-guide-to-migrate-sql-server-data-to-sql-server-2017.html 403
http://sqlapprentice.net 403
http://www.databasejournal.com/features/mssql/which-indexes-are-not-used.html 403
https://github.com/ktaranov/sqlserver-kit/blob/master/LICENSE.md 404
http://blogs.lessthandot.com/index.php/category/datamgmt/dbprogramming/mssqlserver/ 404
http://www.madeiradata.com/blog/ 404
http://www.sqldownunder.com/Podcasts 404
https://www.brentozar.com/archive/2016/01/video-free-training-of-the-week-number-and-date-tables/ 404
https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2012/cc707787 404
https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/cc707787 404
https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008/cc707787 404
https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2005/ms143532 404
https://sqldownunder.com/sdu-tools/ 404
http://blogs.lessthandot.com/index.php/tag/biml/ 404
http://blog.in2bi.eu/biml/ 404
https://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/06/21/huge-collection-of-free-microsoft-sql-server-ebooks 404
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms722784 404
http://www.microsoftstore.com/store/msusa/en_US/pdp/SQL-Server-2014-Standard-Edition/productID.298540100 404
https://www.codykonior.com/categories/#sql 404
http://blogs.lessthandot.com/index.php/author/grrlgeek/ 404
http://www.sqlservercentral.com/Authors/Scripts/Sean_Smith/776614/ 404
https://the.agilesql.club/Blogs/Ed-Elliott/ 404
https://twitter.com/drayhammer 404
https://github.com/ktaranov/sqlserver-kit/Errors/Identity_gap_sql_server_2012.sql 404
http://www.stillhq.com/sqldownunder/archives/msg05089.html 404
http://forum.proxmox.com/threads/15844-Win7-x64-guest-with-SQLServer-2012-High-CPU-usage 404
http://www.theboreddba.com/Categories/FunWithFlags/Revealing-Predicates-in-Execution-Plans- 404
http://webcache.googleusercontent.com/search?q=cache:Nttlt2Dp8egJ:blogs.msmvps.com/gladchenko/2009/08/21/sql_trace_flags_tpc-c/+&cd=6&hl=en&ct=clnk&gl=ru 404
http://sqlblog.com/blogs/paul_white/archive/2011/09/21/how-to-find-the-statistics-used-to-compile-an-paul_white 404
http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-85-48-files/0827.testing-and-developing-supportability-roadmaps-for-isv-applications.pdf 404
https://medium.com/@rusanu/why-i-have-high-hopes-for-the-quality-of-sql-server-2016-release-6173bc1fbc82#.44kg2ktmg 404
https://www.microsoft.com/en-us/download/details.aspx?id=52679 404
https://www.microsoft.com/en-us/download/details.aspx?id=46697 404
http://www.microsoft.com/downloads/details.aspx?FamilyID=CB6C71EA-D649-47FF-9176-E7CAC58FD4BC 404
http://www.microsoft.com/downloads/details.aspx?FamilyId=d07219b2-1e23-49c8-8f0c-63fa18f26d3a 404
http://www.microsoft.com/downloads/details.aspx?FamilyId=ae7387c3-348c-4faa-8ae5-949fdfbe59c4 404
http://www.microsoft.com/downloads/details.aspx?FamilyId=b953e84f-9307-405e-bceb-47bd345baece 404
http://msdn.microsoft.com/en-us/subscriptions/downloads/details/default.aspx?pm=pid%3a334 404
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b953e84f-9307-405e-bceb-47bd345baece 404
http://www.littlekendra.com/downloads/get-the-sqlindexworkbook-database/ 404
http://insiders.sqldownunder.com/ssms-tips-and-tricks/ 404
http://www.sqlservercentral.com/blogs/sql-geek/2018/07/26/save-the-connection-string-parameters-in-ssms-alwayson/ 404
http://www.williamdurkin.com/ 404
https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/blob/dev/sp_BlitzRS.sql 404
https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/blob/dev/sp_BlitzTrace.sql 404
https://github.com/ktaranov/sqlserver-kit/blob/master/Stored_Procedure/usp_BulkUpload.sql 404
https://sqlworkbooks.com/course/sql-server-management-studio-shortcuts-secrets/ 404
http://www.williamdurkin.com/2017/03/presenting-presentation-mode/ 404
http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet 404
http://schemas.microsoft.com/winfx/2006/xaml 404
http://www.sqlservercentral.com/blogs/confessions-of-a-microsoft-addict/2016/11/10/query-tuning-101-problems-with-in-/ 404
http://www.madeiradata.com/datediff-vs-dateadd/ 404
http://www.madeiradata.com/availability-group-sql-server-2016/ 404
http://www.davewentzel.com/content/alter-schema-transfer-zero-downtime-database-upgrades 404
https://red9.com/blog/sql-server-installation-checklist/ 404
http://www.cjsommer.com/2017-03-01-sql-browser-what-is-it-good-for-absolutely-something/ 404
http://www.karaszi.com/SQLServer/info_datetime.asp 404
http://www.sqlservercentral.com/articles/Azure+SQL+Data+Warehouse+ 404
http://www.nielsberglund.com/2017/08/29/microsoft-sql-server-r-services-internals-x/ 404
https://sqlquantumleap.com/2017/12/11/which-collation-is-used-to-convert-nvarchar-to-varchar-in-a-where-condition-part-b-of-2-rabbit/#comments 404
https://red9.com/sql-server-error-log-location/ 404
https://sqlquantumleap.com/2018/04/04/the-uni-code-the-search-for-the-true-list-of-valid-characters-for-t-sql-regular-identifiers-part-2/ 404
https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms191160 404
https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2005/administrator/cc966545 404
https://pubs.vmware.com/srm-60/index.jsp 404
http://www.vmware.com/files/pdf/performance_char_vmfs_rdm.pdf 404
http://www.bluemedora.com/wp-content/uploads/2015/06/vROps-MP-MSSQL-Server-June-2015.pdf 404
http://www.microsoft.com/downloads/info.aspx?na=22&amp 404
https://ola.hallengren.com/scripts/CommandLog.sql. 404
https://ola.hallengren.com/scripts/CommandExecute.sql. 404
https://ola.hallengren.com/sql-server-backup.html. 404
https://ola.hallengren.com/sql-server-integrity-check.html. 404
https://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html. 404
http://www.sqlapprentice.net/contact/ 404
http://www.sqlapprentice.net/license/ 404
http://www.sqlapprentice.net/category/baseline/ 404
https://github.com/ktaranov/sqlserver-kit/blob/master/Stored_Procedure/sp_BlitzInMemoryOLTP.sql 404
http://tempuri.org/TracePersistence.xsd 404
http://weblogs.sqlteam.com/billg/archive/2011/02/15/generate-merge-statements-from-a-table.aspx 404
https://github.com/ktaranov/sqlserver-kit/blob/master/dbo.sp_Snapshot.sql 404
http://www.icao.int/publications/Documents/9303_p1_v1_cons_ru.pdf 404
https://github.com/ktaranov/sqlserver-kit/blob/master/Stored_Procedure/usp_TransliterationEN2RU.sql 404
https://github.com/ctrlbold/dbatools/blob/master/Functions/CsvSqlimport.ps1 404
http://mnadobnik.pl/format-sqlcode 404
https://sqldbawithabeard.com/2016/03/28/using-powershell-to-set-extended-events-sessions-to-autostart/#comments 404
https://github.com/ktaranov/sqlserver-kit/blob/master/Powershell/Scripting_Out_SQL_Server_Data_As_Insert_Statements.ps1 404
https://1drv.ms/x/s 404
https://WaterOxConsulting.com/eula 404
https://www.microsoft.com/en-us/download/details.aspx?id=7558 404
http://databasehealth.com/schemadrift/ 404
https://www.microsoft.com/en-us/download/details.aspx?id=15691 404
http://sualeh.github.io/SchemaCrawler/index.html 404
https://dilmsuite.com/downloads/cat-compare-v2 404
https://dilmsuite.com/downloads/ssis-catalog-compare-v2-bundle 404
http://www.sqlservercentral.com/blogs/the-sql-professor/2017/01/26/backuprestorewhats-my-status/ 404
http://sqlskills.com/blogs/glenn/ 404
http://www.sqlservercentral.com/scripts/Data+Dictionary/167354/ 404
http://www.sqlservercentral.com/scripts/Foreign+Keys+%28FK%29/97811/ 404
http://www.madeiradata.com/cost-threshold-for-parallelism-and-how-to-increase-it-properly/ 404
http://www.sqlservercentral.com/scripts/Restore/140540/ 404
http://blog.waynesheffield.com/waye/code-library/deadlocks/shred-deadlock-graph/ 404
http://www.microsoft.com/en-us/download/details.aspx?id=7218 404
http://www.sqlservercentral.com/blogs/sqlrnnr/2016/12/23/what-agent-job-is-running-back-to-basics/ 404
http://www.nielsberglund.com/2018/06/24/sp-execute-external-script-and-permissions/ 404
http://www.sqlservercentral.com/questions/163450/ 404
http://www.sqlservercentral.com/blogs/martin_catherall/2017/01/22/create-database-ive-not-seen-that-before/ 404
http://www.sqlservercentral.com/scripts/Set+Based/139370/ 404
http://www.sqlservercentral.com/Forums/Topic1585850-391-2.aspx#bm1629360 404
http://www.sqlservercentral.com/scripts/Calculate+Distance/118083/ 404
http://www.codeproject.com/Articles/13525/Fast-memory-efficient-Levenshtein-algorithm. 404
http://www.sqlservercentral.com/scripts/Tally+Table/99617/ 404
https://promptformatapi.red-gate.com/api/format/ 405
http://www.bidn.com/Videos/Videos 410
http://sql2014.pl/docs/SQL_Server_2014_Licensing_Guide.pdf 410
http://www.bidn.com/Blogs/userid/43/author/mike-milligan 410
http://www.bidn.com/blogs/MMilligan/bidn-blog/3326/sql-server-management-studio-ssms-tips-and-tricks 410
http://midnightdba.itbookworm.com/ 500
http://midnightdba.itbookworm.com/Show 500
https://www.devart.com/dbforge/sql/search/searchsql22std.exe 500
https://www.linkedin.com/in/seanmsmith/ 999
http://sqlmag.com/
https://www.punkspider.org/
https://learnfrom.brentozar.com/courses/how-to-think-like-the-engine-an-introduction-to-sql-server-internals/
https://learnfrom.brentozar.com/
http://www.e-squillace.com/tech/techdiagrams/#SQL_Server
http://www.frysdisken.net/
http://extras.sqlservercentral.com/prettifier/prettifier.aspx
http://sqlmag.com/scaling-success-sql-server-2016/overview-sql-server-2016-licensing
https://chrisadkin.org/2015/04/14/well-known-and-not-so-well-known-sql-server-tuning-knobs-and-switches
https://chrisadkin.org/2015/04/14/well-known-and-not-so-well-known-sql-server-tuning-knobs-and-switches/
http://www.sqlmag.com/article/tsql3/making-the-most-of-automatic-statistics-updating--96767
http://sqlmag.com/sql-server/investigating-trace-flags
http://sqlmag.com/sql-server/what-you-need-know-about-batch-mode-window-aggregate-operator-sql-server-2016-part-1
http://www.microsoft.com/downloads/details.aspx?FamilyId=AE7387C3-348C-4FAA-8AE5-949FDFBE59C4
http://sqlmag.com/sql-server/symbolic-links-sharing-template-files-or-how-i-broke-management-studio-symbolic-links
http://sqlmag.com/t-sql/generating-charts-and-drawings-sql-server-management-studio
http://sqlmag.com/database-performance-tuning/introduction-index-operational-statistics-dynamic-management-function
http://sqlmag.com/sql-server/sql-server-2016-upgrade-planning-0
https://blogs.sqlsentry.com/aaronbertrand/backtobasics-updated-kitchen-sink-example/
http://sqlmag.com/sql-server/parallelism-sql-server-query-tuning
http://sqlmag.com/database-security/what-every-accidental-dba-needs-know-now-basics-sql-security
http://sqlmag.com/sql-server/logical-query-processing-what-it-and-what-it-means-you
http://sqlmag.com/t-sql/table-variable-tip
http://sqlmag.com/sql-server/sql-server-query-optimization-no-unknown-unknowns
http://sqlmag.com/sql-server/packing-intervals-priorities
http://sqlmag.com/t-sql/avoid-unnecessary-lookups-when-using-rownumber-paging
http://sqlmag.com/sql-server/identifying-existence-intersections-intervals
http://sqlmag.com/database-administration/dont-panic-busting-file-space-myth
http://sqlmag.com/sql-server/configuring-r-sql-server-2016
http://sqlmag.com/software-development/puzzle-challenge-graph-matching-t-sql-part-1-concepts
http://ns.adobe.com/pdf/1.3/
http://ns.adobe.com/xap/1.0/
http://ns.adobe.com/xap/1.0/mm/
http://www.sqlmag.com/
http://www.aspfaq.com/show.asp?id=2120
http://sqlmag.com/sql-server/best-free-sql-server-tool-2013
http://sqlmag.com/sql-server/2012-sql-server-pro-editors-best-and-community-choice-awards
http://sqlmag.com/sql-server/2011-sql-server-magazine-editors-best-and-community-choice-awards
http://sqlmag.com/sql-server/2010-sql-server-magazine-editors-best-and-community-choice-awards
http://wwwservercentral.com/scripts/sp_who/68607/
http://www.schiffhauer.com/c-split-csv-values-with-a-regular-expression/
http://www.alaskasql.org/Blog/Post/35/Audit-All-SQL-User-Security-with-PowerShell
https://software.dell.com/products/toad-data-modeler/
http://www.manduka.tech/#/home
https://sqletl.com
http://sqlmag.com/database-administration/how-set-sql-server-database-mail-one-easy-script
http://sqlmag.com/database-administration/estimate-when-long-running-sql-processes-will-finish
http://sqlmag.com/database-backup-and-recovery/how-old-are-your-backups
http://sqlmag.com/security/identifying-sql-server-logins-without-default-database-users
http://sqlmag.com/database-security/identifying-logins-default-database-connectivity-issues-sql-server
https://www.sqlserverperformance.wordpress.com/
@petervandivier
Copy link
Author

@petervandivier
Copy link
Author

examples like "http://FirstResponderKit.org." are bad hits on the regex but obvious enough to ignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment