Skip to content

Instantly share code, notes, and snippets.

View marcgeld's full-sized avatar

Marcus Gelderman marcgeld

View GitHub Profile
@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 / 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 / .bash_profile
Last active May 25, 2019 16:53
macOS bash_profile
export PATH="/usr/local/sbin:$PATH"
export PATH=$PATH:$M2_HOME/bin
export GROOVY_HOME=/usr/local/opt/groovy/libexec
export GOPATH="${HOME}/.go:${HOME}/devmap/go"
export PATH="$PATH:${GOPATH}/bin"
function setjdk() {
@marcgeld
marcgeld / pdfImages2MultipageTIFF.groovy
Created April 21, 2019 21:49
Extract images from a pdf file to multipage TIFF (Tesseract-ocr accepts multipage TIFF, but not a pdf file with images as input)
#!/usr/bin/env groovy
// Java 9 or later (…for the TIFF ImageIO Plugin)
@Grab(group='ch.qos.logback', module='logback-classic', version='1.2.3')
@Grab(group='org.apache.pdfbox', module='pdfbox', version='2.0.15')
@Grab(group='commons-io', module='commons-io', version='2.6')
import org.apache.pdfbox.pdfwriter.*
import org.apache.pdfbox.pdmodel.*
@marcgeld
marcgeld / springboot.groovy
Created April 16, 2019 21:44
A very simple Spring Boot Application in groovy
#!/usr/bin/env groovy
package myapp
@Grab('org.springframework:spring-context:5.1.6.RELEASE')
@Grab('org.springframework:spring-web:5.1.6.RELEASE')
@Grab('org.springframework.boot:spring-boot:2.1.4.RELEASE')
@Grab('org.springframework.boot:spring-boot-starter:2.1.4.RELEASE')
@Grab('org.springframework.boot:spring-boot-starter-webflux:2.1.4.RELEASE')
@marcgeld
marcgeld / booleanToString.groovy
Last active April 3, 2019 22:39
boolean to string conversion (Java/Groovy)
#!/usr/bin/env groovy
Boolean TRUE = true
Boolean FALSE = false
println "Boolean true => string: '${Boolean.toString(TRUE)}'"
println "Boolean false => string: '${Boolean.toString(FALSE)}'"
println "String 'true' => string: '${Boolean.parseBoolean("true")}'"
println "String 'TRUE' => string: '${Boolean.parseBoolean("TRUE")}'"
@marcgeld
marcgeld / httpsPost.groovy
Last active March 27, 2019 15:34
Post to httpbin.org/post
#!/usr/bin/env groovy
import groovy.xml.XmlUtil
import javax.net.ssl.SSLSession
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLContext
import javax.net.ssl.HttpsURLConnection
import static javax.net.ssl.HttpsURLConnection.HTTP_OK