Skip to content

Instantly share code, notes, and snippets.

@rickhaffey
rickhaffey / reinvent-2017-youtube.md
Created October 3, 2018 15:48 — forked from stevenringo/reinvent-2017-youtube.md
Links to YouTube recordings of AWS re:Invent 2017 sessions

| Title | Description

@rickhaffey
rickhaffey / docker_cheatsheet.sh
Created April 26, 2018 15:19
docker cheatsheet
# pass through AWS credentials to docker container
# and provide OpenSSL with indication of SSL Certs location
# (based on https://gist.githubusercontent.com/cameck/9ce71ba3e447444bf7f799d92c46c171/raw/4f15f5a5073843a17a38c27bbe10e99747015d60/start.sh)
AWS_ACCESS_KEY_ID=$(aws --profile default configure get aws_access_key_id)
AWS_SECRET_ACCESS_KEY=$(aws --profile default configure get aws_secret_access_key)
docker run -it \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
@rickhaffey
rickhaffey / demo.scala
Created February 28, 2018 22:42
Scala JSON and YAML w/ Jackson
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.module.scala.DefaultScalaModule
object Json_Yaml_Demo {
case class Album(title: String)
def object_to_json(album: Album): String = {
val mapper = new ObjectMapper()
mapper.registerModule(DefaultScalaModule)
@rickhaffey
rickhaffey / spark_cheatsheet.scala
Created February 14, 2018 23:26
Spark Cheatsheet
// ## Save DF as CSV
val path = "s3://foo/bar/bat"
df
.repartition(1)
.write
.format("csv")
.option("header", "true")
.save(path)
// ## Save DF as Parquet
@rickhaffey
rickhaffey / client.py
Last active November 5, 2017 22:25
Python Chat
# Save as client.py
# Message Sender
import os
from socket import *
host = "192.168.0.105" # set to IP address of target computer
port = 13000
addr = (host, port)
UDPSock = socket(AF_INET, SOCK_DGRAM)
while True:
data = input("Enter message to send or type 'exit': ")
@rickhaffey
rickhaffey / README.md
Last active October 3, 2017 20:17
Very Basic D3 Bar-Chart

Just testing out creating a simple D3 Block

D3 Lorum Ipsum....

  • one
  • two
  • three
@rickhaffey
rickhaffey / contingency-table.py
Created April 18, 2017 19:09
Build contingency table (with row, column, and overall %s) from a Pandas DF & 2 column names
import numpy as np
import pandas as pd
def contingencyTable(df, var1, var2):
# isolate to just our 2 variables for the crosstab
df = df.loc[:, [var1, var2]]
# build a crosstab with marginal totals
ct = pd.crosstab(df[var1], df[var2], margins=True)
@rickhaffey
rickhaffey / rolling-stone-500.es.bulk-load
Created June 19, 2015 03:30
Rolling Stone 500 - Elasticsearch Bulk Load Script
POST /_bulk
{"index": {"_type": "album", "_id": "1", "_index": "rolling-stone-500"}}
{"title": "Sgt. Pepper's Lonely Hearts Club Band", "url": "http://www.rollingstone.com/music/lists/500-greatest-albums-of-all-time-20120531/the-beatles-sgt-peppers-lonely-hearts-club-band-20120531", "imageUrl": "http://assets.rollingstone.com/assets/images/list/8f5a817710d65dcedfe55ca22a7d79c2e7259e6c.JPG", "artist": "The Beatles", "rank": 1, "label": "Capitol", "year": 1967, "summary": "Sgt. Pepper's Lonely Hearts Club Band is the most important rock & roll album ever made, an unsurpassed adventure in concept, sound, songwriting, cover art and studio technology by the greatest rock & roll group of all time. From the title song's regal blasts of brass and fuzz guitar to the orchestral seizure and long, dying piano chord at the end of \"A Day in the Life,\" the 13 tracks on Sgt. Pepper's Lonely Hearts Club Band are the pinnacle of the Beatles' eight years as recording artists. John Lennon, Paul McCartney, George Harrison and R
@rickhaffey
rickhaffey / NEST client
Created May 4, 2015 12:19
ES Reindex via NEST requires Refresh [29960168]
string elastic_oldindexname = "so_v1";
string elastic_newindexname = "so_v2";
var node = new Uri("http://localhost:9200");
var settings = new ConnectionSettings(
node,
defaultIndex: elastic_oldindexname
);