Skip to content

Instantly share code, notes, and snippets.

View ataylor284's full-sized avatar

Andrew Taylor ataylor284

View GitHub Profile
@ataylor284
ataylor284 / graal.groovy
Created July 9, 2020 16:47
Testing graal JS engine
@Grapes([
@Grab(group='org.graalvm.js', module='js', version='20.1.0'),
@Grab(group='org.graalvm.js', module='js-scriptengine', version='20.1.0')
])
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
ScriptEngine graalEngine = new ScriptEngineManager().getEngineByName("graal.js");
@ataylor284
ataylor284 / nxrm-minio.md
Last active February 5, 2024 09:56
Creating a Minio S3 Blobstore on NXRM 3.13

Creating a Minio S3 Blobstore on NXRM 3.13

This is a quick guide on creating using the NXRM S3 blob store with Minio's S3 implementation. Disclaimer: Using Minio with NXRM is not officially supported by Sonatype.

Step 1: Start Minio locally

Follow the quick start guide here: https://github.com/minio/minio. For my testing, I started minio with docker with

@ataylor284
ataylor284 / setNodeName.groovy
Last active October 13, 2021 16:57
[nxrm] Set Nexus cluster node name with a groovy script
def hazelcast = container.lookup('com.hazelcast.core.HazelcastInstance')
def nodeConfigurationSource = container.lookup('org.sonatype.nexus.common.node.NodeConfigurationSource')
def nodeId = hazelcast.cluster.members[0].attributes['node.identity']
nodeConfigurationSource.setFriendlyName(nodeId, "My Node")
@ataylor284
ataylor284 / http2.groovy
Last active May 29, 2022 12:11
A mininimalist http2 server with jetty
/*
* Jetty with HTTP2 enabled
* Instructions:
* 1. Create keystore with `keytool -keystore http2_keystore.jks -storepass password -noprompt -genkey -keyalg RSA -keypass password -alias jetty \
* -dname CN=localhost,OU=dev,O=sonatype,L=home,ST=cloud,C=US -ext SAN=DNS:localhost,IP:127.0.0.1 -ext BC=ca:true`
* 2. Run with: `groovy http2.groovy`
* 3. Confirm http2 is being used with `curl -v --http2 --insecure https://localhost:8443`
*/
@Grapes([
@ataylor284
ataylor284 / exportAudit.groovy
Last active October 13, 2021 16:58
[nxrm] Export audit records from NXRM3
import groovy.json.*
def outputFile = new File("auditExport.json")
def auditStore = container.lookup("org.sonatype.nexus.audit.internal.AuditStore")
int pageSize = 1000
int offset = 0
log.info("exporting audit data to ${outputFile.getAbsolutePath()}")
@ataylor284
ataylor284 / PopulateNuget.groovy
Created July 31, 2017 23:05
[nxrm] populate repository with nuget packages
import java.nio.file.Files
import static groovyx.gpars.GParsPool.withPool
def N_PACKAGES = 100
withPool {
(0..<N_PACKAGES).eachParallel { i ->
def dir = new File("package_$i")
dir.deleteDir()
dir.mkdir()
@ataylor284
ataylor284 / proxycreds.groovy
Created December 12, 2016 23:49
http proxy credentials
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.5.2')
import org.apache.http.*
import org.apache.http.auth.*
import org.apache.http.client.*
import org.apache.http.client.config.*
import org.apache.http.client.methods.*
import org.apache.http.impl.auth.*
import org.apache.http.impl.client.*
import org.apache.http.util.*
@ataylor284
ataylor284 / Proxy.groovy
Created August 19, 2016 22:20
A minimalist HTTP proxy using groovy and jetty.
@Grapes([
@Grab(group='org.eclipse.jetty', module='jetty-server', version='8.1.18.v20150929'),
@Grab(group='org.eclipse.jetty', module='jetty-servlet', version='8.1.18.v20150929'),
@Grab(group='org.eclipse.jetty', module='jetty-servlets', version='8.1.18.v20150929')
])
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.ServletHandler
import org.eclipse.jetty.servlets.ProxyServlet
@ataylor284
ataylor284 / cardodds.groovy
Created February 23, 2016 20:55
Calculate odds to draw at least one card in target set from a deck with n draws.
// calculate odds to draw at least one card in target set from a deck
// with n draws
// total size
def deckSize = 52
// cards already consumed
def burned = 0
// number of copies of card we're looking for in the deck
def targets = 4
// number of draws we have
@ataylor284
ataylor284 / gist:781e72ecf86b03e296d9
Last active February 18, 2016 17:54 — forked from tankchintan/gist:1335220
Procedure for installing and setting Sun JDK Java on Default Amazon Linux AMI
# First verify the version of Java being used is not SunJSK.
java -version
# Get the latest Sun Java SDK from Oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u74-b02/jdk-8u74-linux-x64.rpm
# Rename the file downloaded, just to be nice
# mv jdk-7u1-linux-i586.rpm\?e\=1320265424\&h\=916f87354faed15fe652d9f76d64c844 jdk-7u1-linux-i586.rpm
# Install Java