Skip to content

Instantly share code, notes, and snippets.

View aasokan's full-sized avatar

Archana Asokan aasokan

View GitHub Profile
@aasokan
aasokan / guice_field_injection
Created January 30, 2015 23:53
Guice - Field Injection
public class BrewingVat {
@Inject Barley barley;
@Inject Yeast yeast;
public Beer brew() {
//make some beer from ingredients
}
}
@aasokan
aasokan / guice_compact_setter
Created January 30, 2015 23:41
Guce - Compact Setter Injection
public class Amplifier {
private Guitar guitar;
private Speaker speaker;
private Footpedal footpedal;
private Synthesizer synthesizer;
@Inject
public void set(Guitar guitar, Speaker speaker, Footpedal footpedal,
Synthesizer synthesizer) {
this.guitar = guitar;
@aasokan
aasokan / maven_test_logs
Last active August 29, 2015 14:13
Redirect maven surefire test logs to file
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
------------------------------
@aasokan
aasokan / mvn_cheatsheet
Created January 8, 2015 00:22
Maven Cheatsheet
mvn -DskipTests package
mvn clean package
mvn -pl util_scripts -am -Dtest=RandomUnitTest#randomUnitTest -DfailIfNoTests=false test -Dpmd.skip=true
**************************
REMOTE DEBUG
By default, Maven runs your tests in a separate ("forked") process. You can use the maven.surefire.debug property to debug your forked tests remotely, like this:
mvn -Dmaven.surefire.debug test
@aasokan
aasokan / formatted_save_intellij
Created January 8, 2015 00:15
"Formatted Save" in IntelliJ
Make a macro (I used Organize Imports, Format Code, Save All)
Assign it a keystroke (I overrode ctrl+s)
Note: You will have to check the box "Do not show this message again" the first time for the organized imports, but it works as expected after that.
Step-by-step for IntelliJ 10.0:
Code -> "Optimize Imports...", if a dialogue box appears, check the box that says "Do not show this message again.", then click "Run".
Tools -> "Start Macro Recording"
Code -> "Optimize Imports..."
Code -> "Reformat Code..."
@aasokan
aasokan / NotDocIdSet.java
Created January 8, 2015 00:10
Negate a Lucene DocIdSet
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import java.io.IOException;
/**
* Negates the Given DocIdSet
@aasokan
aasokan / AndDocIdSet.java
Last active August 29, 2015 14:13
Simple AndDocIDSet Wrapper for Lucene
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.FilteredDocIdSet;
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import java.io.IOException;
/**
* AndDocIdSet