Skip to content

Instantly share code, notes, and snippets.

View RLesur's full-sized avatar

Romain Lesur RLesur

View GitHub Profile
@julientaq
julientaq / baseline.css
Created July 8, 2019 20:56
paged.js Baseline
:root {
--baseline: var(--font-lineHeight);
--baseline-color: red;
}
.pagedjs_page {
/* grid baseline */
@cderv
cderv / update_git_remote.R
Created April 5, 2019 16:21
update git remote to new url
# Copyright (C) 2018 C. Dervieux
# Licence MIT - https://spdx.org/licenses/MIT.html
#' Update git remote url from R
#'
#' If git remote server is migrated and url is changed, this function allows to easily update
#' the url of local git repo to the new git remote url.
#'
#' This function need `git2r`, `urltools` and `glue` to work.
#'
sapply(list.files(pattern = "\\.html$"), function(file) {
html <- readLines(file)
new_html <- gsub(
"https:.*?MathJax\\.js\\?",
"https://mathjax.rstudio.com/latest/MathJax.js?",
html
)
writeLines(new_html, file)
})
@RLesur
RLesur / case_when_factory.R
Last active October 31, 2023 23:48
How to create reusable dplyr::case_when() functions?
# case_when factory: ----------------------------------------------
create_case_when <- function(..., vars = "x") {
fun_fmls <- purrr::map(rlang::set_names(vars), ~ rlang::missing_arg())
fun_body <- substitute({
for (name in var) {
symb <- rlang::eval_bare(rlang::sym(name))
var <- rlang::eval_tidy(rlang::enquo(symb))
assign(name, var)
}
forms <- purrr::map(formulas, rlang::`f_env<-`, value = environment())
@hrbrmstr
hrbrmstr / gg_tweet.R
Last active October 16, 2020 04:49
use the magick device to make ggplots conform to twitter card or in-stream image optimal sizes, with or without "retina" resolution
library(httr)
library(magick)
library(hrbrthemes)
library(ggplot2)
theme_tweet_rc <- function(grid = "XY", style = c("stream", "card"), retina=TRUE) {
style <- match.arg(tolower(style), c("stream", "card"))
switch(
library(gh)
library(tidyverse)
library("magick")
library(glue)
dir.create("data")
repos <- gh::gh("/orgs/:org/repos", org = "tidyverse", .limit = Inf) %>% map_chr("name")
urls <- repos %>%
@artemklevtsov
artemklevtsov / .gitlab-ci.yml
Last active January 12, 2024 04:14
Testing R package with GitLab CI (with code coverage)
variables:
CODECOV_TOKEN: "CODECOV_TOKEN_STRING"
_R_CHECK_CRAN_INCOMING_: "false"
_R_CHECK_FORCE_SUGGESTS_: "true"
APT_PKGS: "libcurl4-openssl-dev libssh2-1-dev libssl-dev libxml2-dev zlib1g-dev git"
before_script:
- apt-get update
- apt-get install -y --no-install-recommends ${APT_PKGS}
- apt-get install -y --no-install-recommends qpdf pandoc pandoc-citeproc
@keeferrourke
keeferrourke / install-google-fonts.sh
Last active May 22, 2023 12:38
A bash script to install all Google Fonts, system wide, on debian based systems (ex. Ubuntu)
#!/bin/sh
# Written by: Keefer Rourke <https://krourke.org>
# Based on AUR package <https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ttf-google-fonts-git>
# dependancies: fonts-cantarell, ttf-ubuntu-font-family, git
sudo apt-get install fonts-cantarell ttf-ubuntu-font-family git
srcdir="/tmp/google-fonts"
pkgdir="/usr/share/fonts/truetype/google-fonts"
giturl="git://github.com/google/fonts.git"
@cvan
cvan / google_fonts.md
Created March 12, 2016 00:12
get ttf, woff, woff2 from Google Fonts

ttf

curl 'https://fonts.googleapis.com/css?family=Karla'

woff2

curl 'https://fonts.googleapis.com/css?family=Karla' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'User-Agent: AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116'

woff

@shreve
shreve / pdfmarks
Last active July 28, 2024 08:54
Example of adding PDF metadata (bookmarks / ToC) with Ghostscript
[ /Title (Elementary Differential Equations)
/Author (Edwards & Penney)
/DOCINFO pdfmark
[ /Title (Contents)
/Page 6
/OUT pdfmark
[ /Count -8
/Title (1. First-Order Differential Equations)