Skip to content

Instantly share code, notes, and snippets.

View shawnz's full-sized avatar

Shawn Zivontsis shawnz

View GitHub Profile
package org.shawnz;
import java.io.IOException;
import java.io.InputStream;
public class TruncatedInputStream extends InputStream {
private final long maxLength;
private final InputStream underlying;
package org.shawnz;
import java.io.InputStream;
import java.util.Arrays;
public class ZeroInputStream extends InputStream {
private final long zeroes;
private long read;
import java.util.*;
public class LazyList<E> extends AbstractSequentialList<E> {
private final ArrayList<E> cache = new ArrayList<>();
private final Iterator<E> iterator;
private final int size;
public LazyList() {
this.iterator = Collections.emptyIterator();
for (var i = 1; i <= 100; i++) {
var k = 810092048 >> (i - 1) % 15 * 2 & 3,
s = "";
if (k & 1) s += "Fizz";
if (k > 1) s += "Buzz";
console.log(s || i);
}
@shawnz
shawnz / fk_ref.xml
Last active July 27, 2020 19:06
a plugin for SQL Developer to show foreign key references on tables
<displays>
<display type="editor" style="null" enable="true" connType="Oracle" objectType="TABLE">
<name><![CDATA[FK References]]></name>
<description><![CDATA[]]>
</description>
<tooltip><![CDATA[]]>
</tooltip>
<drillclass><![CDATA[null]]></drillclass>
<query>
<sql>
package org.shawnz.util;
import java.util.NoSuchElementException;
import java.util.function.Function;
public abstract class Either<L, R> {
private Either() {
}
@shawnz
shawnz / WarnSchemaValidator.java
Last active May 9, 2023 07:08
Hibernate schema validator that outputs warning messages instead of throwing exceptions. Tested with Hibernate 5.3.9
package org.shawnz;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.Sequence;
import org.hibernate.dialect.Dialect;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.Table;
import org.hibernate.tool.schema.extract.spi.ColumnInformation;