Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Samsotha psamsotha

View GitHub Profile
@psamsotha
psamsotha / ConstructorInterceptExample.java
Created Jan 13, 2017
Example of constructor interception with Jersey/HK2
View ConstructorInterceptExample.java
import org.aopalliance.intercept.ConstructorInterceptor;
import org.aopalliance.intercept.ConstructorInvocation;
import org.aopalliance.intercept.MethodInterceptor;
import org.glassfish.hk2.api.Filter;
import org.glassfish.hk2.api.InterceptionService;
import org.glassfish.hk2.utilities.BuilderHelper;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Test;
@psamsotha
psamsotha / TestFrameworkStarter.java
Last active Apr 29, 2020
Starter for Jersey Test Framework
View TestFrameworkStarter.java
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
View CloseableServiceTest.java
import java.io.Closeable;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
View StackOverflow_55711784_2587435.java
package com.example;
import java.io.IOException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import javax.ws.rs.GET;
View MultiPartTest.java
import java.io.InputStream;
import java.net.URI;
import java.util.logging.Logger;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
View FactoryRankTest.java
import java.util.function.Supplier;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import org.glassfish.hk2.api.Factory;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
@psamsotha
psamsotha / main.ts
Created Jul 8, 2016
Get external configuration file before bootstrap in Angular 2. See also https://blog.sstorie.com/providing-external-data-when-bootstrapping-angular-2/
View main.ts
import { bootstrap } from '@angular/platform-browser-dynamic';
import { HTTP_PROVIDERS } from '@angular/http';
import { Http,
Request,
Response,
XSRFStrategy,
CookieXSRFStrategy } from '@angular/http';
import { Injector,
ReflectiveInjector } from '@angular/core';
import { Observable } from 'rxjs/Rx';
@psamsotha
psamsotha / AsyncTest.java
Last active Aug 27, 2018
A Jersey client test using Jersey Test Framework to show how to make async requests.
View AsyncTest.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.client.InvocationCallback;
@psamsotha
psamsotha / SwingSOLinks.md
Last active Jul 25, 2018
Links to some Stack Overflow questions tagged with Swing (all my answers)
View SwingSOLinks.md
View sed cheatsheet
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
You can’t perform that action at this time.