Skip to content

Instantly share code, notes, and snippets.

@devnulled
devnulled / gist:2401262
Created April 16, 2012 20:22
Jackson 1.9 - Ignore Properties That Don't Exist on Bean
ObjectMapper mapper = new ObjectMapper();
mapper.getDeserializationConfig().without(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
@devnulled
devnulled / gist:2369406
Created April 12, 2012 17:33
Build A Simple Expiring Cache Based On Time
// Requires Google Guava 10 or greater
Cache<Key, Graph> graphs = CacheBuilder.newBuilder()
.concurrencyLevel(4)
.weakKeys()
.maximumSize(10000)
.expireAfterWrite(10, TimeUnit.MINUTES)
.build(
new CacheLoader<Key, Graph>() {
public Graph load(Key key) throws AnyException {
@devnulled
devnulled / gist:2369299
Created April 12, 2012 17:21
Using Commons HTTP Client 3.1 With a Proxy + SSL Self Generated Certificate
Protocol easyhttps = new Protocol("https", (ProtocolSocketFactory)new EasySSLProtocolSocketFactory(), 443);
Protocol.registerProtocol("https", easyhttps);
HttpClient client = new HttpClient();
HostConfiguration config = client.getHostConfiguration();
config.setProxy("localhost", 8888);
@devnulled
devnulled / gist:2303585
Created April 4, 2012 16:31
Scala Test + Mockito + TestNG Template for IntelliJ
#if (${PACKAGE_NAME} == "" )package ${PACKAGE_NAME}
#end
import org.scalatest.Assertions
import org.scalatest.mock.MockitoSugar
import org.testng.annotations.Test
import org.scalatest.Assertions
import org.scalatest.mock.MockitoSugar
import org.testng.Assert._
@devnulled
devnulled / gist:2026961
Created March 13, 2012 05:18
Generate Secure RSA Key on Mac
ssh-keygen -t rsa -b 4096 -C "email@email.com"