Skip to content

Instantly share code, notes, and snippets.

@rkroll
rkroll / gist:f5fafbb42b2fca101333
Created August 28, 2014 15:20
funky java date
@Test
public void testDate() {
{
Date date = new Date(1325376000000l);
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("US/Eastern"));
cal.setTime(date);
cal.set(Calendar.MONTH, Calendar.JANUARY);
Date timeDate = cal.getTime();
System.out.println(timeDate);
}
@rkroll
rkroll / TruncatedBinaryBackoff
Created June 19, 2014 18:38
twitter TruncatedBinaryBackoff
// =================================================================================================
// Copyright 2011 Twitter, Inc.
// -------------------------------------------------------------------------------------------------
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this work except in compliance with the License.
// You may obtain a copy of the License in the LICENSE file, or at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@rkroll
rkroll / beanValidationExample
Created June 11, 2014 19:06
Bean Validation Example
public class User {
@NotNull
@Email
private String email;
@ValidUsername
private String username;
@NotNull
private String name;
!# /usr/bin/env sh
du -s ./* | sort -n| cut -f 2-| xargs du -sh {}
@rkroll
rkroll / gist:016814536d34fc0f2f97
Created May 27, 2014 18:29
Sprint Transaction + ApplicationEventPublisher
public <T extends ApplicationEvent> void publishEvent(final T event) {
if (TransactionSynchronizationManager.isActualTransactionActive()) {
TransactionSynchronizationManager.registerSynchronization(
new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
delegate.publishEvent(event);
}
});
}
@rkroll
rkroll / gist:286bd48c5c723fe5eccc
Created May 22, 2014 16:16
LDM request/response
22 May 12:15:48,532 DEBUG org.apache.http.impl.conn.SingleClientConnManager:212 - Get connection for route HttpRoute[{s}->https://scriptguidetest.ldmgrp.com] -
22 May 12:15:48,686 DEBUG org.apache.http.impl.conn.DefaultClientConnectionOperator:145 - Connecting to scriptguidetest.ldmgrp.com/67.221.232.152:443 -
22 May 12:15:49,056 DEBUG org.apache.http.client.protocol.RequestAddCookies:132 - CookieSpec selected: best-match -
22 May 12:15:49,064 DEBUG org.apache.http.client.protocol.RequestAuthCache:75 - Auth cache not set in the context -
22 May 12:15:49,064 DEBUG org.apache.http.impl.client.DefaultRequestDirector:631 - Attempt 1 to execute request -
22 May 12:15:49,064 DEBUG org.apache.http.impl.conn.DefaultClientConnection:264 - Sending request: POST /remotebridge.aspx HTTP/1.1 -
22 May 12:15:49,065 DEBUG org.apache.http.impl.conn.Wire:63 - >> "POST /remotebridge.aspx HTTP/1.1[\r][\n]" -
22 May 12:15:49,066 DEBUG org.apache.http.impl.conn.Wire:63 - >> "Content-Length: 588[\r][\n]" -
22 May 12:15:49,0
REQUEST:
<request source="EMA_4_0" portalID="1" pformat="pcl" wformat="html" output="inline">
<rxNumber>rx_encrypted_id</rxNumber>
<productRxNorm>830648</productRxNorm>
<productNDC>00093092606</productNDC>
<quantity>10</quantity>
<patient>
<code>ABC123</code>
<firstName>John</firstName>
@rkroll
rkroll / gist:5752210
Created June 10, 2013 20:56
Geopoint Calculation facet
{
"query" : {
"match_all" : { }
},
"facets" : {
"tag" : {
"terms" : {
"field" : "geopoint_calc_method",
"size" : 10
}
@rkroll
rkroll / gist:5645851
Created May 24, 2013 19:14
Counts of geocoded addresses
Get count of geocoded addresses:
curl -v 'http://cass3:9200/addresses/address/_count' -d '{
"constant_score": {
"filter": {
"not": {
"missing": {
"field": "geo_point"
}
}
}
addresses/address/_count w/ body"
{
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"or": [
{
"missing": {