Skip to content

Instantly share code, notes, and snippets.

View yutannihilation's full-sized avatar
🍣
Nobody loves you

Hiroaki Yutani yutannihilation

🍣
Nobody loves you
View GitHub Profile
library(stringr)
library(ggplot2)
library(rr4r)

ptn <- r"([\w]+://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?)"
url <- "https://mail.google.com/mail/u/0/"

res1 <- bench::press(
 x = c(1, 1e3, 1e5),
PS C:\Users\...\Documents\tmp> C:\rtools40\mingw64\bin\g++ -std=gnu++11 -O3 .\main.cpp
PS C:\Users\...\Documents\tmp> .\a.exe
PS C:\Users\...\Documents\tmp>
Rcpp::cppFunction('
void foo() {
// works fine if I change the pattern to one without []
std::regex reg("[0-9]");
}
', includes = "#include <regex>")
# works
Sys.setlocale("LC_ALL", 'English')
foo()
warning: matching on `Some` with `ok()` is redundant
--> extendr-macros/src/output_r.rs:20:5
|
20 | if let Some(manifest_dir) = env::current_dir().ok() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(clippy::if_let_some_result)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_let_some_result
help: consider matching on `Ok(manifest_dir)` and removing the call to `ok` instead
|
@yutannihilation
yutannihilation / zzz.R
Last active July 31, 2022 03:22
東京都新型コロナウィルス陽性患者発表数
#| fig.width: 12
#| fig.height: 8
#| dpi: 100
#| dev: ragg_png
library(readr)
library(dplyr, warn.conflicts = FALSE)
library(ggplot2)
f <- \(...) scale_colour_viridis_d(option = "F", end = 0.94, direction = -1, ..., aesthetics = c("colour", "fill"))
library(string2path)
d <- string2path("ABCDE", "/usr/share/fonts/TTF/iosevka-extrabold.ttf")
colnames(d) <- c("x", "y", "group")
d$subgroup <- 1
library(triangular)
library(ggplot2)
m <- as.matrix(d[,1:2])
library(string2path)
d <- string2path("ABCDE", "/usr/share/fonts/TTF/iosevka-extrabold.ttf")
colnames(d) <- c("x", "y", "group")
d$subgroup <- 1
library(triangular)
library(ggplot2)
plot_frame <- function(i) {
library(rayrender)
# generate path data by https://github.com/yutannihilation/rusttype-test
d <- readr::read_csv("/tmp/tmp.csv", col_names = c("x", "y", "id"))
l <- split(d, d$id)
colors <- scales::colour_ramp(c("#FF3499", "#FFECEC"))(seq(from = 0.4, to = 0.0, length.out = length(l)))
dir.create("/tmp/tokyor/")
@yutannihilation
yutannihilation / separate_cols.md
Last active July 24, 2020 21:07
separate_cols()

tidyr::separate() cannot handle the cell that contains arbitrary order of values. separate_rows() + pivot_wider() works to some extent, but this cannot handle an empty string or a missing value.

tibble(
  id = 1:4,
  answer = c("a,b", "a,c", "a,b,c", "c")
) %>% 
  # separate() だとできないのでいったん縦向きに広げてから pivot する
  separate_rows(answer) %>%