Skip to content

Instantly share code, notes, and snippets.

View dragosmg's full-sized avatar
💭
I'm coding.

Dragoș Moldovan-Grünfeld dragosmg

💭
I'm coding.
View GitHub Profile
@dragosmg
dragosmg / decimal_date_bench::mark
Created March 30, 2022 09:24
Benchmarking the difference between the old implementation of `decimal_date()` (making more use of `difftime`) and the new implementation
# decimal_date_strptime is:
register_binding("decimal_date_strptime", function(date) {
# browser()
y <- build_expr("year", date)
# timezone <- call_binding("tz", date)
start <- call_binding("make_datetime", year = y, tz = "UTC")
end <- call_binding("make_datetime", year = y + 1L, tz = "UTC")
# maybe use yday here
sofar <- call_binding("difftime", date, start, units = "secs")
total <- call_binding("difftime", end, start, units = "secs")
@dragosmg
dragosmg / markdown-details-collapsible.md
Created January 20, 2022 21:49 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets

Keybase proof

I hereby claim:

  • I am dragosmg on github.
  • I am dragosmg (https://keybase.io/dragosmg) on keybase.
  • I have a public key ASB7hObwhQjNh4fdt360hgZ4igZjQrFMQwA9LMcOlHiS9Ao

To claim this, I am signing this object:

library(arrow, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
# target dataset size is 100k columns, 300k rows
# This is large, but we should be able to handle it (especially when it's
# partitioned). We can reduce the number of columns if we want to reproduce, but
# we should still be able to handle this (even if we're not perfectly tuned for it)
rows <- 300000
cols <- 100000
partitions <- 20
@dragosmg
dragosmg / .Rprofile
Created April 1, 2020 08:15 — forked from gadenbuie/.Rprofile
current project and branch in R command prompt
if (interactive()) {
# requires: devtools::install_github("gaborcsardi/prompt")
.prompt_grk <- function(...) {
dir <- if (rstudioapi::hasFun("getActiveProject") &&
!is.null(rstudioapi::getActiveProject())) {
basename(rstudioapi::getActiveProject())
} else {
basename(getwd())
}
if(interactive()) {
.__Rprofile_env__. <- new.env(parent = emptyenv())
.__Rprofile_env__.[["install"]] <- pak::pkg_install
attach(.__Rprofile_env__.)
library(usethis, warn.conflicts = FALSE)
library(conflicted)
conflict_prefer("filter", "dplyr")
conflict_prefer("sql", "dbplyr")
These code snippets have been tested on R 3.1.0 and Mac OS 10.9.3. They presumably do *not* work on R 2.X!
## Enter these commands in the Mac OS Terminal
# use faster vecLib library
cd /Library/Frameworks/R.framework/Resources/lib
ln -sf /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Versions/Current/libBLAS.dylib libRblas.dylib
# return to default settings
cd /Library/Frameworks/R.framework/Resources/lib