Skip to content

Instantly share code, notes, and snippets.

View proteus-russ's full-sized avatar

Russ Tennant proteus-russ

  • Proteus
  • Lincoln, NE
View GitHub Profile
@proteus-russ
proteus-russ / lang.kts
Created December 30, 2019 12:23
Integer as binary string
fun Int.asBinaryString(): String {
return String.format(
"%16s",
Integer.toBinaryString(this)
)
.replace(' ', '0')
}
val number = 6
abstract class Entity<T : Serializable> {
abstract var id: T
override fun equals(other: Any?): Boolean = when {
this === other -> true
other == null -> false
Hibernate.getClass(other) != Hibernate.getClass(this) -> false
else -> Objects.equals(id, (other as Entity<*>).id)
}
@proteus-russ
proteus-russ / Example.java
Created June 15, 2017 18:53 — forked from saguinav/Example.java
Polymorphic deserialization with Moshi
package com.square.moshi.example;
import com.squareup.moshi.RuntimeTypeJsonAdapterFactory.RuntimeType;
public class Example {
static class Animal {
String type;
String name;
CREATE OR REPLACE FUNCTION DC_ReorderIndexesNULLS(key bigint, tableName text, keyName text, orderCol text) RETURNS integer AS
$PROCEDURE$
DECLARE
last_index INTEGER := 0;
count INTEGER := 0;
r RECORD;
query TEXT := 'SELECT ' || orderCol || ' as order FROM ' || tableName || ' WHERE ' || keyName || ' = ' || key
|| ' ORDER BY ' || orderCol;
BEGIN
EXECUTE 'SELECT COUNT(*) as cnt FROM ' || tableName || ' WHERE ' || keyName || ' = ' || key INTO count;
@proteus-russ
proteus-russ / CronUtilsissue.java
Created November 30, 2015 18:08
Issue when upgrading to 3.1.2
package com.lrlabs.model.activity.config;
import com.cronutils.model.Cron;
import com.cronutils.model.definition.CronDefinition;
import com.cronutils.model.definition.CronDefinitionBuilder;
import com.cronutils.model.time.ExecutionTime;
import com.cronutils.parser.CronParser;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;