Skip to content

Instantly share code, notes, and snippets.

View TheRockStarDBA's full-sized avatar
🏠
Working from home

Kin Shah TheRockStarDBA

🏠
Working from home
View GitHub Profile
@chitchcock
chitchcock / 20111011_SteveYeggeGooglePlatformRant.md
Created October 12, 2011 15:53
Stevey's Google Platforms Rant

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

DECLARE @FileName NVARCHAR(4000)
SELECT @FileName =
LEFT(target_data.value('(EventFileTarget/File/@name)[1]','nvarchar(4000)') ,
CHARINDEX('system_health',target_data.value('(EventFileTarget/File/@name)[1]','nvarchar(4000)') )-1) + 'system_health*.xel'
FROM (
SELECT
CAST(target_data AS XML) target_data
@TheRockStarDBA
TheRockStarDBA / sp_whoisactive.sql
Last active July 29, 2019 08:39
sp_whoisactive - from Adam Machanic
--- download it from http://sqlblog.com/files/folders/release/tags/who+is+active/default.aspx
EXEC sp_WhoIsActive
@filter = '',
@filter_type = 'session',
@not_filter = '',
@not_filter_type = 'session',
@show_own_spid = 0,
@show_system_spids = 0,
@show_sleeping_spids = 1,
@get_full_inner_text = 1,
function Invoke-DbaDBRestoreSeeding
{
<#
.SYNOPSIS
Syncs 2 databases ready for database mirroring or Availability Group setup
.DESCRIPTION
Scans the database backup history on the Source SQL Instance, and restores them onto the source Instance
If more transanction backups occur before the restores complete, these will then be applied afterwards.
The function may also be used to resume an already partially restored databas as long as it's based on the same full database backup chain
function Invoke-DbaDBRestoreSeeding
{
<#
.SYNOPSIS
Syncs 2 databases ready for database mirroring or Availability Group setup
.DESCRIPTION
Scans the database backup history on the Source SQL Instance, and restores them onto the source Instance
If more transanction backups occur before the restores complete, these will then be applied afterwards.
The function may also be used to resume an already partially restored databas as long as it's based on the same full database backup chain
@refactorsaurusrex
refactorsaurusrex / appendAllLines.ps1
Last active August 1, 2023 12:53
How to call 'File.AppendAllLines' with PowerShell
$path = 'C:\text.txt'
$output = 'This is an output string'
# This works...
[System.IO.File]::WriteAllLines($path, $output)
# But this doesn't. WTF!
[System.IO.File]::AppendAllLines($path, $output)
# Result: 'Cannot find an overload for "AppendAllLines" and the argument count: "2".'
@nohwnd
nohwnd / Uninstall-Pester.ps1
Last active March 14, 2024 13:57
Remove built-in version of Pester 3 (or -All) from Windows 10 Program Files and Program Files (x86).
#Requires -RunAsAdministrator
function Uninstall-Pester ([switch]$All) {
if ([IntPtr]::Size * 8 -ne 64) { throw "Run this script from 64bit PowerShell." }
#Requires -RunAsAdministrator
$pesterPaths = foreach ($programFiles in ($env:ProgramFiles, ${env:ProgramFiles(x86)})) {
$path = "$programFiles\WindowsPowerShell\Modules\Pester"
if ($null -ne $programFiles -and (Test-Path $path)) {
if ($All) {
@TheRockStarDBA
TheRockStarDBA / Get-AmIPwned.ps1
Created February 22, 2018 03:49 — forked from lzybkr/Get-AmIPwned.ps1
Script to query passwords reported to haveibeenpwned.com
<#
.SYNOPSIS
Reports if your password is pwned by querying haveibeenpwned.com
.DESCRIPTION
Query haveibeenpwned.com to see if a password has appeared in a breach.
The query sends the first 5 characters of the SHA1 hash, so the query should be considered safe and anonymous.
@TheRockStarDBA
TheRockStarDBA / latency.txt
Created September 5, 2018 15:24 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@haranjackson
haranjackson / scrapy_lambda_layer.sh
Last active May 7, 2022 09:24
Deploys Python Scrapy library to an AWS Lambda layer. You can specify the region, library version, and runtime.
REGION=eu-west-1
VER=1.7.3
RUNTIME=python3.7
docker run -v $(pwd):/out -it lambci/lambda:build-$RUNTIME \
pip install scrapy==$VER -t /out/build/scrapy/python
cd build/scrapy
zip -r ../../scrapy.zip python/
cd ../..