Skip to content

Instantly share code, notes, and snippets.

View serj-lotutovici's full-sized avatar

Serj Lotutovici serj-lotutovici

View GitHub Profile
@serj-lotutovici
serj-lotutovici / GenericPolymorphicJsonAdapterFactory.java
Last active May 8, 2022 19:45
A Moshi JsonAdapter.Factory that creates Polymorphic JsonAdapter. Requires Moshi 1.4.0. (Tests written in kotlin)
View GenericPolymorphicJsonAdapterFactory.java
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.JsonDataException;
import com.squareup.moshi.JsonReader;
import com.squareup.moshi.JsonWriter;
import com.squareup.moshi.Moshi;
import com.squareup.moshi.Types;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.LinkedHashMap;
View SmallBenchmark.java
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import com.squareup.moshi.Types;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
View SQLQueryBuilder.java
public class SQLQueryBuilder {
private static final String STATEMENT_SELECT = "SELECT";
private static final String STATEMENT_DISTINCT_SELECT = "SELECT DISTINCT";
private static final String STATEMENT_UPDATE = "UPDATE";
private static final String STATEMENT_INSERT_INTO = "INSERT INTO";
private static final String STATEMENT_DELETE = "DELETE FROM";
private static final String WHERE = "WHERE";
private static final String FROM = "FROM";
@serj-lotutovici
serj-lotutovici / Kotlin Style Getter
Last active June 2, 2018 16:27
Kotlin Style Getter and Setter templates for IntelliJ Idea. https://www.jetbrains.com/idea/help/generating-getters-and-setters.html for more info
View Kotlin Style Getter
public ##
#if($field.modifierStatic)
static ##
#end
$field.type ##
#set($name = $StringUtil.decapitalize($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project))))
${name}() {
return $field.name;
}
@serj-lotutovici
serj-lotutovici / Oauth1SigningInterceptor.java
Last active May 2, 2023 07:16 — forked from JakeWharton/Oauth1SigningInterceptor.java
An OkHttp interceptor which does OAuth1 signing. Requires Java 7 (but can easily be ported to Java 6).
View Oauth1SigningInterceptor.java
/*
* Copyright (C) 2015 Jake Wharton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software