Skip to content

Instantly share code, notes, and snippets.

View dhcgn's full-sized avatar

Daniel dhcgn

View GitHub Profile
@dhcgn
dhcgn / encrypt-text.ps1
Last active September 2, 2023 08:50
Encrypt Test (String) with age in Powershell
# Change key to your key or run age-keygen
$key = "age1x9papwe3rsptzkfvet95yk0e5gaf4nk99yq6wr9azydk9c0lay4q76yzwg"; $content = Read-Host -MaskInput; $temp = New-TemporaryFile; Set-Content -Value $content -Path $temp; age -e -a -r $key $temp; Remove-Item $temp
@dhcgn
dhcgn / Einfache Offline Sandbox.wsb
Last active August 2, 2023 12:34
Check Windows Sandbox Requirement
<Configuration>
<LogonCommand>
<Command>powershell -executionpolicy unrestricted -command "start powershell {-NoExit -NoLogo -NoProfile}"</Command>
</LogonCommand>
</Configuration>
@dhcgn
dhcgn / Program.cs
Created July 20, 2023 12:01
Teach Linq
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
var apples = new List<Apple>(){
new Apple(){Color = "Red", Weight = 100},
new Apple(){Color = "Green", Weight = 200},
new Apple(){Color = "Yellow", Weight = 300},
new Apple(){Color = "Red", Weight= 400},
new Apple(){Color = "Blue", Weight = 500},
};

System

You're a mean but entertaining Programmer making code reviews.

Question

Please review this code:

	dnsServerIP := "8.8.8.8"
@dhcgn
dhcgn / readme.md
Created March 28, 2023 07:26
Write a DNS Client for only A-Records in Go, avoid using the built-in resolver.

Here's a minimal DNS client in Go that only supports A-records and avoids using the built-in resolver. It uses UDP to communicate with a DNS server to query A-records and outputs the results.

package main

import (
	"encoding/binary"
	"fmt"
	"net"
	"os"
@dhcgn
dhcgn / audio-to-text.ps1
Last active March 24, 2023 21:14
Create a transcriptions from a file with OpenAI with Powershell
<#
Documentation
https://platform.openai.com/docs/api-reference/audio/create#audio/create-prompt
Better results if you set prompt or/and language
$body = @{ file = Get-Item $filePath; model = "whisper-1"; prompt = "Dies ist eine Kindergeschichte."; language = "de" }
#>
$filePath = "C:\temp\video.mp4" # can be mp3, mp4, mpeg, mpga, m4a, wav, or webm. But max 25 MB
$TOKEN = "" # Create one here https://platform.openai.com/account/api-keys
@dhcgn
dhcgn / run-age-demo.ps1
Created March 17, 2023 09:01
Spielwiese für die Verwendung von age
# 1. Download https://github.com/FiloSottile/age/releases/download/v1.1.1/age-v1.1.1-windows-amd64.zip
# 2. Extract content to folder
# 3. Move to folder (e.g. cd c:\temp)
# 4. Execute Script
.\age-keygen.exe -o secret_key.txt
$pubkey = .\age-keygen.exe -y .\secret_key.txt
Set-Content .\mein_geheimis.txt -Value "Hallo Welt!"
Get-Content .\mein_geheimis.txt
.\age -e -r $pubkey -o .\mein_geheimis.txt.age .\mein_geheimis.txt
@dhcgn
dhcgn / README.md
Last active January 15, 2023 19:06
Daniels Skripte für seinen Workflow mit Fotos

Workflow

Devices/Infrastruture

  1. DSLM with Wifi
  2. FTP Server
  3. Google Photos or Synology Photos

Software

@dhcgn
dhcgn / convert.ps1
Created January 11, 2023 10:01
Convert images to jpg using ImageMagick
<#
.Description
Convert images to jpg using ImageMagick
Need to download https://imagemagick.org/archive/binaries/ImageMagick-7.1.0-57-portable-Q16-x64.zip and extract archive to a folder,
$PathToImageMagick should point to the magick.exe file
.Example
convert.ps1 -PathToImageMagick 'C:\Local\Downloads\magick\magick.exe' -SourceFolder 'C:\temp\source' -TargetFolder 'C:\temp\target'
#>
@dhcgn
dhcgn / takesover.ps1
Created December 28, 2022 20:47
Take over files on windows
icacls <foldername> /grant administrators:F /T
takeown /f <foldername> /r /d y