Skip to content

Instantly share code, notes, and snippets.

@amihalik
amihalik / foo.java
Last active April 2, 2018 18:38
Six String example
public class foo {
public static void main(String[] args) throws Exception {
String long_string = "asdfasdf123456";
String six_string = "123456";
String five_string = "12345";
String one_string = "1";
String empty_string = "";
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@amihalik
amihalik / ParsingExample.java
Created May 31, 2017 16:50
A "Pre Java 8" and Java 8 example of parsing a date/time string
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class ParsingExample {
@amihalik
amihalik / Vangrantfile
Created November 18, 2016 20:40
A simple dev box in vagrant
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.provider "virtualbox" do |vb|
vb.name = "dev-box"
vb.memory = "4096"
vb.cpus = 4
end
@amihalik
amihalik / AccumuloTemporalIndexer.java
Last active August 25, 2016 13:11
"Print line Debugging" updates to AccumuloTemporalIndexer, a RyaDirectExample exposing the query planning bug, and the output showing the bad query plan and evidence of a cross product
package mvm.rya.indexing.accumulo.temporal;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
import mvm.rya.api.RdfCloudTripleStoreConfiguration;
import mvm.rya.indexing.accumulo.ConfigUtils;
import mvm.rya.indexing.accumulo.geo.GeoConstants;
import mvm.rya.mongodb.MongoDBRdfConfiguration;
import mvm.rya.sail.config.RyaSailFactory;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.openrdf.model.vocabulary.RDFS;
import org.openrdf.query.QueryLanguage;
import org.apache.commons.io.IOUtils;
import org.openrdf.rio.ntriples.NTriplesWriter;
import org.openrdf.rio.turtle.TurtleParser;
public class TurtleFileParsingExample {
public static final String TTL = "@prefix images: <http://www.somepublisher.com/img/> . \n"
+ "@prefix isi: <http://www.isi.edu/ikcap/Wingse/fileOntology.owl#> . \n"
+ "images:f43240.jpg isi:hasMetadata <http://www.somepublisher.com/ns/m43240> .";
<html>
<body>
<h2>Remove Url Defense</h2>
<form method="post" action="fixUrls">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">Enter URL Defended Text here:&nbsp;</td>
</tr>
<tr>
@amihalik
amihalik / NormalizedGini.java
Last active August 29, 2015 14:05
NormalizedGini
import java.util.Arrays;
import java.util.Comparator;
public class NormalizedGini {
private static double gini(double[] a, double[] p, double[] w) {
int len = a.length;
if (p.length != len || w.length != len) {
throw new IllegalArgumentException("array length not equal");
}