Skip to content

Instantly share code, notes, and snippets.

View AppModule.java
@Advise(serviceInterface=LoginContextService.class)
public void adviseSecuritySaveRequest(MethodAdviceReceiver receiver,
final @Inject @Symbol(SymbolConstants.CHARSET) String requestEncoding,
final RequestGlobals requestGlobals, final ComponentEventLinkEncoder linkEncoder,
final LinkSource linkSource, final Cookies cookies,
TapestrySessionFactory sessionFactory)
throws SecurityException, NoSuchMethodException
{
@SuppressWarnings("unchecked")
Method method = receiver.getInterface().getDeclaredMethod("saveRequest");
@dmitrygusev
dmitrygusev / XeroOAuthService.java
Created Aug 11, 2014
Using Scribe's custom RequestFactory and ConnectionFactory
View XeroOAuthService.java
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import javax.net.ssl.HttpsURLConnection;
import org.scribe.builder.api.DefaultApi10a;
import org.scribe.model.OAuthConfig;
import org.scribe.model.OAuthConstants;
import org.scribe.model.OAuthRequest;
@dmitrygusev
dmitrygusev / keybase.md
Created Feb 26, 2015
GitHub identity proof for Keybase.io
View keybase.md

Keybase proof

I hereby claim:

  • I am dmitrygusev on github.
  • I am dmitrygusev (https://keybase.io/dmitrygusev) on keybase.
  • I have a public key whose fingerprint is E544 E143 40C3 DC06 E8D8 4B3F E1E1 5EC6 36AE FF9C

To claim this, I am signing this object:

View junit-test.java
package com.anjlab.sat3;
import java.util.Properties;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cern.colt.list.ObjectArrayList;
View SortHandlerTest.java
package com.anjlab.ssf4j;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
public class SortHandlerTest {
@Test
public void testSort() {
View snippet.java
private Map<String, List<String>> traces = new HashMap<String, List<String>>();
private void writeSummary(final List<String> headers) throws IOException {
SortHandler<Integer> handler = new SortHandler<Integer>() {
public int to() {
return headers.size() - 1;
}
public void swap(int i, int j) {
Collections.swap(headers, i, j);
@dmitrygusev
dmitrygusev / AppModule.java
Created Mar 30, 2013
Tapestry5 Skicky Forms
View AppModule.java
import java.util.List;
public class AppModule
{
public static void bind(ServiceBinder binder) throws ClassNotFoundException
{
binder.bind(StickyFormSource.class, StickyFormSourceImpl.class);
}
@Contribute(StickyFormSource.class)
View EventResponseRenderer.java
public interface EventResponseRenderer
{
String render(RenderEvent renderEvent);
}
View CompanyBlocks.java
import x.y.z.entities.Company;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
public class CompanyBlocks
{
@Property private Company company;
@dmitrygusev
dmitrygusev / AppModule.java
Created May 12, 2013
Eager load Tapestry5 services on startup
View AppModule.java
public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration,
@Symbol(TapestryEagerLoadInitializer.FORCE_EAGER_LOAD) boolean forceEagerLoad)
{
if (forceEagerLoad)
{
configuration.addInstance("EagerLoad", TapestryEagerLoadInitializer.class, "before:*");
}
}