Skip to content

Instantly share code, notes, and snippets.

learn Unreal Engine 5 (UE5 https://www.unrealengine.com) - free pro software, this is what the industry uses now
get it from the Epic Games Launcher https://store.epicgames.com/
do projects alone at first. take time to learn the basics. multiplayer is always more complicated.
buying asset store projects is an unreasonably effective way to learn https://www.unrealengine.com/marketplace
learning projects should be simple enough to finish.
blueprints is a programming language for games used by UE5. Many games are possible using only blueprints code. start by searching for “beginner blueprint tutorials ue5”
find a good place to ask questions, like a Discord community or https://forums.unrealengine.com/
# This will register a new job that removes itself from Get-ScheduledJob when finished
$Trigger = New-JobTrigger -Once -At (Get-Date).AddSeconds(3)
$TaskName = "SelfDestructingJob"
Register-ScheduledJob -Trigger $Trigger -Name $TaskName `
-ScriptBlock ([scriptblock]::Create(@"
("Started job at " + (Get-Date) + ", waiting...") | Out-File -FilePath 'C:\ProofThatItWorks.txt'
Start-Sleep 3
("Finished at " + (Get-Date)) | Out-File -Append -FilePath 'C:\ProofThatItWorks.txt'
Unregister-ScheduledJob -Name '$TaskName' -Force
@karlgluck
karlgluck / WaitForScheduledTaskExample.ps1
Last active May 15, 2022 21:18
Example of how to wait for a scheduled task to finish running
$Trigger = New-JobTrigger -Once -At (get-date).AddSeconds(5)
$JobOptions = New-ScheduledJobOption -StartIfOnBattery -RunElevated
$Job = Register-ScheduledJob -Name "TaskName" -Trigger $Trigger -ScheduledJobOption $JobOptions `
-ScriptBlock {
Sleep 5
}
# From https://docs.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-error-and-success-constants?redirectedfrom=MSDN
Set-Variable -Name "SCHED_S_TASK_HAS_NOT_RUN" -Value 0x00041303 -Option Constant
@karlgluck
karlgluck / RunAtLoginExample.ps1
Created May 15, 2022 19:02
How to register a script block to run with elevated privileges when the current user logs in
$JobName = "RunAtLoginExample"
$Enabled = $True # set to $False and run to remove the job
# https://stackoverflow.com/questions/40569045/register-scheduledjob-as-the-system-account-without-having-to-pass-in-credentia
# Output: %LOCALAPPDATA%\Microsoft\Windows\PowerShell\ScheduledJobs\$JobName
$accountId = ((Get-WMIObject -class Win32_ComputerSystem | Select-Object -ExpandProperty username))
$Trigger = New-JobTrigger -AtLogOn
$JobOptions = New-ScheduledJobOption -StartIfOnBattery -RunElevated
@karlgluck
karlgluck / CreatePathIfDoesntExistExample.ps1
Created May 14, 2022 19:57
One-liner to create a path if it doesn't exist
if (-not (Test-Path $Path)) { New-Item $Path -ItemType Directory | Out-Null }
@karlgluck
karlgluck / ExtractFileFromZipExample.ps1
Created May 14, 2022 17:46
How to extract a single file from a ZIP archive using Powershell
$ZipFilePath = ""
$FileNameInZip = ""
Add-Type -AssemblyName System.IO.Compression.FileSystem
$Zip = [System.IO.Compression.ZipFile]::OpenRead($ZipFilePath)
$Zip.Entries |
Where-Object { $_.Name -eq $FileNameInZip } |
ForEach-Object {
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $_.Name, $true)
@karlgluck
karlgluck / DownloadFromPrivateGitHubRepoExample.ps1
Created May 14, 2022 17:32
One-liner for downloading from a private GitHub repository
# Fill these in with your own values
$Username = "your_username"
$Branch = "main"
$PathToFile = "README.md"
# Go to [https://github.com/settings/tokens] and add a Personal Access Token with two scopes: "repo" and "read:org"
$GitHubAuthToken = "ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
Invoke-WebRequest -Method Get -Uri "https://raw.githubusercontent.com/$Username/$Repository/$Branch/$PathToFile" -Headers @{Authorization="token $GitHubAuthToken"; 'Cache-Control'='no-cache'} | ForEach-Object { $_.Content } | Write-Host
@karlgluck
karlgluck / RoombaVictory.ps1
Created September 18, 2019 00:55
Play the Roomba's victory jingle using the Powershell beep. Because why not?
[console]::beep(260,200)
[console]::beep(320,200)
[console]::beep(380,150)
[console]::beep(520,200)
Start-Sleep -Milliseconds 200
[console]::beep(520,150)
[console]::beep(700,800)
@karlgluck
karlgluck / PerfectPixelCamera.cs
Created September 13, 2018 22:35
Main file from the Perfect Pixel Camera asset on the Unity asset store, licensed with MIT https://assetstore.unity.com/packages/tools/camera/perfect-pixel-camera-by-gg-ez-100000
// Copyright 2018 Karl Gluck
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
private static Vector3 ViewportToWorldPointUnity (Vector3 point, float fieldOfView, float aspect, Vector3 from, Vector3 to, Vector3 up)
{
// The zNear / zFar magic numbers are what Unity's viewport always uses regardless of camera settings
var matP = Matrix4x4.Perspective (fieldOfView, aspect, 0.6f /* zNear */, 1000f /* zFar */);
// For some reason we have to reverse these coordinates
from = -from;
to = -to;