Skip to content

Instantly share code, notes, and snippets.

View randerzander's full-sized avatar

Randy Gelhausen randerzander

View GitHub Profile
@randerzander
randerzander / cell.scala
Created April 23, 2016 18:00
Reading from NiFi into Spark Streaming
import org.apache.nifi.remote.client.SiteToSiteClientConfig
import org.apache.nifi.remote.client.SiteToSiteClient
import org.apache.nifi.spark.NiFiReceiver
import org.apache.spark._
import org.apache.spark.streaming._
val ssc = new StreamingContext(sc, Seconds(2))
val wifiConfig = new SiteToSiteClient.Builder()
.url("http://raspberrypi:8080/nifi")
.portName("wifi")
@randerzander
randerzander / cell1.html
Created April 5, 2016 01:58
Give Zeppelin interpreter results to arbitrary JS
%angular
<div id='testDiv'>
</div>
<script>
var el = angular.element($('#testDiv').parent('.ng-scope'));
angular.element(el).ready(function() {
window.locationWatcher = el.scope().compiledScope.$watch('dummy', function(newValue, oldValue) {
$('#testDiv').append(newValue);
});
});
@randerzander
randerzander / map.js
Last active April 3, 2016 06:16 — forked from granturing/reactive_map.js
Sample reactive Leaflet code for Zeppelin
%angular
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.5/leaflet.css" />
<div id="map" style="height: 500px; width: 100%"></div>
<script type="text/javascript">
function initMap() {
var map = L.map('map').setView([30.00, -30.00], 3);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
var geoMarkers = L.layerGroup().addTo(map);
#!/bin/bash
#set -eu
source /root/.bashrc
MODE=$1
MASTER_FQDN=$2
NIFI_HOME=$3
HOSTNAME=$(hostname -f)
@randerzander
randerzander / dbf2csv.py
Last active September 9, 2015 22:47
export dbf to csv file
#!/usr/bin/python
import sys, pyproj, shapefile
input_file = sys.argv[1]
output_file = sys.argv[2]
source_spatialref = sys.argv[3]
target_spatialref = sys.argv[4]
sf = shapefile.Reader(input_file)
shapes = sf.shapes()
@randerzander
randerzander / tickets.py
Last active August 18, 2020 16:48
SalesForce open cases list
# See https://pip.pypa.io/en/latest/installing.html for how to install pip, then:
# pip install simple-salesforce
from simple_salesforce import Salesforce
import string
# To get your SFDC token, see https://help.salesforce.com/apex/HTViewHelpDoc?id=user_security_token.htm
# salesforce_login.txt should contain the following, one per line:
# Your Name
# your_email@sfdc_account.com
# your_password
@randerzander
randerzander / gist:00acd97c7f0c757109d8
Last active February 23, 2017 16:55 — forked from nsabharwal/gist:600bef5a0454e0738a93
Syslog -> Flume Agent -> Kafka -> Kafka Mirror Maker
# Configure Flume agent (/etc/flume/conf/flume.conf) to receive syslog messages
agent.sources=syslogsource-1
agent.channels=mem-channel-1
agent.sinks=kafka-sink-1
agent.sources.syslogsource-1.type=syslogtcp
agent.sources.syslogsource-1.port=13073
agent.sources.syslogsource-1.host=0.0.0.0
agent.sources.syslogsource-1.channels=mem-channel-1
@randerzander
randerzander / pyPhoenix
Created April 20, 2015 18:09
Apache Phoenix via Python
import jaydebeapi
conn = jaydebeapi.connect('org.apache.phoenix.jdbc.PhoenixDriver', \
['jdbc:phoenix:my_zk_server:2181:/hbase-unsecure', '', ''], \
'/usr/hdp/current/phoenix-client/phoenix-client.jar')
curs = conn.cursor()
curs.execute('select * from WEB_STAT limit 1')
curs.fetchall()
@randerzander
randerzander / compress.sh
Created April 19, 2015 17:35
tar and gzip everything in a directory
DIR=$1
cd $DIR
for file in *
do
tar -czvf $file.tgz $file/
done
@randerzander
randerzander / csv2ddl.sh
Last active August 29, 2015 14:19
csv2ddl
set -eu
FILE=$1
HEADER_LINE_NUM=$2
DELIM=$3
TABLE_NAME=$4
LOCATION=$5
# This script assumes columns are all strings. Edit the DDL file after running the script and change column types at will.