Skip to content

Instantly share code, notes, and snippets.

View andyreagan's full-sized avatar

Andy Reagan andyreagan

View GitHub Profile
@andyreagan
andyreagan / salaries.tsv
Created March 22, 2022 20:06
Highest paid public employees by state
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
Alabama::Nick Saban::Head football coach::University of Alabama::8,307,000
Alaska::James Roland Johnsen::President::University of Alaska Statewide System::384,599.99
Arizona::Sean Miller::Head basketball coach::University of Arizona::2,700,000
Arkansas::Chad Morris::Head football coach::University of Arkansas::3,500,000
California::Chip Kelly::Head football coach::University of California, Los Angeles::3,300,000
Colorado::Mike MacIntyre::Head football coach::University of Colorado Boulder::2,878,500
Connecticut::Randy Edsall::Head football coach::University of Connecticut::1,100,000
Delaware::Mark T. Brainard::President::Delaware Technical Community College::245,954.82
Florida::Dan Mullen::Head football coach::University of Florida::6,070,000
Georgia::Kirby Smart::Head football coach::University of Georgia::6,603,600
@andyreagan
andyreagan / wordle.py
Created February 14, 2022 16:27
Obligatory wordle coding
from math import prod
from itertools import product
import click
LETTERS = "abcdefghijklmnopqrstuvwxyz"
assert len(LETTERS) == 26
def get_all_possibilities(guesses: list, results: list) -> list:
bad_letters_global = [
@andyreagan
andyreagan / programming.md
Created November 9, 2021 15:16
Programming with dplyr
title author output
Programming with dplyr
Andy Reagan
html_document
toc
true
library(dplyr)
import random
def decrypt(plain: str, key: list):
short_key = [y for y in key if y < len(plain)]
return ''.join([plain[y] for y in [z for z in sorted(range(len(plain)),key=short_key.__getitem__)]])
def encrypt(plain: str, key: list):
'''
@andyreagan
andyreagan / index.html
Created March 23, 2021 16:33
Scrollytelling complete
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=900, initial-scale=1.0">
<title>Document</title>
<style>
body {
font-family: sans-serif;
@andyreagan
andyreagan / index.html
Created March 23, 2021 01:23
Scrollytelling
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=900, initial-scale=1.0">
<title>Document</title>
<style>
body {
font-family: sans-serif;
@andyreagan
andyreagan / 00_how_to_use_R_like_python.md
Last active March 9, 2021 19:02
How to use R like Python

Here's how to use an R script like a Python script, relying on box. While there are reasons to use R, there are also two very bad parts of the R language, avoid them: (1) never use source and (2) never use library. These encourage patterns of code that are difficult to test or maintain. Using source comes along with changing the working directory sometimes, which should also be avoided. I'll quote Jenny Bryan, who, among other things says

Have setwd() in your scripts? PLEASE STOP DOING THAT. ... I will come into your lab and SET YOUR COMPUTER ON FIRE.

She has also written a whole post on why setwd() is, and I quote again, "so problematic and often associated with other awkward workflow problems".

There are three files here:

  • src/main/myscript.R: the main script, has functions that can be used elsewhere and also can be run standalone.
  • `src/main/04_uncon
day game KD Accuracy match Kills
1 1 0.56 07.60 TDM 9
1 2 0.48 04.40 TDM 12
1 3 0.50 09.80 TDM 13
1 4 0.90 09.40 TDM 27
1 5 0.36 03.50 TDM 4
1 6 0.71 04.70 TDM 10
1 7 1.38 00.00 TDM 18
1 8 1.00 20.00 TDM 2
2 1 0.78 15.30 TDM 7
@andyreagan
andyreagan / gps_track.gpx
Last active September 25, 2020 14:57
Virtual boston marathon data
<?xml version="1.0" encoding="UTF-8"?>
<gpx creator="StravaGPX" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd" version="1.1" xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
<metadata>
<time>2020-09-13T10:04:30Z</time>
</metadata>
<trk>
<name>Virtual Boston Marathon!</name>
<type>9</type>
<trkseg>
<trkpt lat="42.4211140" lon="-72.4243420">
@andyreagan
andyreagan / .flake8
Created July 14, 2020 03:12
Standard pre commit and isort, flake8 settings
[flake8]
max-line-length = 88
max-complexity = 12
select = C,E,F,W,B,B950
ignore = E203, E501, W503