Skip to content

Instantly share code, notes, and snippets.

@rkroll
rkroll / Histogram Oddness
Created December 16, 2010 18:12
Displays the histogram oddness on dates
// delete the index
curl -XDELETE 'http://localhost:9200/test/'
// create index
curl -XPUT 'http://localhost:9200/test/' -d '
{
index : {
number_of_shards : 5,
number_of_replicas : 0
@rkroll
rkroll / query_string_double_quote
Created December 21, 2010 20:17
Query search string containing non-closed double quote
[2010-12-21 15:15:46,708][DEBUG][action.search.type ] [Oracle] [redflag][14], node[BIjCua6SR8CUaN6YRSKruw], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@704c98f1]
java.lang.ArrayIndexOutOfBoundsException: 549
at org.elasticsearch.common.Unicode.UTF8toUTF16(Unicode.java:188)
at org.elasticsearch.common.Unicode.unsafeFromBytesAsUtf16(Unicode.java:104)
at org.elasticsearch.common.Unicode.fromBytes(Unicode.java:78)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:416)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:335)
at org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:153)
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteDfs(SearchServiceTransportAction.java:101)
at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchDfsQueryThenFetchAction.java:82)
@rkroll
rkroll / gist:1097269
Created July 21, 2011 14:09
VendorSearchCallback
public interface VendorQueryCallback extends ClientCallback<SearchResponse>{
ActionFuture<SearchResponse> execute(final Client client);
}
public class VendorQueryCallbackImpl implements VendorQueryCallback {
private final VendorSearchQuery query;
public VendorQueryCallbackImpl(VendorSearchQuery query) {
this.query = query;
@rkroll
rkroll / gist:1114071
Created July 29, 2011 15:43
git diff local to master before push
git diff origin/master..
@rkroll
rkroll / Tuple.java
Created August 22, 2011 19:36
A tuple impl
package adt.reflexam.common.collect;
public class Tuple<V1, V2> {
public static <V1, V2> Tuple<V1, V2> tuple(V1 v1, V2 v2) {
return new Tuple<V1, V2>(v1, v2);
}
private final V1 v1;
private final V2 v2;
@rkroll
rkroll / gist:1171165
Created August 25, 2011 17:04
reflex LOC
As of 8/25/2011
reflex-am-web:
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Javascript 58 3824 3646 17015
CSS 27 2500 1506 16215
HTML 136 1777 839 15612
Java 155 2000 600 6581
@rkroll
rkroll / createUser
Created October 3, 2011 16:11
createUser
public User createUser(Account account, User user) {
account.addUser(user);
save(account);
//TODO - announce UserCreatedEvent
//TODO - move to listener
ObjectIdentity oid = new ObjectIdentityImpl(account);
securityService.createPermission(oid, new PrincipalSid(user.getUsername()), BasePermission.READ);
@rkroll
rkroll / gist:1309033
Created October 24, 2011 13:33
DatabaseUpgrader.valueOf(string)
private static final String DOT = ".";
public static DatabaseVersion valueOf(String string) {
DatabaseVersion version;
if(StringUtils.contains(string, DOT)) {
String[] versionParts = StringUtils.split(string, DOT);
if(versionParts.length != 2) {
throw new IllegalArgumentException("Could not parse version number '" + string + "'");
@rkroll
rkroll / gist:1309978
Created October 24, 2011 19:59
Phone numbers @OrderColumn
create table users_phone_number (users_id int8 not null, phone_numbers_id int8 not null, phone_order int8 not null, primary key (users_id, phone_numbers_id));
alter table users_phone_number add constraint FKUSERPHONEUSER foreign key (users_id) references users;
alter table users_phone_number add constraint FKUSERPHONEPHONE foreign key (phone_numbers_id) references phone_number;
@OneToMany(cascade = CascadeType.ALL)
@OrderColumn(name = "phone_order")
public List<PhoneNumber> getPhoneNumbers() {
return phoneNumbers;
@rkroll
rkroll / gist:1314110
Created October 25, 2011 20:18
Instantiate a Google MultiMap
Multimaps.newListMultimap(new HashMap<String, Collection<String>>(), new Supplier<List<String>>() {
@Override
public List<String> get() {
return new ArrayList<String>();
}
});