Skip to content

Instantly share code, notes, and snippets.

View dikiprawisuda's full-sized avatar

Diki Prawisuda dikiprawisuda

View GitHub Profile
@Dpananos
Dpananos / ex.R
Created April 13, 2024 16:09
Confounding example
library(tidyverse)
# Genuine confounding example. Sex confounds relationship between drug and death
set.seed(0)
n <- 1000000
is_male <- rbinom(n, 1, 0.5)
drug <- rbinom(n, 1, 0.6 + 0.3*is_male)
y <- rbinom(n, 1, 0.4 - 0.1*drug + 0.4*is_male)
d <- tibble(drug, is_male, y)
@friendly
friendly / diabetes-pca-tsne.R
Created April 3, 2024 13:21
Animation of PCA vs. tSNE dimension reduction
#' ---
#' title: Animate transition from PCA <--> tsne
#' ---
# idea from: https://jef.works/genomic-data-visualization-2024/blog/2024/03/06/akwok1/
#' ## Load packages and data
library(ggplot2)
library(gganimate)
library(Rtsne)
library(patchwork)
library(tidyverse)
library(mgcv)
#> Loading required package: nlme
#> 
#> Attaching package: 'nlme'
#> The following object is masked from 'package:dplyr':
#> 
#>     collapse
#> This is mgcv 1.8-41. For overview type 'help("mgcv-package")'.
@mitchellh
mitchellh / merge_vs_rebase_vs_squash.md
Last active March 4, 2026 18:04
Merge vs. Rebase vs. Squash

I get asked pretty regularly what my opinion is on merge commits vs rebasing vs squashing. I've typed up this response so many times that I've decided to just put it in a gist so I can reference it whenever it comes up again.

I use merge, squash, rebase all situationally. I believe they all have their merits but their usage depends on the context. I think anyone who says any particular strategy is the right answer 100% of the time is wrong, but I think there is considerable acceptable leeway in when you use each. What follows is my personal and professional opinion:

@veekaybee
veekaybee / normcore-llm.md
Last active March 3, 2026 22:19
Normcore LLM Reads

Anti-hype LLM reading list

Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Foundational Concepts

Screenshot 2023-12-18 at 10 40 27 PM

Pre-Transformer Models

@AlbertRapp
AlbertRapp / fruit_seasonality_New_Zealand.qmd
Created August 7, 2023 20:58
fruit_seasonality_New_Zealand.qmd
```{r}
library(tidyverse)
# https://www.produce.co.nz/seasonality-chart/
fruits <- tibble::tribble(
~ fruit, ~start, ~ end,
"Blueberry", "October", "April",
@AlbertRapp
AlbertRapp / connected_ggiraph.R
Created January 25, 2023 19:39
connected_ggiraph.R
library(dplyr)
library(ggplot2)
library(patchwork)
library(ggiraph)
dat <- gapminder::gapminder |>
janitor::clean_names() |>
mutate(
# ID that is shared for boxplots (this one uses factors, i.e. numbers, as ID instead of continents)
@tonyelhabr
tonyelhabr / scrape-worldcup-match-player-stats.md
Last active July 23, 2023 15:32
Get stats by player for a 2022 World Cup match.

Scraping a specific stat for this match. Inspiration here. You can get other player stats in a similar fashion.

library(httr)
library(tibble)
library(tidyr)
library(dplyr)
library(purrr)
library(janitor)