This file contains hidden or 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
| # Clone repo | |
| git clone https://github.com/keaven/gsDesign.git | |
| cd gsDesign | |
| # Run gource - this will generate a 411GB ppm file | |
| gource -3840x2160 --seconds-per-day 0.1 --auto-skip-seconds 0.01 --file-idle-time 0 --font-size 34 --key --logo man/figures/logo.png -o gsDesign.ppm | |
| # Convert ppm to mp4 | |
| ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i gsDesign.ppm -vcodec libx264 -preset medium -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 gsDesign.mp4 | |
| # Merge audio to video | |
| ffmpeg -i gsDesign.mp4 -i music.mp3 -c:v copy -c:a aac output.mp4 | |
| # Recommended by YouTube |
This file contains hidden or 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
| // Automate browser extension updates with RobotJS | |
| const robot = require("robotjs"); | |
| const { execSync } = require("child_process"); | |
| const updateExtension = (coordRemove) => { | |
| // Open in extensions page in browser | |
| execSync('open -a "Google Chrome" chrome://extensions'); | |
| // Move to and click "Remove" button of the extension | |
| robot.setMouseDelay(1000); |
This file contains hidden or 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
| # Load data and split training/test set ---------------------------------------- | |
| library("xts") | |
| index2010 <- sparseIndexTracking::INDEX_2010 | |
| x_tr <- index2010$X[1:126] | |
| x_te <- index2010$X[127:252] | |
| r_tr <- index2010$SP500[1:126] | |
| r_te <- index2010$SP500[127:252] |
This file contains hidden or 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
| library("promises") | |
| library("chromote") | |
| #' Print HTML to PDF using chromote | |
| #' | |
| #' @param url Input URL | |
| #' @param filename Output file name | |
| #' @param wait_ If TRUE, run in synchronous mode, | |
| #' otherwise, run in asynchronous mode. | |
| #' @param ... Additional parameters for Page.printToPDF, see |
This file contains hidden or 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
| # <https://github.com/madler/zlib/blob/8678871f18f4dd51101a9db1e37791f975969079/doc/txtvsbin.txt> | |
| #' Classify any file into text file or binary file | |
| #' | |
| #' @param path File path. | |
| #' @param n The (maximal) number of bytes to read. | |
| #' | |
| #' @return Logical. `TRUE` if text, `FALSE` if binary. | |
| #' | |
| #' @examples |
This file contains hidden or 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
| # Get operator (parallel or serial) | |
| # Idea from <https://github.com/tidymodels/tune/blob/c4a1d891ac77e64086a417ab75ad822178cd87ee/R/parallel.R> | |
| get_operator <- function() { | |
| is_par <- foreach::getDoParWorkers() > 1 | |
| if (is_par) { | |
| res <- foreach::`%dopar%` | |
| } else { | |
| res <- foreach::`%do%` | |
| } | |
| res |
This file contains hidden or 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
| fileInputArea <- function(inputId, label, multiple = FALSE, accept = NULL, | |
| width = NULL, buttonLabel = "Browse...", placeholder = "No file selected") { | |
| restoredValue <- restoreInput(id = inputId, default = NULL) | |
| # Catch potential edge case - ensure that it's either NULL or a data frame. | |
| if (!is.null(restoredValue) && !is.data.frame(restoredValue)) { | |
| warning("Restored value for ", inputId, " has incorrect format.") | |
| restoredValue <- NULL | |
| } |
This file contains hidden or 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
| switchInput <- function(inputId, label, value = FALSE, disabled = FALSE, width = NULL) { | |
| value <- shiny::restoreInput(id = inputId, default = value) | |
| inputTag <- htmltools::tags$input(id = inputId, type = "checkbox", role = "switch", class = "form-check-input") | |
| if (!is.null(value) && value) { | |
| inputTag$attribs$checked <- NA | |
| } | |
| if (!is.null(disabled) && disabled) { | |
| inputTag$attribs$disabled <- NA | |
| } | |
| htmltools::tags$div( |
This file contains hidden or 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
| # Generate mock data ----------------------------------------------------------- | |
| set.seed(42) | |
| k <- 100 | |
| df <- data.frame( | |
| title = unlist(purrr::map2( | |
| .x = stringr::word(stringi::stri_rand_lipsum(k), start = 1, end = 10), | |
| .y = rep("#", k), | |
| .f = function(.x, .y) as.character(htmltools::tags$a(.x, href = .y)) | |
| )), | |
| time = as.POSIXct(unlist( |
This file contains hidden or 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
| library(knitr) | |
| library(htmltools) | |
| library(webshot2) | |
| df <- mtcars[2:7, c("mpg", "disp", "drat", "wt", "qsec")] | |
| rownames(df) <- NULL | |
| colnames(df) <- NULL | |
| tnum <- function(font, title, output) { | |
| tags$html( |