Skip to content

Instantly share code, notes, and snippets.

@ansell
ansell / repositorymanagement.rj
Created March 25, 2014 04:40
Repository management graph created by PODD due to different ontologies selected by different users
{
"urn:podd:repository:3efbe347-408b-4476-ad06-e8dec8eb368e" : {
"http://purl.org/podd/ns/repository#containsSchemaIRI" : [ {
"value" : "http://purl.org/podd/ns/dcTerms",
"type" : "uri"
}, {
"value" : "http://purl.org/podd/ns/foaf",
"type" : "uri"
}, {
"value" : "http://purl.org/podd/ns/poddBase",
import org.junit.Before;
import org.junit.Test;
import sun.misc.Unsafe;
import sun.reflect.ReflectionFactory;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import static org.junit.Assert.assertEquals;
@ansell
ansell / CSVAggregator.java
Last active August 29, 2015 14:04
Aggregation of CSV rows using Java-8 functions
/**
* Finds a unique result in the given file, based on examining rows from the CSV and comparing
* them sequentially down the file using the given value aggregator function.
*
* @param <T>
* The type of the value that is being compared.
* @param <R>
* The type of the value that is being returned as the aggregation.
* @param nextFile
* The file to check
@ansell
ansell / R-Installation
Last active August 29, 2015 14:08
Installing R
sudo apt-get install r-base r-base-dev r-doc-pdf r-mathlib autoconf2.13 r-cran-rcurl libcurl4-openssl-dev
Download RStudio from : http://www.rstudio.com/products/rstudio/
Inside RStudio run:
install.packages("devtools")
install.packages("ggplot2")
import org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression;
public class LinearRegression {
public static void main(String[] args) {
double [] y = {-0.48812477, 0.33458213,
-0.52754476, -0.79863471,
-0.68544309, -0.12970239,
0.02355622, -0.31890850,
0.34725819, 0.08108851};
double [][] x = {{1,0}, {0,0},
{1,0}, {2,1},
@ansell
ansell / gist:1141581
Created August 12, 2011 06:36
Restlet web.xml skeleton
<!-- Application class name -->
<context-param>
<param-name>org.restlet.application</param-name>
<param-value>
mypackage.WebSiteApplication
</param-value>
</context-param>
<!-- Restlet adapter -->
<servlet>
@ansell
ansell / gist:1167214
Created August 24, 2011 03:03
Tasks to add dynamic service support in queryall
1. Create class QueryTypeEnum extends QueryAllEnum
2. Create interface QueryTypeParser extends QueryAllParser<QueryType>
3. Create interface QueryTypeFactory extends QueryAllFactory<QueryTypeEnum, QueryTypeParser, QueryType>
4. Create class QueryTypeRegistry extends AbstractServiceLoader<QueryTypeEnum, QueryTypeFactory>
import org.restlet.Context;
import org.restlet.Request;
import org.restlet.Response;
import org.restlet.data.Reference;
import org.restlet.resource.Directory;
public class ClassLoaderDirectory extends Directory {
private ClassLoader _cl;
private static class CompositeClassLoader extends ClassLoader {
private Vector<ClassLoader> classLoaders = new Vector<ClassLoader>();
@Override
public URL getResource(String name) {
for (ClassLoader cl : classLoaders) {
URL resource = cl.getResource(name);
michaels-imac:stardog-1.2.1 mhgrove$ ./stardog-admin db drop -n testRulesDB
Successfully deleted database 'testRulesDB'.
michaels-imac:stardog-1.2.1 mhgrove$ ./stardog-admin db create -n testRulesDB
Successfully created database 'testRulesDB'.
michaels-imac:stardog-1.2.1 mhgrove$ ./stardog data add -u admin -p admin testRulesDB ~/Downloads/rules.ttl
Adding data from file: /Users/mhgrove/Downloads/rules.ttl
Added 42 RDF triples.