Skip to content

Instantly share code, notes, and snippets.

View zgulde's full-sized avatar

Zach Gulde zgulde

View GitHub Profile
import matplotlib.pyplot as plt
from pydataset import data
class Plot:
def __init__(self, data=None):
if data is not None:
self.data = data
def __getattr__(self, attr):
def wrapper(*args, **kwargs):
if attr in ['scatter', 'hist', 'bar', 'plot'] and 'data' not in kwargs:
In [148]: def various_scales(s: pd.Series):
...: df = pd.DataFrame()
...: df['original'] = s
...: df['min_max'] = MinMaxScaler().fit_transform(s.values.reshape(-1, 1))
...: df['percentile'] = s.rank(pct=True)
...: df['rank'] = s.rank()
...: df['z_score'] = StandardScaler().fit_transform(s.values.reshape(-1, 1))
...: return df
#!/usr/bin/env bash
tail -n +3 $0 | pandoc --section-divs --mathjax -o index.html ; exit 0
# Self-Rendering Markdown File
Just make sure you have `pandoc` installed, ignore the first two lines of this
file, and make this file executable (`chmod +x self-rendering.md`).
Then you can run this file to produce it's html output.
```
JUPYTER_NOTEBOOK_CONFIG_FILE=$(jupyter --config-dir)/jupyter_notebook_config.py
# conda -c conda-forge install jupytext
python3 -m pip install --upgrade jupytext
[[ -f $JUPYTER_NOTEBOOK_CONFIG_FILE ]] || jupyter notebook --generate-config
if ! grep -q 'c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"' $JUPYTER_NOTEBOOK_CONFIG_FILE ; then
echo "# Added by $0 at $(date)" >> $JUPYTER_NOTEBOOK_CONFIG_FILE
#!/usr/bin/env bash
# Shell script to install docker and docker-compose
# author: Zach Gulde <[email protected]>
#
# This script is more or less an automation of the guides found here:
#
# - https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04
# - https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-ubuntu-18-04
#
@zgulde
zgulde / spark_jdbc.py
Last active August 22, 2022 17:47
spark jdbc mysql driver connection setup
import pyspark
import env
MYSQL_CONNECTOR_VERSION = '5.1.38'
DATABASE = 'a_database'
TABLE = 'some_db_table'
spark = (pyspark.sql.SparkSession.builder
.config(f'spark.jars.packages', 'mysql:mysql-connector-java:{MYSQL_CONNECTOR_VERSION}')
@zgulde
zgulde / git.md
Last active September 17, 2018 17:14

Getting Work on GitHub | First time repo setup

  1. Create the repo

    git init
    
  2. Add and commit your files

USE codeup_test_db;
TRUNCATE albums;
INSERT INTO albums (artist, name, release_date, genre, sales)
VALUES
("Michael Jackson", "Thriller", 1982, "Pop, rock, R&B", 43.3),
("AC/DC", "Back in Black", 1980, "Hard rock", 25.9),
("Pink Floyd", "The Dark Side of the Moon", 1973, "Progressive rock", 22.7),
("Whitney Houston / Various artists", "The Bodyguard", 1992, "Soundtrack/R&B, soul, pop", 27.4),
("Meat Loaf", "Bat Out of Hell", 1977, "Hard rock, progressive rock", 20.6),
("Eagles", "Their Greatest Hits (1971–1975)", 1976, "Rock, soft rock, folk rock", 32.2),
@zgulde
zgulde / index.html
Last active July 9, 2018 16:29
Simple JS Navigation Example
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
  • We're smarter than intellij when it comes to variables in our views

Defining a Thymeleaf fragment with a parameter

  1. [Define the head fragment, including a placeholder for the page title][1]
  2. Elsewhere, [when the fragment is included, pass a value for the title][2]
  3. In the fragment, [use the passed value][3]

Static Assets (things that don't change)