Skip to content

Instantly share code, notes, and snippets.

View marcgeld's full-sized avatar

Marcus Gelderman marcgeld

View GitHub Profile
@marcgeld
marcgeld / base64encode.groovy
Created February 9, 2018 08:51
Decode and encode the first argument in args. If no args exists use the string "password"
#!/usr/bin/env groovy
import java.nio.charset.StandardCharsets
String text = ""
if ( this.args.size() > 0 ) {
text = this.args[0]
}
else {
@marcgeld
marcgeld / httpBasicAuthEncode.groovy
Last active April 3, 2019 22:39
Encodes username and password for the basic authentication header (http/https)
#!/usr/bin/env groovy
import java.nio.charset.StandardCharsets
import org.apache.commons.cli.Option
def cli = new CliBuilder( usage:"${this.getClass().getName()} --u <username> -p <password>" )
cli.with {
u( longOpt: 'user', 'username', args: 1, required: true )
p( longOpt: 'password', 'password', args: 1, required: true )
@marcgeld
marcgeld / everyDayInAYear.groovy
Created January 22, 2018 10:02
Create calendar for a year
#!/usr/bin/env groovy
def year = 2018
Calendar.metaClass.yearMonthDay {
delegate.format("yyyy-MM-dd")
}
Calendar.metaClass.weekDay {
delegate.format("EEEE")
@marcgeld
marcgeld / homebridge
Created December 10, 2017 11:07 — forked from johannrichard/homebridge
Systemd Service for homebridge (http://github.com/nfarina/homebridge)
# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
HOMEBRIDGE_OPTS=-U /var/lib/homebridge
# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*
@marcgeld
marcgeld / dumpJar.groovy
Created September 21, 2017 13:24
Dump classes from a jar-file.
#!/usr/bin/env groovy
import java.util.zip.ZipFile
def printelnerr = System.err.&println
def appName = this.getClass().getName()
def cli = new CliBuilder( usage:"${appName} --basedir <path_to_dir> --intersectdir <path_to_dir> " )
cli.with {
@marcgeld
marcgeld / findJar.groovy
Created June 28, 2017 14:22
Find in which jar file a class is located.
#!/usr/bin/env groovy
import groovy.io.FileType
import java.net.URL
import java.net.URLClassLoader
import java.nio.file.Paths
import java.security.CodeSource
import java.security.ProtectionDomain
def printelnerr = System.err.&println
@marcgeld
marcgeld / ikeaTradfriFWCheck.groovy
Last active April 14, 2019 21:15
Pretty Print JSON (IKEA Tradfri FW Check)
#!/usr/bin/env groovy
import static groovy.json.JsonOutput.prettyPrint
println prettyPrint( new URL ("http://fw.ota.homesmart.ikea.net/feed/version_info.json").getText() )
@marcgeld
marcgeld / jarSelector.groovy
Created June 26, 2017 09:03
Compare jar-file versions in two folders
#!/usr/bin/env groovy
import groovy.io.FileType
def printelnerr = System.err.&println
def appName = this.getClass().getName()
def cli = new CliBuilder( usage:"${appName} --basedir <path_to_dir> --intersectdir <path_to_dir> " )
cli.with {
@marcgeld
marcgeld / skvFiler.groovy
Created June 19, 2017 22:28
Transforms .csv data to a MS Excel Workbook
#!/usr/bin/env groovy
@Grapes([
@Grab(group='org.apache.poi', module='poi', version='3.16'),
@Grab(group='net.sf.opencsv', module='opencsv', version='2.3')
])
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
@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