Skip to content

Instantly share code, notes, and snippets.

@dodgex
dodgex / OkHttpClientRequest.java
Last active December 20, 2015 01:19
OkHttpRequestFactory for Spring Rest Template
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPOutputStream;
import org.springframework.http.ContentCodingType;
@dodgex
dodgex / EnhancedMenuInflater.java
Created October 28, 2014 08:08
splitActionBar for Android 5.0
import android.support.v4.internal.view.SupportMenuItem;
import android.support.v7.internal.view.menu.MenuItemImpl;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import here.is.your.R;
public class EnhancedMenuInflater {
@dodgex
dodgex / PrintView.java
Created April 14, 2015 08:53
dump TM1 view
void printView(TM1Cube oCube, String viewName) {
TM1View view = oCube.getView(viewName);
view.constructArray();
int arrayRows = view.getNumberOfArrayRows();
int arrayColumns = view.getNumberOfArrayColumns();
int dataRows = view.getNumberOfArrayAxisTuples(new TM1Val(2)).getInt();
int dataCols = view.getNumberOfArrayAxisTuples(new TM1Val(1)).getInt();
/**
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details.
*
* --------------------------------------------------------------------
*
* This method takes a SemVer (http://semver.org/) compatible Version String
@dodgex
dodgex / SqlLog.java
Created February 16, 2017 10:10
tiny helper to enable hibernate sql trace logging and resotring previous log level
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
public class SqlLog {
private static final Logger LOG =
(Logger) LoggerFactory.getLogger(SqlLog.class);
@dodgex
dodgex / Outer.java
Created April 3, 2017 07:17
Eclipse formatter bug
import java.util.Objects;
public class Outer {
private class Inner {
@Override
public boolean equals(Object obj) {
// @formatter:off
return Objects.equals("", "")
&& Objects.equals("", "")
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* Based on: https://stackoverflow.com/a/26227947/1659588
*/
public class Parser {
@dodgex
dodgex / build.gradle.kts
Created November 4, 2018 18:09
unpack webjars into version less directory
// create configuration
val webjars = configurations.create("webjar")
// add dependencies
dependencies {
"webjar"("org.webjars.bower:bootstrap:4.1.3")
"webjar"("org.webjars.bower:jquery:3.3.1")
}
// add task