Skip to content

Instantly share code, notes, and snippets.

/**
* This file is licensed to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@tomgullo
tomgullo / MockHTable.java
Created September 30, 2015 18:12 — forked from agaoglu/MockHTable.java
MockHTable
/**
* This file is licensed to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@tomgullo
tomgullo / storm_locally.sh
Created March 24, 2015 20:13
execute storm locally
mvn compile exec:java -Dexec.mainClass="MyTopology" -Dexec.args="-somekey someval" -P local
@tomgullo
tomgullo / CosineDocumentSimilarity.java
Created March 24, 2015 13:03
Program that demonstrates cosine similarity
import java.io.IOException;
import java.util.*;
import org.apache.commons.math3.linear.*;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.core.SimpleAnalyzer;
import org.apache.lucene.document.*;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.index.*;
import org.apache.lucene.store.*;
@tomgullo
tomgullo / worlds_smalles_solr_program.groovy
Created March 3, 2015 20:11
Worlds smallest Solr program
@Grapes([
@Grab('org.apache.solr:solr-solrj:4.5.0'),
@Grab(group='org.apache.solr', module='solr-core', version='4.5.0'),
@GrabExclude('org.restlet.jee:org.restlet'),
@GrabExclude('org.restlet.jee:org.restlet.ext.servlet'),
])
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
1. Copy solrconfig.xml to /example/solr/collection1/conf
2. Copy schema.xml to /example/solr/collection1/conf
3. (optional) If you have use special classes for geospatial copy jts.jar over to /example/solr-webapp/../WEB-INF/lib
4. In example directory run java -jar start.jar
Query:
#!/bin/sh
curl http://localhost:8983/solr/collection1/query?q=*:*
Update:
//delete jars not wanted in war (ideally exclude in Maven or Gradle)
grails.war.resources = { stagingDir ->
delete(file:"${stagingDir}/WEB-INF/lib/my-jar-name.jar")
}
@tomgullo
tomgullo / run_groovy.gradle
Last active September 17, 2015 20:24
run groovy in gradle
//You can create src/main/groovy, put your script called 'myscript.groovy' in there:
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'application'
configurations {
excludeFromJar
compile.extendsFrom excludeFromJar
}
@tomgullo
tomgullo / word_wrap_d3js_treemap.js
Last active December 24, 2015 02:49
snippet to word wrap text in d3js treemap
....
text = cell.append("text")
.attr("x", function(d) { return d.dx / 2; })
.attr("y", function(d) { return d.dy / 2; })
.attr("dy", ".35em")
.attr("text-anchor", "middle")
.style("opacity", function(d) { d.w = this.getComputedTextLength(); return d.dx > d.w ? 1 : 0; })
.text(function(d) { return d.name });
var temp_text = text.text();
@tomgullo
tomgullo / tree_map_d3js.html
Created September 26, 2013 10:48
tree_map_d3js
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
position: relative;
}