Skip to content

Instantly share code, notes, and snippets.

@hertzsprung
hertzsprung / Foo.java
Created July 28, 2011 21:32
java.lang.invoke
package foo;
import static java.lang.invoke.MethodHandles.catchException;
import static java.lang.invoke.MethodHandles.publicLookup;
import static java.lang.invoke.MethodType.methodType;
public class Foo {
public void sayHello(String name) throws RuntimeException {
System.out.println("hello " + name);
throw new RuntimeException("boom!");
@hertzsprung
hertzsprung / Java7Lols.java
Created July 28, 2011 21:48
Assorted Java 7 features
package foo;
import static java.util.EnumSet.of;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
@hertzsprung
hertzsprung / AllOfTest.java
Created April 7, 2012 12:39
Test case for Hamcrest AllOf missing mismatch description
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.both;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
import org.junit.Test;
public class AllOfTest {
@Test
public void doesPrintMismatch() {
@hertzsprung
hertzsprung / ResponseMatchers.java
Created April 7, 2012 16:23
Combining Hamcrest matchers
package uk.co.datumedge.blog.hamcrest;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.both;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThan;
import javax.ws.rs.core.Response;
@hertzsprung
hertzsprung / pom.xml
Created May 5, 2012 17:24
Maven source code management information
<scm>
<connection>scm:git:git://github.com/hertzsprung/redis-launcher.git</connection>
<developerConnection>scm:git:[email protected]:hertzsprung/redis-launcher.git</developerConnection>
<url>http://github.com/hertzsprung/redis-launcher</url>
</scm>
@hertzsprung
hertzsprung / pom.xml
Created May 5, 2012 17:30
Maven release plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
</configuration>
</plugin>
@hertzsprung
hertzsprung / pom.xml
Created May 5, 2012 17:35
Maven distribution management
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus snapshot repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Sonatype Nexus release repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
@hertzsprung
hertzsprung / pom.xml
Created May 5, 2012 17:38
Maven artifact signing
<profiles>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
@hertzsprung
hertzsprung / settings.xml
Created May 6, 2012 21:57
Maven credentials
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>myusername</username>
<password>mypassword</password>
</server>
@hertzsprung
hertzsprung / Dazzle7.java
Created June 20, 2012 21:06
Java 7 ActionListener
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ui.dazzle(e.getModifiers());
}
});