Skip to content

Instantly share code, notes, and snippets.

View marcgeld's full-sized avatar

Marcus Gelderman marcgeld

View GitHub Profile
@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)"
@marcgeld
marcgeld / mavenPwdDecode.groovy
Created June 8, 2017 07:12
Decodes maven passwords in configuration
#!/usr/bin/env groovy
// for logging: #!/usr/bin/env JAVA_OPTS=-Dgroovy.grape.report.downloads=true groovy
@Grab(group='commons-codec', module='commons-codec', version='1.10')
@Grab(group='org.sonatype.plexus', module='plexus-cipher', version='1.7')
import java.nio.file.Paths
import org.apache.commons.codec.binary.Base64
import org.sonatype.plexus.components.cipher.DefaultPlexusCipher
@marcgeld
marcgeld / regexJava.groovy
Created June 13, 2017 08:12
Groovy: regex & Base64
#!/usr/bin/env groovy
import java.util.Base64
import java.util.Base64.Decoder
import java.util.Base64.Encoder
import java.util.regex.Matcher
import java.util.regex.Pattern
import java.nio.charset.StandardCharsets;
final Decoder decoder = Base64.getDecoder()
@marcgeld
marcgeld / scanner.groovy
Last active June 13, 2017 20:03
Groovy scanner
#!/usr/bin/env groovy
print "enter number: "
System.in.eachLine() { line ->
n = line.trim().toInteger()
(1..10).each{
int res = n * it
println "${n} x ${it} = ${res}"
}
@marcgeld
marcgeld / ikeaTradfriCall.groovy
Last active August 4, 2017 11:21
Connect to IKEA Trådfri Gateway Device via CoAP and DTLS
#!/usr/bin/env groovy
// Keywords are:
// CoAP - Constrained Application Protocol (Internet Application Protocol for constrained devices.)
// DTLS - Datagram Transport Layer Security (Encryption for Datagram (UDP))
// IKEA Trådfri - (http://www.ikea.com/us/en/catalog/products/90353361/)
@Grapes([
@GrabConfig(systemClassLoader = true),
@Grab(group='net.straylightlabs', module='hola', version='0.2.2'),
@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 / 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 / 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 / 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 / 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