Skip to content

Instantly share code, notes, and snippets.

View butlermh's full-sized avatar

Mark H. Butler butlermh

  • Santa Clara, United States
View GitHub Profile
@butlermh
butlermh / build.gradle
Created June 11, 2011 17:30
Building ElasticSearch in Eclipse 2
eclipseClasspath {
defaultOutputDir = file('build/eclipse-build')
}
@butlermh
butlermh / musicbrainz.rb
Created June 12, 2011 13:06
Ruby code to get JSON data from MusicBrainz and post it to a local NoSQL / Search database e.g. CouchDB, ElasticSearch
#!/usr/bin/ruby
#Retrieve data from MusicBrainz in JSON format and upload it to server
require 'rubygems'
require 'json'
require 'open-uri'
require 'active_support'
require 'net/http'
$KCODE = "UTF8"
@butlermh
butlermh / es.txt1
Created June 12, 2011 16:27
ElasticSearch indices created from a MusicBrainz recording
_all
_source
_type
_uid
artist-credit.name-credit.artist.id
artist-credit.name-credit.artist.name
artist-credit.name-credit.artist.sort-name
id
length
puid-list.puid.id
{
"recording-list":{
"offset":0,
"count":243,
"recording":[ {
"score":"100",
"id":"1d86aa9d-21a2-4504-a668-61d488d3f251",
"title":"Bowie",
"length":162400,
"artist-credit":{
@butlermh
butlermh / wishlist.rb
Created June 16, 2011 19:29
Find out what books are available on your Amazon wishlist on Kindle
#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
require 'net/http'
require 'uri'
require 'amazon/aws/search'
include Amazon::AWS
@butlermh
butlermh / boolquery.json
Created June 29, 2011 11:05
Nested boolean queries for ElasticSearch
{
"bool":{
"must":[
{
"query_string":{
"default_field":"content",
"query":"test1"
}
},
{
@butlermh
butlermh / QueryParserTest.java
Created June 29, 2011 11:09
Test that checks ElasticSearch JSON queries are valid
package org.elasticsearchtest;
import static org.elasticsearch.common.io.Streams.copyToStringFromClasspath;
import java.io.IOException;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.inject.ModulesBuilder;
import org.elasticsearch.common.settings.ImmutableSettings;
@butlermh
butlermh / HBaseConfigurationSpringWrapper.java
Created December 23, 2011 11:24
A Spring friendly wrapper for HBaseConfiguration
package org.apache.hadoop.hbase;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
public class HBaseConfigurationSpringWrapper extends HBaseConfiguration {
public HBaseConfigurationSpringWrapper(Configuration config,
Map<String, String> configParams) {
@butlermh
butlermh / applicationContext.xml
Created December 23, 2011 11:28
Snippet from Spring config file
<bean id="resourceStore" scope="singleton"
class="my.hbase.using.Webapp">
<constructor-arg>
<bean scope="singleton"
class="org.apache.hadoop.hbase.HBaseConfigurationSpringWrapper">
<constructor-arg>
<bean scope="singleton" class="org.apache.hadoop.conf.Configuration" />
</constructor-arg>
<constructor-arg>
<map>
@butlermh
butlermh / lzo-build.sh
Created December 23, 2011 13:15
Snippet from LZO build script
env CFLAGS="-m64" CXXFLAGS="-m64" ./configure --enable-shared
make
make check
make test
make DESTDIR=$PWD/build install