Skip to content

Instantly share code, notes, and snippets.

// search for all Annotations and get its keywords string
final String documentClass = "Annotation";
Object[] queryParameters = new Object[]{"1", "bscw:name", "*"};
allAnnotations = (Object[]) client.execute(BSCWMethods.find, new Object[]{"0", documentClass, queryParameters, new Object[]{"id", BSCWAttributes.BSCW_KEYWORDS}});
[
{
"id": "c4b7b11b-47de-4a0f-8d57-0fdb26a19160",
"feature": "feature4",
"polarityValue": 0.27951066080617004,
"polarity": {
"id": "995b7f99-bbc4-4abe-aaf1-bec3c1e809b7",
"positive": true
},
"extractedFrom": "http://item.com/1"
@mox601
mox601 / gist:5046432
Created February 27, 2013 08:54
guice injection of properties
//in jersey servlet modules
final Properties properties = PropertiesHelper.readFromClasspath("/wp5services.properties");
// binds the keynames as @Named annotations
Names.bindProperties(binder(), properties);
this.properties = properties;
//to init stuff from custom factories
bind(Directory.class).toInstance(getDirectory());
import Timestamped;
import java.util.Date;
import java.util.List;
public interface Repository<K, V extends Timestamped> {
void store(K key, V timestampedValue);
V getLatest(K key);
{
"published": "2011-02-10T15:04:55Z",
"actor": {
"url": "http://example.org/martin",
"objectType" : "person",
"id": "tag:example.org,2011:martin",
"image": {
"url": "http://example.org/martin/image",
"width": 250,
"height": 250
@BeforeClass
protected void setUpMongoInstance() throws Exception {
// final IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
// .defaultsWithLogger(Command.MongoD, LOGGER)
// .build();
final MongodStarter runtime = MongodStarter.getDefaultInstance();
mongodExecutable = runtime.prepare(new MongodConfig(Version.Main.DEVELOPMENT, PORT,
Network.localhostIsIPv6()));
Jan 20, 2014 7:14:45 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/endpoint] appears to have started a thread named [com.google.inject.internal.util.$Finalizer] but has failed to stop it. This is very likely to create a memory leak.
Jan 20, 2014 7:14:45 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/endpoint] created a ThreadLocal with key of type [com.codahale.metrics.ThreadLocalRandom$1] (value [com.codahale.metrics.ThreadLocalRandom$1@6b4d6015]) and a value of type [com.codahale.metrics.ThreadLocalRandom] (value [com.codahale.metrics.ThreadLocalRandom@24df39bc]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Jan 20, 2014 7:14:45 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/endpoint] created a ThreadLocal with key of type [com.google.inject.internal.InjectorImpl$1] (value [com
234 [main] DEBUG org.apache.commons.httpclient.MultiThreadedHttpConnectionManager - HttpConnectionManager.getConnection: config = HostConfiguration[host=http://vmegov01.deri.ie:8080], timeout = 0
235 [main] DEBUG org.apache.commons.httpclient.MultiThreadedHttpConnectionManager - Allocating new connection, hostConfig=HostConfiguration[host=http://vmegov01.deri.ie:8080]
242 [main] DEBUG org.apache.commons.httpclient.HttpConnection - Open connection to vmegov01.deri.ie:8080
2370 [main] DEBUG org.apache.commons.httpclient.HttpMethodDirector - Closing the connection.
2370 [main] INFO org.apache.commons.httpclient.HttpMethodDirector - I/O exception (java.net.ConnectException) caught when processing request: Connection refused
2371 [main] DEBUG org.apache.commons.httpclient.HttpMethodDirector - Connection refused
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.n
@mox601
mox601 / gist:10981419
Last active November 29, 2017 08:56
google script: automatic heading
/* taken from https://productforums.google.com/d/msg/docs/w4MXeqJaefU/tPjnI2l2TJUJ */
function addHeaderNumbering () {
var pars = DocumentApp.getActiveDocument().getBody().getParagraphs();
var counterHeader = [0, 0, 0, 0, 0, 0];
for(var i=0; i<pars.length; i++) {
var par = pars[i];
var hdg = par.getHeading();
if (hdg == DocumentApp.ParagraphHeading.HEADING1) {
/* http://webapps.stackexchange.com/questions/23861/header-numbering-in-google-docs */
var pars = DocumentApp.getActiveDocument().getBody().getParagraphs();
for(var i=0; i<pars.length; i++) {
var par = pars[i];
var hdg = par.getHeading();
if (hdg == DocumentApp.ParagraphHeading.HEADING1) {
counterh1 = counterh1+1; counterh2 = 0; counterh3 = 0; counterh4 = 0; counterh5 = 0; counterh6 = 0;
var content = par.getText();
var chunks = content.split('\t')