Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Kondratovich akandratovich

View GitHub Profile
View SpringBootMetricsCollector.java
package me.kondratovich.actuator.prometheus;
import static io.micrometer.core.instrument.Statistic.Count;
import static io.micrometer.core.instrument.Statistic.Total;
import static io.micrometer.core.instrument.Statistic.TotalTime;
import static io.micrometer.core.instrument.Statistic.Value;
import com.google.common.base.Objects;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
View NexusHelloWorldResource.java
import javax.inject.Named;
import javax.inject.Singleton;
import org.restlet.Context;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.ResourceException;
import org.restlet.resource.Variant;
import org.sonatype.plexus.rest.resource.AbstractPlexusResource;
import org.sonatype.plexus.rest.resource.PathProtectionDescriptor;
View BrandsnappeException.java
package com.os.brandsnapper.exception;
public class BrandsnappeException extends RuntimeException {
private final ErrorCode code;
private BrandsnappeException(ErrorCode err, String message) {
super(message == null ? err.getMessage() : message);
code = err;
}
View Handler.java
...
post(new Route("zuora-callout-callback") {
@Override
public Object handle(Request request, Response response) {
logger.info("GOT IT");
for (String v : request.queryParams()) {
logger.info(v + " " + request.queryParams(v));
}
View Handler.java
...
post(new Route("zuora-callout-callback") {
@Override
public Object handle(Request request, Response response) {
logger.info("GOT IT");
for (String v : request.queryParams()) {
logger.info(v + " " + request.queryParams(v));
}
View formatter-java.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="Default" version="12">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
View DBConnector.java
...
private static BoneCPDataSource initialize() {
PropertyResourceBundle config = (PropertyResourceBundle) ResourceBundle.getBundle("bonecp");
Properties p = new Properties();
Enumeration<String> keys = config.getKeys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
p.setProperty(key, config.getString(key));
View gist:4555065
package com.os.cpnet.tool;
import java.util.Arrays;
import org.apache.commons.codec.binary.Base64;
public final class BitString implements Comparable<BitString> {
public static final BitString ZERO = new BitString(new long[] {});
public static final int SLOT_SIZE = 64;
View gist:3169347
"Limit (cost=19359.90..19360.02 rows=50 width=12) (actual time=35.973..36.005 rows=50 loops=1)"
" Output: a.f, a.t, a."time""
" Buffers: shared hit=5238 read=2"
" -> Sort (cost=19359.90..19360.14 rows=96 width=12) (actual time=35.935..35.947 rows=50 loops=1)"
" Output: a.f, a.t, a."time""
" Sort Key: a."time""
" Sort Method: top-N heapsort Memory: 18kB"
" Buffers: shared hit=5238 read=2"
" -> Hash Join (cost=18994.33..19356.74 rows=96 width=12) (actual time=26.953..31.508 rows=7500 loops=1)"
" Output: a.f, a.t, a."time""
View gist:3169150
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;