This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#no idea why, but i thought this was kind of funny | |
#get our winform stuff | |
$null = [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | |
$null = [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | |
#move the mouse on x | |
function Nudge($p){ | |
[System.Windows.Forms.Cursor]::Position = ` | |
[System.Drawing.Point]::New( ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Submit-TextFile($filePath,$Uri){ | |
$filename = (Get-ChildItem $filePath).Name | |
$filecontents = Get-Content $filePath -raw | |
$boundary = [guid]::NewGuid().ToString() | |
$contentinfo = "Content-Disposition: form-data; name=`"file`"; filename=`"$filename`"`nContent-Type: text/html; charset=utf-8`n" | |
$body = "--$boundary`n$contentinfo`n$filecontents`n--$boundary--`n" | |
$params = @{ | |
Uri = $Uri | |
Body = $body | |
Method = 'Post' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sb = { | |
do{ #pause while server is starting up | |
$error.Clear() | |
try{ | |
[Net.Sockets.TcpClient]::new('localhost',8080) | |
}catch{ | |
Start-Sleep 1 | |
} | |
}while($error) | |
for ($i = 0; $i -lt $args[1]; $i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#open profile with code $profile or notepad $profile and paste in the following | |
#note you will need to have installed oh-my-posh already | |
#see https://ohmyposh.dev/ for details | |
Import-Module oh-my-posh | |
function Get-ThemeList{ | |
$themeurl = "https://github.com/JanDeDobbeleer/oh-my-posh/tree/main/themes" | |
$ProgressPreference = 'SilentlyContinue' | |
$links = (iwr $themeurl).links | |
$ProgressPreference = 'Continue' | |
($links | where title -like *omp.json).title -Replace ".omp.json","" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import kernel32 calls we need | |
# note screen saver will not enable either | |
# can remove the display required flag to remove that | |
Add-Type -Name n -Namespace ns -MemberDefinition @' | |
[DllImport("kernel32.dll")] | |
public static extern uint SetThreadExecutionState(uint esFlags); | |
public const uint ES_CONTINUOUS = 0x80000000; | |
public const uint ES_SYSTEM_REQUIRED = 0x00000001; | |
public const uint ES_DISPLAY_REQUIRED = 0x00000002; | |
public static string StayAwake(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#moves the mouse x location by offset p pixels | |
function Nudge($p){ | |
[System.Windows.Forms.Cursor]::Position = ` | |
[System.Drawing.Point]::New( ` | |
[System.Windows.Forms.Cursor]::Position.X+$p, ` | |
[System.Windows.Forms.Cursor]::Position.Y ) | |
} | |
#call nudge every 10ms with pos/neg value of x | |
function Jiggle(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is a google script method of getting a client key from stripe | |
// this means you don't have to get a server to take stripe payments because | |
// this can be your server. at the time of this script creation, you are | |
// limited to 20k per month. in order to 'deploy' this you'll have to | |
// go to https://script.google.com/ and create a new script, replace the | |
// body of the initial script file with this and then deploy it as a web app | |
// you'll have to give it the required permissions it asks for the first time | |
// and ensure you set it up for anonymous access. | |
// this function will just return the secret key for the client from stripe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//import or add cdn for global, url should be passed in somehow | |
fetch(url) | |
.then(r=>r.blob()) | |
.then(JSZip.loadAsync) | |
.then(zip=>zip.files[Object.keys(zip.files)[0]].async('string')) | |
.then(JSON.parse) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//bind onclick to downloadcsv. | |
//o should be the json you want to turn into a table | |
//h should be a string array for the header row, or this can be null and it will use the keys from the first record | |
//n is the name of the file, csv will be appended. if omitted it will just be 'data.csv' | |
export const downloadcsv = (o,h,n = 'data') => { | |
downloadFile( toCSV(o,h) , n + '.csv', 'text/csv' ); | |
} | |
const toCSV = (o,h) => { | |
const a = (v) => `"${v.join(`","`)}"` | |
let csv = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//comments in blogpost | |
myoptions.events = [] | |
myoptions.animation = { | |
duration: 0, | |
onComplete: function () { | |
let chartInstance = this.chart | |
let ctx = chartInstance.chart.ctx | |
ctx.textAlign = 'center' | |
function formatLabel(value) { |