Skip to content

Instantly share code, notes, and snippets.

package integrations
import javax.xml.parsers.SAXParser
import org.xml.sax.InputSource
import xml.parsing.NoBindingFactoryAdapter
import javax.xml.parsers.SAXParser
import org.xml.sax.InputSource
import xml.parsing.NoBindingFactoryAdapter
/**
@maciekr
maciekr / AmqpBrokenPipeAwarePublisher.java
Created May 20, 2013 15:21
dummy example of alternate exchange
package com.homeaway.brokenclient;
import com.rabbitmq.client.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* Created with IntelliJ IDEA.
@maciekr
maciekr / CorrelationIdServletFilter.java
Created May 21, 2013 16:56
servlet filter that sets up correlation id for a given request (either generates it or takes it from the request header/params)
package com.liftago.utils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
package com.liftago.utils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
@maciekr
maciekr / pom.xml
Created June 28, 2013 13:02
added version.txt task
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.adleritech.billing</groupId>
<artifactId>billing-platform</artifactId>
<version>1.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Billing Platform</name>
@maciekr
maciekr / RabbitHAClient.java
Created November 23, 2013 17:31
amqp connection recovery
package com.adleritech.aitcommons.rabbit;
import com.rabbitmq.client.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
@maciekr
maciekr / NearestLinePointFromStandalonePoint.java
Created February 20, 2014 14:44
nearest line point rfrom a standalon point
package com.adleritech.searchplay;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineSegment;
import com.vividsolutions.jts.linearref.LinearLocation;
import com.vividsolutions.jts.linearref.LocationIndexedLine;
public class NearestLinePointFromStandalonePoint {
@maciekr
maciekr / property_decorator.rb
Created June 29, 2015 15:56
check pricer method - no business logic in here, just delegating to pricer (which is de facto handler for price)
class PropertyDecorator < Draper::Decorator
delegate_all
decorates_association :reviews
def summary
collection = [] #'breadcrumbs will go here? see properties/show.html.haml'
('<span>' + name + '</span>' + collection.join(', ')).html_safe
end
def summary_plain
@maciekr
maciekr / property_decorator.rb
Created June 29, 2015 15:57
check out pricer method. it's fairly anemic now, no business there, all pushed down to brand specific pricers.
class PropertyDecorator < Draper::Decorator
delegate_all
decorates_association :reviews
def summary
collection = [] #'breadcrumbs will go here? see properties/show.html.haml'
('<span>' + name + '</span>' + collection.join(', ')).html_safe
end
def summary_plain
@maciekr
maciekr / base_pricer.rb
Created June 29, 2015 16:00
this is pricer factory and a base pricer that implements pretty much all that current pricer does, but allows for nice overrides of core behaviours. the factory though, it tries to instantiate a 'valid' pricer - pricer is really a handler (with business) for dummy price. factory is a bit smarter than usual, as it implements some business logic a…
module Pricing::Pricers
class PricerFactory
def self.pricer_for(property, check_in_on, check_out_on, request_live_price: request_live_price?)
pricer_class = begin
"Pricing::Pricers::#{property.source.gsub(/\s+/,'')}Pricer".constantize
rescue NameError
Pricing::Pricers::BasePricer