Skip to content

Instantly share code, notes, and snippets.

View matt40k's full-sized avatar

Matt Smith matt40k

View GitHub Profile
@matt40k
matt40k / 40k.md
Created June 10, 2023 21:11
Warhammer 40,000 10th edition notes
Name Description
Critical Hit Unmodified 6 to hit
Critical Wound Unmodified 6 to wound

Shooting

Name Description
Heavy +1 to hit if remained stationary
@matt40k
matt40k / email.csv
Created April 2, 2023 21:03
Common user mistakes entering email addresses
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
gmai.com|gmail.com
gmail.colm|gmail.com
gmail.coml.com|gmail.com
gmail.on|gmail.com
gmal.com|gmail.com
goglemail.com|googlemail.com
homail.com|hotmail.com
htmail.com|hotmail.com
@matt40k
matt40k / wahapediaDownload.ps1
Created April 24, 2022 19:40
Download the Wahapedia CSV exports
$baseUri = "http://wahapedia.ru/wh40k9ed/"
$r = (Invoke-WebRequest -Uri "$($baseUri)Last_update.csv" -UseBasicParsing).Content | ConvertFrom-Csv -Delimiter "|" -Header "last_update" | Select-Object -Skip 1
$lastUpdated = $r.last_update
$factions = (Invoke-WebRequest -Uri "$($baseUri)Factions.csv" -UseBasicParsing).Content | ConvertFrom-Csv -Delimiter "|" -Header "id", "name", "link" | Select-Object -Skip 1
$datasheets = (Invoke-WebRequest -Uri "$($baseUri)Datasheets.csv" -UseBasicParsing).Content | ConvertFrom-Csv -Delimiter "|" -Header "id", "name", "link", "faction_id", "source_id", "role", "unit_composition", "transport", "power_points", "priest", "psyker", "open_play_only", "crusade_only", "virtual", "cost_per_unit", "Cost" | Select-Object -Skip 1
$wargear = (Invoke-WebRequest -Uri "$($baseUri)Wargear_list.csv" -UseBasicParsing).Content | ConvertFrom-Csv -Delimiter "|" -Header "id", "name", "type", "description", "source_id", "is_relic", "faction_id", "legend" | Select-Object -Skip 1
$datasheetWargear =
@matt40k
matt40k / image.m
Created October 10, 2021 11:08
PowerQuery M code for scrapping the Raspberry PI image stats
let
Source = Web.BrowserContents("https://rpi-imager-stats.raspberrypi.org"),
#"Extracted Table From Html" = Html.Table(Source, {{"Column1", "DIV.row:nth-child(3) > DIV.col-sm:nth-child(1) > TABLE.table.mt-4 > * > TR > :nth-child(1)"}, {"Column2", "DIV.row:nth-child(3) > DIV.col-sm:nth-child(1) > TABLE.table.mt-4 > * > TR > :nth-child(2)"}}, [RowSelector="DIV.row:nth-child(3) > DIV.col-sm:nth-child(1) > TABLE.table.mt-4 > * > TR"]),
#"Promoted Headers" = Table.PromoteHeaders(#"Extracted Table From Html", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Image", type text}, {"Percentage", Percentage.Type}}),
#"Add Timestamp" = Table.AddColumn(#"Changed Type", "Timestamp", each DateTime.LocalNow(), type datetime)
in
#"Add Timestamp"
@matt40k
matt40k / googlepbi.ps1
Created March 23, 2021 23:03
Simple PowerShell script to use the Google Search API to search for public Power BI reports
$apikey = ""
$baseUri = "https://www.googleapis.com/customsearch/v1"
$cx = ""
$query = "site:https://app.powerbi.com"
function GetSearchResults([string]$start)
{
$uri = "$($baseUri)?key=$($apikey)&cx=$($cx)&q=$($query)&start=$($start)"
$c = Invoke-WebRequest -Uri $uri -UseBasicParsing -Method Get
@matt40k
matt40k / TabularEditor.ps1
Created October 8, 2020 15:52
Latest TabularEditor
# Download URL for the latest Tabular Editor portable:
$TabularEditorUrl = Invoke-RestMethod -uri https://api.github.com/repos/otykier/TabularEditor/releases/latest | select -ExpandProperty assets | select -expand browser_download_url | ? { $_.Contains("Portable")}
# Download destination (root of PowerShell script execution path):
$DownloadDestination = join-path (get-location) "TabularEditor.zip"
# Download from GitHub:
Invoke-WebRequest -Uri $TabularEditorUrl -OutFile $DownloadDestination
# Unzip Tabular Editor portable, and then delete the zip file:
@matt40k
matt40k / Cleanup.ps1
Last active June 22, 2021 21:09
Laptop scripts
$removeList = (Invoke-WebRequest -Uri https://gist.githubusercontent.com/matt40k/92b2aefd89f0002c0617cb1c5c9404e0/raw/RemoveList.txt -UseBasicParsing).Content
foreach ($removeItem in $removeList)
{
Write-Host $removeItem
Get-appxpackage $removeItem.Trim() -AllUsers | Remove-appxpackage -AllUsers
}
$chromeExe = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"'
$outputDir = "C:\Temp\"
function GetScreenshot($fileName, $url)
{
$command = @'
cmd.exe /C $chromeExe --headless --disable-gpu --screenshot="$outputDir\$fileName.png" --window-size=1920,1024 $url
'@
Invoke-Expression -Command:$command
}
@matt40k
matt40k / sqlFromRDL.ps1
Created May 15, 2019 09:46
Extract T-SQL code from multiple RDL files by Arvind Shyamsundar (arvindsh@microsoft.com)
<#
.SYNOPSIS
Extract T-SQL code from multiple RDL files
.NOTES
Author : Arvind Shyamsundar (arvindsh@microsoft.com)
.PARAMETERS
-RootFolder: full path to the root folder which contains the RDL files
-Recurse: whether to search sub folders or not