Skip to content

Instantly share code, notes, and snippets.

View dmitrygusev's full-sized avatar

Dmitry Gusev dmitrygusev

View GitHub Profile
@dmitrygusev
dmitrygusev / XeroObjectMapperContextResolver.java
Created June 20, 2013 13:49
Example of calling Xero API using JSON format via Resteasy client with custom ObjectMapper
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.ws.rs.ext.ContextResolver;
import org.codehaus.jackson.map.ObjectMapper;
@dmitrygusev
dmitrygusev / AbstractWorker.java
Last active December 23, 2015 17:29
Tapestry Workers & Tasks
package com.anjlab.spelling.web.services.workers;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import org.apache.tapestry5.ioc.Messages;
// see http://svn.apache.org/repos/asf/shiro/tags/shiro-root-1.2.2/core/src/test/java/org/apache/shiro/test/AbstractShiroTest.java
public class BaseIntegrationTest extends AbstractShiroTest
{
public static Registry registry;
@BeforeClass
public static void setup()
{
// Here is how I use it in my AppModule.java, note there may be no any HTTP Request when this code executing:
import xxx.web.pages.oauth.Callback;
// ...
@Contribute(OAuthServiceCatalog.class)
public void contributeOAuthServices(MappedConfiguration<String, OAuthServiceConfig> configuration,
// ...
OfflineLinkSource offlineLinkSource)
@dmitrygusev
dmitrygusev / BetterJPAQuery.java
Created November 11, 2013 16:44
Implementing JPAQuery.count(EntityPath<?>) for QueryDSL
/*
* Copyright 2011, Mysema Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
import com.mysema.query.BooleanBuilder;
import com.mysema.query.types.Expression;
import com.mysema.query.types.Order;
import com.mysema.query.types.Predicate;
import com.mysema.query.types.expr.ComparableExpression;
import re
import os
import sys
from subprocess import Popen, PIPE
scriptpath=os.path.dirname(os.path.abspath(__file__))
decrypt=os.path.join(scriptpath, 'decrypt')
input_str = sys.stdin.read()
@dmitrygusev
dmitrygusev / Dockerfile
Last active October 4, 2018 13:28
Jenkins in Docker
FROM jenkins/jenkins:2.138.1
USER root
RUN apt-get update -y && apt-get install -y \
python-pip \
sudo
RUN pip install awscli --upgrade