Skip to content

Instantly share code, notes, and snippets.

View defuneste's full-sized avatar
🌳

Olivier Leroy defuneste

🌳
View GitHub Profile
@defuneste
defuneste / new_post.R
Created September 10, 2024 01:27
same idea that blogdown::new_post but way less cool
# Assumption is that you run it at the root of the project
# waiting https://github.com/quarto-dev/quarto-cli/issues/3917 to ditch
new_post <- function(title, author = "default") {
t <- tolower(gsub(" ", "_", title, fixed = TRUE))
dir_path <- paste("posts",
paste(Sys.Date(), t, sep = "_"),
sep = "/")
@defuneste
defuneste / mastodon_posit_conf.md
Last active August 21, 2024 17:30
list of mastodon users fromposit conf 2024
@defuneste
defuneste / us_states_df.R
Last active February 15, 2024 13:23
us states tables
# copy paste from wiki https://en.wikipedia.org/wiki/List_of_U.S._state_and_territory_abbreviations
US_states <- data.frame(
"United States of America" = c("Alabama", "Alaska","Arizona","Arkansas","California",
"Colorado","Connecticut","Delaware","District of Columbia",
"Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa",
"Kansas","Kentucky","Louisiana","Maine","Maryland",
"Massachusetts","Michigan","Minnesota","Mississippi","Missouri",
"Montana","Nebraska","Nevada","New Hampshire","New Jersey",
"New Mexico","New York","North Carolina","North Dakota","Ohio",
@defuneste
defuneste / the_wole_game.md
Last active January 25, 2023 19:02
The whole Game (from Hadley Wickham and Jenny Bryan ) in mermaid
flowchart LR
subgraph one[Initializing package]
direction LR
A("create_package()")-->C("use_git()")
A-->B("use_XX_licence()")
A--> Z("use_testthat()")
end
subgraph two[Developping]
direction LR
@defuneste
defuneste / splitting_line_regular.R
Created October 7, 2022 14:08
splitting a line segment with regular spacing
#loading some libs
library(sf);library(lwgeom)
# a simplified example from sf help page of st_line_sample
ls = st_sfc(st_linestring(rbind(c(.1,0), c(0,0), c(0,1))), crs = 4326) |>
st_transform(3857)
# st_line_sample give you MULTIPOINT that you convert to POINT
points <- st_line_sample(ls, density = units::set_units(1, 1/km)) |>
st_cast("POINT")