Skip to content

Instantly share code, notes, and snippets.

View dikiprawisuda's full-sized avatar

dikip dikiprawisuda

View GitHub Profile
@brancengregory
brancengregory / chrome_history.R
Created November 11, 2024 22:33
Chrome History in R with DuckDB
library(duckdb)
library(duckplyr)
library(dplyr)
chrome_history_path <- "./chrome_history.sqlite"
# Copy the db to the local directory because Chrome puts a lock on it
file.copy(
"~/.config/google-chrome/Default/History", # Adjust based on OS
chrome_history_path,
#You have 3 urns, each containing 100 balls.
#In the first two, 99 of the balls are red and the last is green.
#In the third urn, all 100 balls are red.
#You choose one of the urns at random and remove 99 randomly chosen balls from it; they’re all red.
#The last is probably?
library(tidyverse)
pick_ball <- function(){
@JEFworks
JEFworks / fireworks.R
Last active July 4, 2024 22:19
Using gganimate to create an animation of fireworks over a background image
## following https://alistaire.rbind.io/blog/fireworks/
## but manually convert to polar coordinates to be able to add
## background image, which cannot be used with coord_polar()
library(ggplot2)
library(gganimate)
theme_set(theme_void())
## create set of points in polar coordinates
set.seed(0)
@chelseaparlett
chelseaparlett / R_EigenPCA_Plots.R
Last active April 19, 2024 10:45
Show students the relationship between Eigendecomp of Cor/Cov and the % variance explained for PCs
library(tidyverse)
library(MASS)
library(patchwork)
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
# generate data with given cor matrix
a <- 0.9
s1 <- matrix(c(1,a,
a,1), ncol = 2)
@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 February 24, 2025 08:19
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 1, 2025 11:12
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