Skip to content

Instantly share code, notes, and snippets.

@nhojpatrick
nhojpatrick / setJdk
Created September 19, 2018 14:32
Set Java
# java
function setJdk {
JAVA_HOME=`/usr/libexec/java_home -v "$1"` ;
if [ $? -eq 0 ]; then
export JAVA_HOME ;
java -version 2>&1 ;
fi
}
export -f setJdk ;
setJdk 1.8 1>/dev/null ;
@nhojpatrick
nhojpatrick / Parent.java
Created September 11, 2018 19:11
A Bad Hello World example using static and public references of objects.
public class Parent {
public static final Level1 l1 = new Level1();
public static class Level1 {
public final Level2 l2 = new Level2();
}
public static class Level2 {
public final String helloWorld = "Hello World";
@nhojpatrick
nhojpatrick / RajR.java
Last active September 1, 2018 13:11
RajR.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class RajR {
public static class Person {
private final String firstname;
private final String surname;
@nhojpatrick
nhojpatrick / Employee.java
Created July 22, 2018 12:47
Employee Builder example
public class Employee {
public static class Builder<T extends Employee> {
private T entity;
public Builder() {
this.entity = new Employee();
}
@nhojpatrick
nhojpatrick / ansible-apt-issue.bionic64.log
Last active June 23, 2018 12:11
ansible-apt-issue.bionic64.log
loki:ansible-apt-issue john$ vagrant up ansible-apt-module
Bringing machine 'ansible-apt-module' up with 'virtualbox' provider...
==> ansible-apt-module: Importing base box 'ubuntu/bionic64'...
==> ansible-apt-module: Matching MAC address for NAT networking...
==> ansible-apt-module: Checking if box 'ubuntu/bionic64' is up to date...
==> ansible-apt-module: Setting the name of the VM: ansible-apt-issue_ansible-apt-module_1529754013294_58923
==> ansible-apt-module: Fixed port collision for 22 => 2222. Now on port 2200.
==> ansible-apt-module: Clearing any previously set network interfaces...
==> ansible-apt-module: Preparing network interfaces based on configuration...
ansible-apt-module: Adapter 1: nat
@nhojpatrick
nhojpatrick / ansible-apt-issue.artful64.log
Last active June 23, 2018 12:11
ansible-apt-issue.artful64.log
loki:ansible-apt-issue john$ vagrant up ansible-apt-module
Bringing machine 'ansible-apt-module' up with 'virtualbox' provider...
==> ansible-apt-module: Importing base box 'ubuntu/artful64'...
==> ansible-apt-module: Matching MAC address for NAT networking...
==> ansible-apt-module: Checking if box 'ubuntu/artful64' is up to date...
==> ansible-apt-module: Setting the name of the VM: ansible-apt-issue_ansible-apt-module_1529753061622_14729
==> ansible-apt-module: Fixed port collision for 22 => 2222. Now on port 2200.
==> ansible-apt-module: Clearing any previously set network interfaces...
==> ansible-apt-module: Preparing network interfaces based on configuration...
ansible-apt-module: Adapter 1: nat
@nhojpatrick
nhojpatrick / indent.py
Last active June 21, 2018 21:23
Python indentation demo
#!/usr/bin/env python
def indent():
logic1 = True
logic2 = True
if logic1 :
print("A")
if not logic2 :
print("B")
else :
@nhojpatrick
nhojpatrick / example.json
Created June 18, 2018 17:28
example json
{
"id": 1234,
"name": "a name",
"dynamicsection": {
"key1": 1,
"key2": false,
"key3": "a string"
}
}
@nhojpatrick
nhojpatrick / ExampleNoPackagePackagePrivateAbstract.java
Created March 24, 2018 11:18
Java files can start with these...
abstract class ExampleNoPackagePackagePrivateAbstract {}
@nhojpatrick
nhojpatrick / Example.java
Created March 5, 2018 13:34
JUnit 5 assertAll as Executable
package tld.example;
import org.junit.jupiter.api.function.Executable;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Example {
@Test
public void example() {
assertAll("parent",
() -> assertEquals("1", "2"),