Skip to content

Instantly share code, notes, and snippets.

public class ArrayTest {
public static void main(final String[] args) {
final int D1 = 5;
final int D2 = 4;
int[][] table = new int[D1][D2];
for (int i = 0; i < table.length; i++) {
for (int j = 0; j < table[i].length; j++) {
if (i == j) {
table[i][j] = 1;
} else {
@nhojpatrick
nhojpatrick / xyzThere
Created July 21, 2016 20:22
xyzThere
public boolean xyzThere(final String input) {
if (input == null
|| "".equals(input.trim())) {
return false;
}
if (input.contains(".xyz")
&& input.contains("xyz")) {
return false;
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), "/*");
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);
@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);
}
}
}
@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 / wallet address
Last active October 12, 2017 13:41
blockchain rinkeby
0x34fc06f5c73f1bad89193796e283ac796ad2928c
@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() {
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 / 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) {