Skip to content

Instantly share code, notes, and snippets.

View sblack4's full-sized avatar
:shipit:
taking care of business

Steven B sblack4

:shipit:
taking care of business
View GitHub Profile
@sblack4
sblack4 / gist:0f083a798f6dfd40640a62162785c2cb
Last active May 31, 2018 04:54 — forked from nathanlong/gist:bc1d4923982ad45e9379
Local Servers from the Command Line
# Drop these functions into your ~/.bashrc or ~/.bash_profile, wherever you keep your bashy goodness.
# Usage: cd to directory you want to serve up, fire one of these commands, navigate to http://0.0.0.0:{port number here}
# Start an HTTP server from a directory, optionally specifying the port
function serverpy() {
local port="${1:-8000}"
open "http://localhost:${port}/"
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
@sblack4
sblack4 / vnc_port_forward.sh
Created June 9, 2018 17:06
ssh command for vnc
#!/bin/bash
echo "... sshing to vncserver once we get some info ..."
echo "enter ip e.g. 123.456.789"
read HOST_IP
echo "enter username e.g. ubuntu"
read USERNAME
@sblack4
sblack4 / .gitignore
Last active September 5, 2018 18:54
Python app to mock a Kafka producer using a CSV file
*.log
*.swp
*.out
__pycache__
@sblack4
sblack4 / Stream_Producer.json
Last active August 30, 2018 23:59
Zeppelin notebook to view a mocked twitter stream
{"paragraphs":[{"title":"Add your Event Hub connection details","text":"%spark2\nz.angularBind(\"BIND_ObjectStorage_Container\", \"\")\nz.angularBind(\"BIND_OEHCS_ConnectionDescriptor\", z.input(\"OEHCS_ConnectionDescriptor\",\"129.150.212.124:6667\"))\nz.angularBind(\"Tweets_Topic\", z.input(\"Tweets_Topic\",\"idcs-363b4236183e42f68a92d1c5ad79728e-lumiere\"))\nz.angularBind(\"Survey_Topic\", z.input(\"Survey_Topic\",\"idcs-363b4236183e42f68a92d1c5ad79728e-lumiere\"))\n\n//save these for pyspark\nz.put(\"Tweets_Topic\", z.angular(\"Tweets_Topic\"))\nz.put(\"Survey_Topic\", z.angular(\"Survey_Topic\"))\nz.put(\"BIND_OEHCS_ConnectionDescriptor\", z.angular(\"BIND_OEHCS_ConnectionDescriptor\"))\n\n//save these for shell\nscala.tools.nsc.io.File(\"/var/lib/zeppelin/oehcs.sh\").writeAll(\n \"export ObjectStorage_Container=\\\"\"+z.angular(\"BIND_ObjectStorage_Container\")+\"\\\"\\n\" +\n \"export OEHCS_ConnectionDescriptor=\\\"\"+z.angular(\"BIND_OEHCS_ConnectionDescriptor\")+\"\\\"\\n\" +\n \"export Tweets_To
@sblack4
sblack4 / bootstrap.sh
Last active September 10, 2018 16:51
Bootstrap files for the Realtime Analytics workshop
#!/bin/bash
#
# by http://sblack4.github.io - Steven.Black@Oracle.com
# updated 2018-07-30
# credit goes to David Bayard for providing the majority of this script
# see his journey 2 (where I got a lot of this) below, I highly recommend it!
# https://github.com/oracle/learning-library/tree/master/workshops/journey2-new-data-lake
#!/bin/python
"""
takes tweet dataset and transforms into tickets dataset
Category, Date, Comment, id
category: ['bug', 'ticket', 'help', 'ID10t', 'feature']
"""
import csv
@sblack4
sblack4 / make_tickets.py
Last active September 4, 2018 20:32
generate some tweets and some survey data for your next project
#!/bin/python
"""
"""
import csv
from faker import Faker
from pandas import read_csv
from datetime import date, timedelta, datetime
from random import randint, triangular, choice
@sblack4
sblack4 / config.py
Created September 5, 2018 14:40
pump two files to kafka (tweet and ticket data files in another gist)
import logging
log_level = logging.INFO
timeout = 1
kafka_host = "129.144.154.83:6667"
# tickets
key = "ticket"
topic = "idcs-c6319aeb031a417c97ac0f048627b112-conga"
@sblack4
sblack4 / convert_files.py
Last active January 15, 2022 21:00
scripts to convert markdown into .rtf
#!/anaconda3/bin/python
"""
convert_files.py
converts every file in this directory into a microsoft word file
"""
print("run from the workshops/realtime-analytics-oac-datalake")
@sblack4
sblack4 / ATPConnectionTest.java
Created October 11, 2018 15:10
Java - Scripting. Scripts I wrote in java that I can't throw away
import java.io.*;
import java.util.*;
import java.nio.file.*;
import java.lang.RuntimeException;
import java.net.URISyntaxException;
import java.lang.ProcessBuilder.Redirect;
public class ATPConnectionTest {