Skip to content

Instantly share code, notes, and snippets.

View akandratovich's full-sized avatar

Andrei Kandratovich akandratovich

  • Zurich, Switzerland
View GitHub Profile
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;
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;
@akandratovich
akandratovich / BrandsnappeException.java
Last active December 23, 2015 13:09
ExceptionMapper
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;
}
...
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));
}
...
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));
}
<?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"/>
...
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));
@akandratovich
akandratovich / gist:4555065
Last active December 11, 2015 05:49
Bistring
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;
"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""
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;