This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo su | |
yum update -y | |
yum install -y wget git | |
curl -fsSL https://get.docker.com/ | sh | |
service docker start | |
curl -L https://github.com/docker/compose/releases/download/1.15.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose | |
chmod +x /usr/local/bin/docker-compose | |
mv /usr/local/bin/docker-compose /usr/bin | |
usermod -aG docker centos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM centos | |
# minifi-cpp build | |
RUN yum install -y git | |
RUN yum install -y wget | |
RUN yum install -y epel-release | |
RUN yum groupinstall -y 'Development Tools' | |
RUN yum install -y cmake | |
RUN yum install -y boost-devel boost-static libxml2-static libxml2-devel libuuid-devel leveldb-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spark.implicits._ | |
import org.apache.spark.sql.types._ | |
import org.apache.spark.sql.Row | |
val schemaString = sc.textFile("/data.csv").take(1)(0) | |
val rdd = sc.textFile("/data.csv").filter(line => line != schemaString) | |
val fields = (schemaString.split(",").slice(0, 9) ++ Array("stat", "value")) | |
.map(fieldName => { | |
if (fieldName contains "value") | |
StructField(fieldName, DoubleType, nullable = true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from org.apache.commons.io import IOUtils | |
from java.nio.charset import StandardCharsets | |
from org.apache.nifi.processor.io import StreamCallback | |
import os, sys, imp, traceback, time | |
parser_path = '/scripts/parsers/' | |
class PyStreamCallback(StreamCallback): | |
def __init__(self, result): | |
self.result = result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from org.apache.commons.io import IOUtils | |
from java.nio.charset import StandardCharsets | |
from org.apache.nifi.processor.io import StreamCallback | |
class PyStreamCallback(StreamCallback): | |
def __init__(self): pass | |
def process(self, instream, outstream): | |
# To read content as a byte array: | |
# data = IOUtils.toByteArray(instream) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%angular | |
<div id="map" style="height:500px;width:100%;"></div> | |
<script type="text/javascript"> | |
function initMap() { | |
var USA = {lat: 39.8282, lng: -98.5795}; | |
var map = new google.maps.Map(document.getElementById('map'), {zoom: 17, center: USA }); | |
var POIs = {}; | |
$.each(window.angularVars.data, function(i, v){ | |
POIs[v.values[0]] = v.values; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%angular | |
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> | |
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> | |
<div id="mapid" style="height:500px;"></div> | |
<script type="text/javascript"> | |
var Leaflet = L.noConflict(); | |
var map = Leaflet.map('mapid', {center: [40,-97], zoom: 4}); | |
var tiles = Leaflet.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png").addTo(map); | |
var states = [{ | |
"type": "Feature", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"paragraphs": [ | |
{ | |
"title": "Page Setup", | |
"text": "%angular\n\u003cscript src\u003d\"https://cdn.plot.ly/plotly-latest.min.js\"\u003e\u003c/script\u003e\n\u003cdiv id\u003d\"dummy\" vars\u003d\"data,dataSchema\"\u003e\u003c/div\u003e\n\u003cscript type\u003d\"text/javascript\"\u003e\n var div \u003d $(\u0027#dummy\u0027);\n //Given an element in the note \u0026 list of values to fetch from Spark\n //window.angularVars.myVal will be current value of backend Spark val of same name\n function hoist(element, varNames){\n window.angularVars \u003d {};\n var scope \u003d angular.element(element.parent(\u0027.ng-scope\u0027)).scope().compiledScope;\n $.each(varNames, function(i, v){\n window[v+\u0027-watcher\u0027] \u003d scope.$watch(v, function(newVal, oldVal){\n console.log(\u0027Setting \u0027 + v + \u0027 to:\\n\u0027);\n console.log(newVal);\n window.angularVars[v] \u003d newVal;\n });\n });\n }\n hoist(div, div.attr(\u0027vars\u0027).split(\u |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%angular | |
<input id="textbox" class="hide" ng-model="someAngularVar"></input> | |
<button id="btn" type="submit" onclick="update()">UpperCase It!</button> | |
<script type="text/javascript"> | |
function update(){ | |
var element = $('#textbox'); | |
var currentVal = element.val(); | |
//Update the value | |
element.val(currentVal.toUpperCase()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get list of distinct values on a column for given table | |
def distinctValues(table: String, col: String) : Array[(String, String)] = { | |
sqlContext.sql("select distinct " + col + " from " + table + " order by " + col).collect.map(x => (x(0).asInstanceOf[String], x(0).asInstanceOf[String])) | |
} | |
//Get list of tables | |
def tables(): Array[(String, String)] = { | |
sqlContext.sql("show tables").collect.map(x => (x(0).asInstanceOf[String], x(0).asInstanceOf[String])) | |
} |