Skip to content

Instantly share code, notes, and snippets.

View marcgeld's full-sized avatar

Marcus Gelderman marcgeld

View GitHub Profile
@marcgeld
marcgeld / psRandomAlphaNumeric.ps1
Created April 5, 2017 13:05
Powershell: Generate a random Alphanumeric string
# Generate a random Alphanumeric string
Function Get-RandomAlphanumericString {
[CmdletBinding()]
Param (
[int] $length = 8
)
Begin{
@marcgeld
marcgeld / index.html
Last active January 1, 2024 23:58
A simple webpage that list my GitHub gists
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gist List</title>
<script>
function addElement(str, link) {
@marcgeld
marcgeld / run.tpl
Created August 23, 2023 11:23 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name {{printf "%q" .Name}} \
{{- with .HostConfig}}
{{- if .Privileged}}
--privileged \
{{- end}}
{{- if .AutoRemove}}
--rm \
{{- end}}
{{- if .Runtime}}
@marcgeld
marcgeld / psCompress.ps1
Last active April 11, 2023 09:11
Powershell: Compress and decompress byte array
# Compress and decompress byte array
function Get-CompressedByteArray {
[CmdletBinding()]
Param (
[Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)]
[byte[]] $byteArray = $(Throw("-byteArray is required"))
)
Process {
@marcgeld
marcgeld / numberToNumbers.scpt
Last active December 7, 2022 16:19
A jxa script to create a spreadsheet in Apple numbers
let numbers = Application('Numbers')
numbers.includeStandardAdditions = true
numbers.activate()
delay(1)
SystemEvents = Application('System Events')
Notes = SystemEvents.processes['Numbers']
let jsonStr = "[{\"datum\":\"26 januari 2018 16:28\",\"biljett\":\"Enkelbiljett\",\"pris\":\"39,00\",\"moms\":\"2,21\",\"total\":\"39,00\"},{\"datum\":\"24 januari 2018 17:09\",\"biljett\":\"Enkelbiljett\",\"pris\":\"39,00\",\"moms\":\"2,21\",\"total\":\"39,00\"},{\"datum\":\"20 januari 2018 16:14\",\"biljett\":\"Enkelbiljett\",\"pris\":\"47,00\",\"moms\":\"2,66\",\"total\":\"47,00\"},{\"datum\":\"14 januari 2018 02:17\",\"biljett\":\"Enkelbiljett\",\"pris\":\"27,00\",\"moms\":\"1,53\",\"total\":\"27,00\"},{\"datum\":\"13 januari 2018 18:06\",\"biljett\":\"Enkelbiljett\",\"pris\":\"27,00\",\"moms\":\"1,53\",\"total\":\"27,00\"},{\"datum\":\"22 december 2017 14:22\",\"biljett\":\"Enkelbiljett\",\"pris\":\"46,00\",\"moms\":\"2,60\",\"total\":\"46,00\"},{\"datum\":\"21 december 2017 17:20\",\"biljett\":\"Enkelbiljett\",\"pr
@marcgeld
marcgeld / dbVizPasswordDecrypt.groovy
Created June 19, 2017 11:52
Decode DbVisualizer settings password. (https://www.dbvis.com/)
#!/usr/bin/env groovy
import javax.crypto.SecretKeyFactory
import javax.crypto.SecretKey
import javax.crypto.Cipher
import javax.crypto.spec.PBEParameterSpec
import javax.crypto.spec.PBEKeySpec
import java.util.Base64
import java.util.Base64.Decoder
import static java.nio.charset.StandardCharsets.UTF_8
@marcgeld
marcgeld / SlowCalc.java
Created May 27, 2020 23:12
Generates a list of as many primes as possible within 100 milliseconds OR when there is a common divisor >1 for the newly generated prime and last prime on list
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_adisk._tcp</type>
<txt-record>sys=waMa=0,adVF=0x100</txt-record>
<txt-record>dk0=adVN=Time Capsule,adVF=0x82</txt-record>
</service>
<service>
@marcgeld
marcgeld / staxParser.groovy
Created March 23, 2020 23:36
Parse an XML with StAX Java/Groovy
#!/usr/bin/env groovy
import java.util.ArrayList;
import java.util.List;
import java.nio.charset.StandardCharsets;
import java.lang.StringBuilder;
import java.util.concurrent.TimeUnit;
@marcgeld
marcgeld / CompileLoad.ps1
Created May 23, 2017 11:35
Compile and load in Powershell
[string] $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
[string] $fileName = $($MyInvocation.MyCommand).ToString().Replace(".ps1", ".dll")
[string] $dllPath = Join-Path $scriptPath $fileName
Write-Host "Dll fileName: $($fileName)"
Write-Host "Dll scriptPath: $($scriptPath)"
Write-Host "Dll Path: $($dllPath)"