Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rstudio_screenshot <- function(partial_name = "") { | |
look_behind <- "(?<=\\s)" | |
xwid_pattern <- "0x[a-f0-9]+" | |
look_ahead <- | |
paste0("(?=\\s\".*", | |
partial_name, | |
".*\":\\s\\(\"rstudio\"\\s\"RStudio\"\\)\\s+[0-9]{4}x[0-9]{3,4})") | |
xwid <- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
take_screenshot <- function() { | |
xwid <- | |
system("xwininfo -root | sed -n 2p | grep -oP 0x[a-f0-9]+", | |
intern = TRUE) | |
magick::image_write(magick::image_read(paste0("x:", xwid)), | |
path = format(Sys.time(), "ss-%Y%m%d-%H%M%S.png"), | |
format = "png") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import datatable as dt | |
from datatable import f, by, mean | |
# Reading a CSV | |
url = "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv" | |
tbl = dt.fread(url) | |
# Filtering rows | |
tbl = tbl[f.species != "setosa", :] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compose_quote <- function(body_part, creature_name) { | |
cat(paste0("Go for the ", body_part, ", ", creature_name, "!\n")) | |
} | |
execute <- function(fn, ...) { | |
Sys.sleep(1) | |
fn(...) | |
# Or: do.call(fn, list(...)) | |
# Or: rlang::exec(fn, ...) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn compose-quote [body-part creature-name] | |
(println (str "Go for the " body-part ", " creature-name "!"))) | |
(defn execute [command & args] | |
(Thread/sleep 1000) | |
(apply command args)) | |
(execute compose-quote "eyes" "Boo") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def users [{:name "John Doe" :subscription 0} | |
{:name "Jane Doe" :subscription 1} | |
{:name "John Dur" :subscription 1} | |
{:name "Sara Der" :subscription 1}]) | |
(defn alphabetic-sort [u1 u2] | |
(cond | |
(= (:subscription u1) | |
(:subscription u2)) (neg? (compare (:name u1) | |
(:name u2))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qsort <- function(inp, cfun) { | |
if (length(inp) > 1) { | |
cres <- cfun(inp, inp[[length(inp)]]) | |
c(qsort(inp[cres < 0], cfun), inp[cres == 0], qsort(inp[cres > 0], cfun)) | |
} else { | |
inp | |
} | |
} | |
users <- list(list(name = "John Doe", subscription = 0), |
OlderNewer