Skip to content

Instantly share code, notes, and snippets.

@rexarski
rexarski / rotation.R
Created January 7, 2023 03:39 — forked from ivelasq/rotation.R
Rotated ggplot2 graph
# Credits to this Stack Overflow post
# https://stackoverflow.com/questions/13445753/force-ggplot2-scatter-plot-to-be-square-shaped
library(ggplot2)
library(grid)
rotation <- 45
p <-
ggplot() +
@rexarski
rexarski / launchpad-icon-killer.sh
Created June 9, 2022 17:16
Delete redundant macOS Launchpad icons
# Substitute APPNAME with the exact icon/app name
sqlite3 $(find /private/var/folders -name com.apple.dock.launchpad 2>/dev/null)/db/db \
"DELETE FROM apps WHERE title='APPNAME';" && \
killall Dock
library(tidyverse)
set.seed(1234234)
my_selection <- c(6, 7, 8, 9)
dat0 <- expand_grid(a = 1:6, b = 1:6, c = 1:6, d = 1:6)
dat0 <- dat0 |>
mutate(
@rexarski
rexarski / art-map.R
Created March 15, 2021 11:45
personal art map
# source
# https://ggplot2tutor.com/streetmaps/streetmaps/
# http://estebanmoro.org/post/2020-10-19-personal-art-map-with-r/
# create the streetmap
pacman::p_load(osmdata, ggplot2)
# bbx <- getbb("Boston, MA")
bbx <- getbb("Canberra, Australia")
min_lon <- bbx[1,1]
max_lon <- bbx[1,2]
# install.packages("ggalt")
library(ggalt)
library(hrbrthemes)
library(tidyverse)
data <- read_csv("searches.csv") %>%
mutate(keyword = as_factor(keyword)) %>%
group_by(keyword) %>%
mutate(idx = 1:n(),
@rexarski
rexarski / i^i^i.R
Created March 12, 2021 02:50
i^i^i
pacman::p_load(tidyverse, extrafont)
i <- complex(real = 0, imaginary = 1)
count <- 1
point <- complex(real = 0.5, imaginary = 0.5)
x <- c(0.5)
y <- c(0.5)
while (count <= 25) {
z <- i^point
@rexarski
rexarski / cloudSettings
Last active November 19, 2020 03:01
my-visual-studio-code-settings
{"lastUpload":"2020-11-19T03:01:40.792Z","extensionVersion":"v3.4.3"}
@rexarski
rexarski / read_folders.R
Created October 17, 2020 09:45
Read all documents within sub-folders under a folder into a dataframe. https://www.tidytextmining.com/usenet.html
library(dplyr)
library(tidyr)
library(purrr)
library(readr)
training_folder <- "data-folder"
# a function that reads all files from a folder into a data frame
read_folder <- function(infolder) {
tibble(file = dir(infolder, full.names = TRUE)) %>%
@rexarski
rexarski / delete_git_submodule.md
Created October 7, 2020 06:34 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
library(dplyr)
Wilson <- function(n, k, alpha=0.95) {
phat <- k/n
score <- qnorm(1-(1-alpha)/2)
lbound <- (phat+score**2/(2*n)-score*sqrt((phat*(1-phat)+score**2/(4*n))/n))/(1+score**2/n)
return(lbound)
}
seed(2019)