Skip to content

Instantly share code, notes, and snippets.

View warrenronsiek's full-sized avatar

Warren Hamilton Ronsiek warrenronsiek

View GitHub Profile
@warrenronsiek
warrenronsiek / gist:8f19bd48463d84bcfa71219aca81ed79
Created December 3, 2022 18:48
timescale helm values.yaml
# This file and its contents are licensed under the Apache License 2.0.
# Please see the included NOTICE for copyright information and LICENSE for a copy of the license.
replicaCount: 3
# To prevent very long names, we override the name, otherwise it would default to
# timescaledb-single (the name of the chart)
nameOverride: timescaledb
# The default Patroni name of the cluster ("scope") is derived from the name of the release,
@warrenronsiek
warrenronsiek / disk_setup.sh
Created October 19, 2022 21:14
Set up LVM on top of Raid and mount it in ubuntu server
sudo vgdisplay
# assuming the vg you want is called vg0
sudo lvcreate -l 100%VG -n storage_lv vg0
sudo lvdisplay
sudo fdisk -l
mkfs.ext4 /dev/mapper/vg0-storage_lv
sudo mount /dev/mapper/vg0-storage_lv /home/warren/storage
lsblk
@warrenronsiek
warrenronsiek / Dockerfile
Created October 8, 2020 12:42
Docker run simple airflow locally with local dags
FROM ubuntu:18.04 AS builder
WORKDIR /tmp/
COPY ./requirements.txt requirements.txt
COPY dags /tmp/airflow/dags
ENV VIRTUAL_ENV=/tmp/venv
ENV AIRFLOW_HOME=/tmp/airflow
ENV PATH="$VIRTUAL_ENV/bin:$AIRFLOW_HOME/dags:$AIRFLOW_HOME:$PATH"
EXPOSE 8080
SHELL ["/bin/bash", "-c"]
RUN apt-get update \
@warrenronsiek
warrenronsiek / clentRole.scala
Created May 11, 2020 11:33
Create amazon client with specified role
import com.amazonaws.services.s3.{AmazonS3, AmazonS3ClientBuilder}
import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider
import com.amazonaws.regions.Regions
val credsWithRole: STSAssumeRoleSessionCredentialsProvider = new STSAssumeRoleSessionCredentialsProvider
.Builder("role-arn","test-session")
.withStsClient(AWSSecurityTokenServiceClientBuilder.standard().withRegion(Regions.US_EAST_1).build()).build()
val client: AmazonS3 = AmazonS3ClientBuilder.standard().withCredentials(credsWithRole)
.withRegion(Regions.US_EAST_1).build()
@warrenronsiek
warrenronsiek / streamLines.scala
Created May 11, 2020 11:26
Stream file lines from S3 in Scala
import com.amazonaws.services.s3.AmazonS3
import com.amazonaws.services.s3.model.{GetObjectRequest, S3Object => JS3Object}
import java.io.{BufferedInputStream, BufferedReader, File}
import java.util.zip.GZIPInputStream
def stream(bucket: String, key: String)(implicit client: AmazonS3): Iterator[String] = {
val js3: JS3Object = client.getObject(new GetObjectRequest(bucket, key))
val s3ObjectInputStream = js3.getObjectContent
val br = new BufferedReader(new BufferedInputStream(new GZIPInputStream(s3ObjectInputStream)).reader)
Stream.continually(br.readLine()).takeWhile(_ != null).toIterator
@warrenronsiek
warrenronsiek / recursive_list.py
Created April 13, 2020 15:23
Recursively count root directories in an S3 bucket with assumed role in python
import boto3
from collections import Counter
BUCKET = '<YOUR BUCKET NAME>'
ROLE = '<YOUR ROLE TO ASSUME>'
ITEM_LIMIT = 10 # you probably want this to be at least 1
sts = boto3.client('sts')
creds = sts.assume_role(RoleArn=ROLE, RoleSessionName='list-s3')
access_key = creds['Credentials']['AccessKeyId']
@warrenronsiek
warrenronsiek / install_spark.sh
Last active February 10, 2020 18:36
How to install Spark on MacOS with Homebrew
brew tap homebrew/cask-versions
brew tap adoptopenjdk/openjdk
brew cask install adoptopenjdk/openjdk/adoptopenjdk8
brew untap adoptopenjdk/openjdk
brew untap homebrew/cask-versions
brew cleanup
brew install scala
brew install apache-spark
echo "export JAVA_HOME=`/usr/libexec/java_home -v 1.8`" > ~/.bash_profile
source ~/.bash_profile

To install scikit-learn easily run the following command.

curl https://gist.githubusercontent.com/dacamo76/4780765/raw/c3779996d8f6b13caaaa48d33aa1585684c7f8e6/scikit-learn-install.sh | sh

Please look over the shell file being run to make sure no evil is done to your machine.

@warrenronsiek
warrenronsiek / README.md
Last active August 29, 2015 14:18
Gerrymandering

Congressional Gerrymandering

This is a d3 mapping project that creates a map with each congressional district colored by the degree to which it is gerrymandered. E.g. Dark red is a highly gerrymandered republican district and dark blue is democratic and highly gerrymandered.

The shapefiles I used for this project were gotten from the US Census bureau. The party data (i.e. whether a district should be blue or red) was gotten from the Office of the Clerk (in the house of representatives).

@warrenronsiek
warrenronsiek / README.md
Last active August 29, 2015 14:17
Car Preference Clustering Map

Car Preference Clustering

This interactive visualization shows car preference rankings depending on where a person is coming from and where they are going.

Clicking on a country colors other countries based on the kinds of cars the people from those countries tend to rent. E.g. If France is clicked, and the nordic countries are all the same color, it means that the nordic countries have similar car preferences.