Skip to content

Instantly share code, notes, and snippets.

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;
@harschware
harschware / SSHJConnect.java
Created November 21, 2014 22:00
A class for connecting via public key exchange using SSHJ
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;
#!/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 / scalaLivyResult.json
Created May 11, 2018 19:47
Livy DataTypes are Missing from Schema
{
"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": {},
@harschware
harschware / livyResultForSchema.json
Created May 15, 2018 22:18
livy result shows dataframe.schema contains data types
{
"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 / livyResultForSchemaAsJson.json
Created May 15, 2018 22:22
Livy result for schema using %json magick
{
"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": {}
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) {
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;
/**
@harschware
harschware / TestStopWatch.java
Last active October 23, 2018 22:54
Test NiFi StopWatch class - demonstrates bug at NIFI-5742
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);