Skip to content

Instantly share code, notes, and snippets.

View gkhays's full-sized avatar

Garve Hays gkhays

View GitHub Profile
@gkhays
gkhays / Get JAR Location.md
Created February 15, 2020 14:53
Get the path of a running JAR file

The .toURI() method allows you to sidestep issues with special characters.

return new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation()
    .toURI()).getPath();

References

How to get the path of a running JAR file?

@gkhays
gkhays / Dropwizard Hacks.md
Last active February 14, 2020 16:12
Extend Dropwizard

Out of the Box Things for Dropwizard

Push the boundaries of Dropwizard.

Load Classes on Classpath

The fix for Issue #1314 should load classes on the classpath.

test/resources/example.txt
@gkhays
gkhays / GetResource.md
Last active February 13, 2020 00:42
Retrieve a resource on the classpath

Get Resource

Read a file in from a resource. In many cases it is useful to read it into a string. Use a standard Maven directory layout.

├───src
│   ├───main
│   │   ├───java
│   │   └───resources
│ └───test

Getting Debug Logging with Maven and Cargo

Starting in Maven 3.1.x, logging was switched to SLF4J. The consequence is that you no longer receive DEBUG or TRACE logging messages in a cargo build.

Modify Simple Logger Properties

You can update ${MAVEN_HOME}/conf/logging/simplelogger.properties. But that will create a lot of "noise."

org.slf4j.simpleLogger.defaultLogLevel=DEBUG

JSON Parsing in C#

In the past I have used Visual Studio for C# and .NET developement. This little project is used to create a simple .NET console program using Visual Studio Code. The goal is to confirm that for multiple value entries, the .NET parser will use the last entered value.

Getting Started

Use these instructions to get the project up and running.

Prerequisites

Deploy Nginx Using Terraform

terraform init
terraform plan -out tfconfig.tfplan
terraform apply
docker ps
terraform show
@gkhays
gkhays / Compare-Lists-Java.md
Last active October 10, 2019 17:40
Compare members of different lists in Java

Java Collections has some built-in features; e.g. retainAll and removeAll.

//listOne.retainAll(listTwo);
listOne.removeAll(listTwo);

Note: Sets do not allow duplicates.

Keybase proof

I hereby claim:

  • I am gkhays on github.
  • I am gkhays (https://keybase.io/gkhays) on keybase.
  • I have a public key ASArT6jpxW-8ZMbaIJYukNKGpiCD520d9McCdXyoq8T4Pwo

To claim this, I am signing this object:

@gkhays
gkhays / OpenJDK-Mac.md
Last active September 18, 2019 21:14
Install OpenJDK Version 12 on Mac

OpenJDK on Mac

Follow these instructions to move from an Oracle JDK to OpenJDK. In a twist of irony, I had originally replaced OpenJDK on my Mac with the Oracle JDK!

Remove Oracle JDK

The steps for removing different versions of the JDK vary. This is what I did.

sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
@gkhays
gkhays / Eclipse-Console-Logs.md
Last active September 3, 2019 15:36
Redirect Eclipse console logs to a file