Skip to content

Instantly share code, notes, and snippets.

@eyalgo
eyalgo / maven-settings.sh
Created February 28, 2014 23:10
Small settings file for maven to be loaded (M2_HOME and M2)
# /etc/profile.d/maven-settings.sh Maven related stuff
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.1
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
@eyalgo
eyalgo / java-settings.sh
Last active August 29, 2015 13:56
Settings of java under profile.d (JAVA_HOME and path)
# /etc/profile.d/java-settings.sh
OLD
# export JAVA_HOME=/usr/java/jdk1.7.0_51
# export PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME=/usr/java/jdk1.8.0
@eyalgo
eyalgo / .gitignore-intellij
Created March 7, 2014 20:54
gitignore for IntelliJ
### Java ###
*.class
# Package Files #
*.jar
*.war
*.ear
### IntelliJ ###
*.iml
@eyalgo
eyalgo / pgsql-data-settings.sh
Last active August 29, 2015 13:57
Environment settings for PostgreSQ
# /etc/profile.d/pgsql-data-settings.sh
export PGDATA=/usr/local/pgsql/data
@eyalgo
eyalgo / SafeGetCollectionFromMap.java
Last active August 29, 2015 13:58
Safe get from map that holds Collection as value
// The code
public static <T, V> Collection<V> safeGetCollectionFromMap(Map<T, ? extends Collection<V>> map, T key) {
if (map.get(key) != null) {
return map.get(key);
} else {
return Lists.newLinkedList();
}
}
// The tests
@eyalgo
eyalgo / pom.xml
Last active August 29, 2015 14:02
Skeleton pom file.Contains compiler plugin and test dependencies
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId> put the group id </groupId>
<artifactId> put the artifact id </artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name> the name </name>
/opt/hbase/hbase-0.94.18/bin/start.sh
/opt/hbase/hbase-0.94.18/bin/stop.sh
/opt/hbase/hbase-0.94.18/bin/rolling-restart.sh
public class DbCleanupRule implements TestRule {
private final DbConnectionManager connection;
public DbCleanupRule(DbConnectionManager connection) {
this.connection = connection;
}
@Override
public Statement apply(Statement base, Description description) {
return new DbCleanupStatement(base, connection);
public class DbConnectionRule extends ExternalResource {
private DbConnectionManager connection;
public DbConnectionRule() {
}
@Override
protected void before() throws Throwable {
ClassPathXmlApplicationContext ctx = null;
try {
@ContextConfiguration(locations = { "/META-INF/one-dao-TEST-ctx.xml", "/META-INF/two-TEST-ctx.xml" })
public class ExampleDaoTest extends AbstractJUnit4SpringContextTests {
@ClassRule
public static DbCleanupRule connectionRule = new DbCleanupRule ();
@Rule
public DbCleanupRule dbCleanupRule = new DbCleanupRule(connectionRule.getDbConnecttion());
@Autowired