Skip to content

Instantly share code, notes, and snippets.

@dodgex
dodgex / build.gradle.kts
Created Nov 4, 2018
unpack webjars into version less directory
View build.gradle.kts
// 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
View Parser.java
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* Based on: https://stackoverflow.com/a/26227947/1659588
*/
public class Parser {
@dodgex
dodgex / Outer.java
Created Apr 3, 2017
Eclipse formatter bug
View Outer.java
import java.util.Objects;
public class Outer {
private class Inner {
@Override
public boolean equals(Object obj) {
// @formatter:off
return Objects.equals("", "")
&& Objects.equals("", "")
@dodgex
dodgex / SqlLog.java
Created Feb 16, 2017
tiny helper to enable hibernate sql trace logging and resotring previous log level
View SqlLog.java
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);
View versioncode.grade
/**
* 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
View PrintView.java
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();
@dodgex
dodgex / EnhancedMenuInflater.java
Created Oct 28, 2014
splitActionBar for Android 5.0
View EnhancedMenuInflater.java
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 / OkHttpClientRequest.java
Last active Dec 20, 2015
OkHttpRequestFactory for Spring Rest Template
View OkHttpClientRequest.java
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;