Skip to content

Instantly share code, notes, and snippets.

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;
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},
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.
@ansell
ansell / start_testing_java8_today.asciidoc
Created May 18, 2016 04:16 — forked from aslakknutsen/start_testing_java8_today.asciidoc
Example of how to use both JDK 7 and JDK 8 in one build.

JDK 8 Released

Most of us won’t be able to use/deploy JDK 8 in production for a looong time. But that shouldn’t stop us from using it, right?

It should be possible to sneak in JDK 8 in the back way, the same way we snuck in Groovy and other libraries we wanted to use.

The Test Suite to the rescue

The Maven compiler plugin run in two separate lifecycles, compile and testCompile. Those can be configured separately.

@ansell
ansell / gist:3f40f066b76a1df7ab849cc695bdfa91
Last active June 1, 2018 03:24 — forked from WintersMichael/gist:c70d195c5c5670d1625f
Shell one-liner to parse apache access logs and extract a unique URL list with hit count, querystring excluded.
cat access.log | awk -F\" '{print $2}' | awk '{print $2}' | sed '/^$/d' | sed 's/\?.*//g' | sort | uniq -c | sort -rn > url_hits.txt
cat access.log | awk -F\" '{print $2}' | awk '{print $2}' | sed '/^$/d' | sort | uniq -c | sort -rn > url_with_paths_hits.txt
cat access.log | awk -F\" '{print $2}' | awk '{print $2}' | sed '/^$/d' > raw_url_with_paths.txt
@ansell
ansell / install_postgresql9.4_postgis2.1_ubuntu.md
Last active February 26, 2019 09:17 — forked from hewerthomn/install_postgresql9.3_postgis2.1_ubuntu.md
Installing PostgreSQL 9.4 and PostGIS on Ubuntu 14.04

Remove old PostGIS Installation

The first step is to remove older version of PostGIS if any.

sudo apt-get purge postgis

Setup repository

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
@ansell
ansell / solr-filter.conf
Created April 18, 2019 03:23 — forked from sebnmuller/solr-filter.conf
Logstash config for ingesting Solr logs
input {
file {
path => "/Users/sebastienmuller/comperio/projects/sintef/tmp/logs/indexing_logs_2/solr.log.3"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
# Extract event severity and timestamp
@ansell
ansell / install-java.sh
Created August 14, 2019 01:35
HomeBrew Revert to Java8 from Java9
#!/usr/bin/env bash
set -e
# Uninstall Java 9 off the bat, so we can fix our local installation
if brew cask ls --versions "java" &>/dev/null; then
echo "Uninstalling Java"
brew cask uninstall java
fi
# Install jenv, java8 and java9
brew install jenv
brew cask install caskroom/versions/java8