Skip to content

Instantly share code, notes, and snippets.

harschware

Block or report user

Report or block harschware

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@harschware
harschware / TestStopWatch.java
Last active Oct 23, 2018
Test NiFi StopWatch class - demonstrates bug at NIFI-5742
View TestStopWatch.java
import org.apache.nifi.util.StopWatch;
import java.util.concurrent.TimeUnit;
class Scratch {
// https://github.com/apache/nifi/blob/02261311b3b3f765ebb394f8f101b0373a7fb3ab/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/StopWatch.java#L77
public static void main(String[] args) {
StopWatch stopWatch = new StopWatch(true);
View AddInstanceToContext,java
package harschware.sandbox.scratch;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.Arrays;
import java.util.Objects;
/**
View Driver.java
import org.springframework.aop.target.HotSwappableTargetSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
/**
* Inspired by: https://stackoverflow.com/a/12808171/154461
*/
public class SwappableBeans {
public static void main(String... args) {
@harschware
harschware / livyResultForSchemaAsJson.json
Created May 15, 2018
Livy result for schema using %json magick
View livyResultForSchemaAsJson.json
{
"code": "import org.apache.spark.sql._\nvar d = sqlContext.sql(\"SELECT tbl10.`venueid`, tbl10.`venuename`, tbl10.`venuecity`, tbl10.`venuestate`, tbl10.`venueseats`, tbl10.`processing_dttm` AS `venues_processing_dttm` FROM `concerts`.`venues` tbl10\")\nvar e = d.schema\n%json e\n",
"id": 7,
"output": {
"data": {
"application/json": [
{
"dataType": {},
"metadata": {
"map": {}
@harschware
harschware / livyResultForSchema.json
Created May 15, 2018
livy result shows dataframe.schema contains data types
View livyResultForSchema.json
{
"code": "import org.apache.spark.sql._\nvar d = sqlContext.sql(\"SELECT tbl10.`venueid`, tbl10.`venuename`, tbl10.`venuecity`, tbl10.`venuestate`, tbl10.`venueseats`, tbl10.`processing_dttm` AS `venues_processing_dttm` FROM `concerts`.`venues` tbl10\")\nd.schema\n",
"id": 5,
"output": {
"data": {
"text/plain": "import org.apache.spark.sql._\nd: org.apache.spark.sql.DataFrame = [venueid: int, venuename: string, venuecity: string, venuestate: string, venueseats: int, venues_processing_dttm: string]\nres2: org.apache.spark.sql.types.StructType = StructType(StructField(venueid,IntegerType,true), StructField(venuename,StringType,true), StructField(venuecity,StringType,true), StructField(venuestate,StringType,true), StructField(venueseats,IntegerType,true), StructField(venues_processing_dttm,StringType,true))\n"
},
"execution_count": 5,
"status": "ok"
},
@harschware
harschware / scalaLivyResult.json
Created May 11, 2018
Livy DataTypes are Missing from Schema
View scalaLivyResult.json
{
"code": "import org.apache.spark.sql._\nvar d = sqlContext.sql(\"SELECT tbl10.`venueid`, tbl10.`venuename`, tbl10.`venuecity`, tbl10.`venuestate`, tbl10.`venueseats`, tbl10.`processing_dttm` AS `venues_processing_dttm` FROM `concerts`.`venues` tbl10\")\nval e = d.take(2)\n%json e\n",
"id": 13,
"output": {
"data": {
"application/json": [
{
"schema": [
{
"dataType": {},
View parsingSkippedTests.pl
#!/usr/bin/perl
# Produces output found at the end of this script / after __END__
use TAP::Parser;
my $NO_DESC = <<EOF;
1..1
ok 1 # skip for a really good reason
EOF
@harschware
harschware / SSHJConnect.java
Created Nov 21, 2014
A class for connecting via public key exchange using SSHJ
View SSHJConnect.java
package harschware.sandbox;
import java.io.IOException;
import java.security.Security;
import java.util.concurrent.TimeUnit;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.common.IOUtils;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
View TestJena712.java
package com.hp.hpl.jena.sparql.path;
import static org.junit.Assert.assertEquals;
import java.io.File;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
View OutputOf_TestRdfXmlOnBlankNodes
2013-Oct-04 17:52:34.010 PDT DEBUG [main] [org.apache.jena.riot.stream.JenaIOEnvironment:createLocationMapper] [JenaIOEnvironment.java:181] [] [] [] - Failed to find configuration: location-mapping.ttl;location-mapping.rdf;location-mapping.n3;etc/location-mapping.rdf;etc/location-mapping.n3;etc/location-mapping.ttl
=== FILE CONTENTS ===
_:b0 <http://p> <http://o> .
=== MODEL CONTENTS ===
blank URI URI
Exception in thread "main" com.hp.hpl.jena.shared.BadURIException: Only well-formed absolute URIrefs can be included in RDF/XML output: <http://> Code: 57/REQUIRED_COMPONENT_MISSING in HOST: A component that is required by the scheme is missing.
at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.checkURI(BaseXMLWriter.java:820)
at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.xmlnsDecl(BaseXMLWriter.java:339)
at com.hp.hpl.jena.xmloutput.impl.Basic.writeRDFHeader(Basic.java:64)
at com.hp.hpl.jena.xmloutput.impl.Basic.writeBody(Basic.java:47)
You can’t perform that action at this time.