Skip to content

Instantly share code, notes, and snippets.

Design Principles

  • YAGNI: Don't build it until you need it.
  • DRY: Extract patterns after second duplication, not before.
  • Fail Fast: Explicit errors beat silent failures.
  • Simple First: Write the obvious solution, optimize only if needed.
  • Delete Aggressively: Less code = fewer bugs.
  • Semantic Naming: Always name variables, parameters, and API endpoints with verbose, self-documenting names that optimize for comprehension by both humans and LLMs, not brevity (e.g., wait_until_object_is_saved = true vs wait = true).
library(tidyverse)
fruit_prices <- tibble(
Month = c("Jan", "Feb", "Mar"),
Apples = c(1.79, 1.82, 1.8),
Pears = c(1.29, 1.34, 1.5),
Oranges = c(.89, .92, .85)
)
# A typical mutate, create a new column that is the sum of three columns
Welcome to Miniforge3 24.11.3-2
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
Miniforge installer code uses BSD-3-Clause license as stated below.
Binary packages that come with it have their own licensing terms
and by installing miniforge you agree to the licensing terms of individual
let x = [0, 50, 100]; // Initial x-coordinates for the squares
let y = [50, 100, 150]; // y-coordinates for the squares
function setup() {
createCanvas(windowWidth, 200); // Create a canvas
}
function draw() {
background(220); // Clear the canvas with a gray background
function colors = pal_hue(n, s, v)
% Generates a palette of n evenly spaced colors with default settings
% similar to R's scales::pal_hue().
% s is the saturation (default 0.75), v is the value (brightness, default 0.95).
% The hue component varies from 0 to 1.
if nargin < 2
s = 0.75; % Default saturation
end
if nargin < 3
@seankross
seankross / README.md
Last active April 28, 2023 16:55
Get TTS working in R with Reticulate on M1 or M2 MacOS

Make sure homebrew is all up to date.

Make sure you have venv working, I think it just comes with python3.

Start a brand new RStudio project and open it in RStudio.

In the terminal:

python -m venv .venv
@seankross
seankross / jazz.txt
Created May 18, 2018 18:20
Jazz Toni Morrison
From "Jazz" by Toni Morrison
It's nice when grown people whisper to each other under the covers. Their
ecstasy is more leaf-sigh than bray and the body is the vehicle, not the point.
They reach, grown people, for something beyond, way beyond and way, way down
underneath tissue. They are remembering while they whisper the carnival dolls
they won and the Baltimore boats they never sailed on. The pears they let hang
on the limb because if they plucked them, they would be gone from there and who
else would see that ripeness if they took it away for themselves? How could
anybody passing by see them and imagine for themselves what the flavor would
@seankross
seankross / schools.R
Created March 29, 2018 19:08
Graph for Clare
# You can find pch values for shapes here:
# https://cdn-images-1.medium.com/max/1600/1*0QEVFHrgqmkVsCVCQceh6w.jpeg
data <- data.frame(
Name = c("Ohio State", "Purdue", "Indiana", "Wisconsin", "Nebreaska"),
Min = c(0.37, 0.25, 0.13, 0.22, 0.28),
Max = c(0.88, 0.57, 0.68, 0.77, 0.63),
Value = c(0.51, 0.32, 0.24, 0.65, 0.57),
Pch = c(1, 2, 5, 6, 22),
stringsAsFactors = FALSE
@seankross
seankross / emilyp.R
Created March 7, 2018 04:04
Getting p-values out of a model, two ways
berkeley <- as.data.frame(UCBAdmissions)
model <- glm(Admit ~ Gender + Dept + Freq, data = berkeley, family = "binomial")
# Base R
model_summary <- summary(model)
model_summary$coefficients[,4]
# Or become one of the cool kids
library(shiny)
library(miniUI)
ui <- miniPage(
gadgetTitleBar("My Gadget"),
miniContentPanel(
## Your UI items go here.
)
)