Skip to content

Instantly share code, notes, and snippets.

@ninmonkey
ninmonkey / divinggear-verbose.json
Last active July 15, 2020 16:05
test for mapping xml to json
{
"divingmask": {
"PreferredContainer": [
"System.Collections.Hashtable",
"System.Collections.Hashtable"
],
"Attrs": {
"category": "Equipment",
"impactsoundtag": "impact_metal_light",
"identifier": "divingmask",
@ninmonkey
ninmonkey / Table To JSON.pq
Last active July 26, 2020 13:28
random powerquery examples
let
/*
Convert any table to JSON
*/
// variables for later:
args = [
MaxDateCutoff = #date(2010, 1, 5),
InvalidDate = #date(2000, 1, 1),
@ninmonkey
ninmonkey / minimal web query.pq
Last active July 31, 2020 19:08
Basic structure for web apis
let
// for the url: https://mods.factorio.com/api/mods?page_size=10&size=5
//you would use:
request_blob = Web.Contents(
"https://mods.factorio.com/api",
[
RelativePath = "/mods",
Query = [ page_size = "10", page = "5"]
]
),
@ninmonkey
ninmonkey / Dropbox request using Invoke-WebRequest.ps1
Last active August 4, 2020 17:03
Dropbox request using Invoke-WebRequest
$oauth_token = "your token here"
function ExampleRequest {
<#
.synopsis
example that uses the Dropbox API: '/files/list_folder'
.notes
See also:
Invoke-RestMethod
Docs:
@ninmonkey
ninmonkey / printing ansi colors in powershell.ps1
Created August 5, 2020 00:00
print ansi colors using powershell
function AnsiColor([int]$AnsiNumber) {
<#
.synopsis
Outputs a 3/4-bit ansi color sequence
color '0' resets to the default color
(Currently the integrated terminal has a width bug. Windows terminal works)
#>
"`e[", $AnsiNumber, 'm' -join ''
}
@ninmonkey
ninmonkey / from 1.3 preview.jsonc
Last active June 24, 2021 14:21
new windows terminal config
[
/* for more see the series:
- https: //devblogs.microsoft.com/commandline/windows-terminal-preview-1-3-release/
- https: //devblogs.microsoft.com/commandline/windows-terminal-preview-1-2-release/
- https: //devblogs.microsoft.com/commandline/windows-terminal-preview-1-1-release/
*/
/* vs code -like palette, shows hotkeys if you need a reference */
{
@ninmonkey
ninmonkey / Format-ADUser.ps1
Created September 1, 2020 13:35
Nicer ActiveDirectory output
function Format-ADUser {
<#
.synopsis
Make ADUser data readable in a console
.example
$me = Get-ADUser identity -property *
$me | Format-ADUser
$me | Format-ADUser Medium
@ninmonkey
ninmonkey / Convert Images to embeded Images in a PowerBI DAX Measure.ps1
Last active September 18, 2021 16:56
Embed images inside Power BI Reports ( DAX with inline base64 images)
<#
You can convert to base64 using this website:
https://www.browserling.com/tools/image-to-base64
This runs on 'PowerShell'
( It requires changes to run on 'Windows Powershell' (legacy) )
For usage jump to the very last lines in this file:
> $config = $runKwargs.DaxPng
@ninmonkey
ninmonkey / Output.log
Created September 4, 2020 12:52
Run and log commands.ps1
## 1 ##
Label: Find, then count lines
Command:
find.exe | wc.exe -l
@ninmonkey
ninmonkey / Get-PlatformPathFolder.ps1
Last active June 24, 2021 14:15
comparing GetFolderPath per platform
function Export-PlatformFolderPath {
<#
.description
compare results of [Environment]::GetFolderPath() across different platforms and versions
#>
param(
[Parameter(HelpMessage = 'skip converting to json')][switch]$PassThru
)
$folderList = [enum]::GetNames( [System.Environment+SpecialFolder] ) | ForEach-Object {