Skip to content

Instantly share code, notes, and snippets.

View robdaemon's full-sized avatar

Robert Roland robdaemon

View GitHub Profile
@robdaemon
robdaemon / sqlite-test-suite.dylan
Created August 8, 2013 05:32
Attempted macro for implementing a "with-sqlite-db"
define macro with-sqlite-db
{ with-sqlite-db (?db-location:expression) ?:body end }
=> {
let (result, sqlite3-db) = sqlite3-open(?db-location);
?body;
sqlite3-close(sqlite3-db);
}
end macro with-sqlite-db;
@robdaemon
robdaemon / KeyValueBuilder.java
Created March 20, 2013 23:46
Every once in a while you need to modify an HBase KeyValue in various ways depending on conditional logic. This is a simple builder pattern applied to a KeyValue with a copy constructor.
package com.simplymeasured.doormouse.mapreduce.utils;
import org.apache.hadoop.hbase.KeyValue;
/**
* Stupid-simple builder pattern applied to the HBase KeyValue class.
*
* Makes it easier to manipulate KeyValues in map/reduce jobs
*
* @author [email protected]
@robdaemon
robdaemon / region_counts.rb
Created March 8, 2013 21:25
Get region counts for an HBase service
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.HBaseAdmin
import org.apache.hadoop.hbase.client.HTable
import org.apache.hadoop.hbase.util.Bytes
conf = HBaseConfiguration.create()
admin = HBaseAdmin.new(conf)
tables = admin.listTables()
; nREPL 0.1.6
user> (use 'midje.repl)
CompilerException java.lang.NoClassDefFoundError: org/apache/http/client/AuthCache, compiling:(cemerick/pomegranate/aether.clj:40:54)
user> (pst)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: pst in this context, compiling:(NO_SOURCE_PATH:1:1)
user>
@robdaemon
robdaemon / repl.txt
Created February 11, 2013 00:20
nREPL error within emacs
; nREPL 0.1.6
user> (use 'midje.repl)
CompilerException java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SchemeSocketFactory, compiling:(cemerick/pomegranate/aether.clj:40:54)
user>
@robdaemon
robdaemon / AbstractModelAdapter.java
Created August 22, 2012 03:17
rejected execution exception
@Override
public void persist(Map<String, Object> data) throws Exception {
Map<String, List<Row>> databaseOperations = generateDatabaseOperations(data);
for(String table: databaseOperations.keySet()) {
List<Row> batch = databaseOperations.get(table);
PutHelper.writeToTable(connectionPool, table, batch);
}
}