Skip to content

Instantly share code, notes, and snippets.

@nhojpatrick
nhojpatrick / Example.java
Last active February 27, 2018 11:42
Method Chaining Example
package tld.examples;
public class Example {
protected String mandatory;
protected String optional;
protected String mandatoryIfOptionalExists;
private Example() {
}
$ find .
.
./classes
./source
./source/local
./source/local/User1.java
./source/foreign
./source/foreign/User2.java
$
$ javac -d ./classes source/local/*.java source/foreign/*.java
@nhojpatrick
nhojpatrick / AbstractEntity.java
Created January 8, 2018 20:51
Generics Issue
package tld.examples.builders;
public abstract class AbstractEntity {
protected String varAbstractEntity;
public AbstractEntity() {
}
public AbstractEntity(final AbstractEntityBuilder abstractEntityBuilder) {
TASK [mysql-ansible-apt-module : Install mysql server - ansible module] ********
fatal: [ansible-apt-module]: FAILED! => {"cache_update_time": 1515198522, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'mysql-server'' failed: No apport report written because the error message indicates its a followup error from a previous failure.\nE: Sub-process /usr/bin/dpkg returned an error code (1)\n",
"rc": 100, "stderr": "No apport report written because the error message indicates its a followup error from a previous failure.\nE: Sub-process /usr/bin/dpkg returned an error code (1)\n",
"stderr_lines": ["No apport report written because the error message indicates its a followup error from a previous failure.",
"E: Sub-process /usr/bin/dpkg returned an error code (1)"], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be i
@nhojpatrick
nhojpatrick / install_jenkins_plugin.sh
Last active October 18, 2018 15:21 — forked from hoesler/install_jenkins_plugin.sh
Script to install one or more jenkins plugins including dependencies while jenkins is offline
#!/usr/bin/env bash
set -e
set -o pipefail
plugin_repo_url="http://updates.jenkins-ci.org/download/plugins"
plugin_dir="/var/lib/jenkins/plugins"
include_optionals=false
showUsage() {
@nhojpatrick
nhojpatrick / wallet address
Last active October 12, 2017 13:41
blockchain rinkeby
0x34fc06f5c73f1bad89193796e283ac796ad2928c
@nhojpatrick
nhojpatrick / JitExample.java
Created September 14, 2017 21:10
Jit Example
public class JitExample {
public static void main(final String[] args) {
new JitExample();
}
public JitExample() {
final long oneStart = System.nanoTime();
@nhojpatrick
nhojpatrick / Pattern.java
Last active April 23, 2017 15:11
1 Loop & 1 StringBuilder
public class Pattern {
public static void main(final String[] args) {
final StringBuilder sb = new StringBuilder();
for (int i = 1; i <= 7; i++) {
System.out.println(String.format("%s %s %s", sb.toString(), i, sb.reverse()));
sb.reverse().append(" " + i);
}
}
}
public class Student {
...
}
public class FrontEndCode {
...
public void updateStudentWithNewName(final Id id, final String firstName, final String lastName) {
final Student student = bec.getStudent(id);
student.setFirstName(firstName);
student.setLastName(lastName);
HttpServer server = new GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig);
server.getServerConfiguration()
.addHttpHandler(new CLStaticHttpHandler(Application.class.getClassLoader()), "/");
WebappContext webappContext = new WebappContext("grizzly web context", "/");
FilterRegistration filterRegistration = webappContext.addFilter("MyFilter", MyFilter.class);
filterRegistration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), "/*");