Skip to content

Instantly share code, notes, and snippets.

@juliasilge
juliasilge / installation.md
Last active April 22, 2024 21:04
Installing R + Tensorflow on M1
@akostadinov
akostadinov / fonts_find.sh
Created May 19, 2021 21:10
shows fonts containing character
#!/usr/bin/env bash
# example: ./font_find.sh 🎩︎
# credits: David Baynard, https://unix.stackexchange.com/a/393740/14907
param="$1"
char=${param:0:1}
printf '%x' \'"$char" | xargs -I{} fc-list ":charset={}"
@jennybc
jennybc / vv_transformer.R
Last active August 9, 2019 18:32
A glue transformer inspired by the "variables & values" f-string syntax in Python 3.8
library(glue)
vv_transformer <- function(text, envir) {
regex <- "=$"
if (!grepl(regex, text)) {
return(identity_transformer(text, envir))
}
text <- sub(regex, "", text)
res <- identity_transformer(text, envir)
n <- length(res)
@RLesur
RLesur / sort_definition_list.lua
Created October 27, 2018 23:22
A pandoc lua filter that sorts definition lists
DefinitionList = function(dl)
local terms = {}
local inlines = {}
local blocks = {}
local sorted = {}
for i, item in ipairs(dl.content) do
local term = string.upper(pandoc.utils.stringify(item[1])) --string.upper() is used because all the terms were not capitalized in the example
table.insert(terms, term)
inlines[term] = item[1]
blocks[term] = item[2]
@jimhester
jimhester / graphql_reviews.R
Last active April 27, 2018 15:31
graphql query
library(tidyverse)
library(httr)
library(jsonlite)
library(glue)
library(lubridate)
# JSON friendly version of glue
jlue <- function(..., .envir = parent.frame()) {
glue(..., .envir = .envir, .open = "<", .close = ">")
}
@stephlocke
stephlocke / Checklist.md
Last active May 25, 2018 19:01
Conference good practices according to Steph!
  • Have a Code of Conduct and a demonstrable commitment to diversity
    • The Code of Conduct must be prominently displayed
    • Sponsors and other third parties must adhere to the Code of Conduct
  • Provide a mechanism for low income attendees to get reduced prices and support where the event charges more than a day's income
  • Attendees encounter only non-defaulted opt-ins to marketing and future contact, especially from third parties
  • The data entrusted to the event is handled with due care and consideration
  • Diverse attendees' needs are considered and taken into consideration. Things like (but not limited to) large print agendas, gender neutral bathrooms, quiet rooms, family rooms, and prayer rooms are implemented to ensure a pleasant experience for all attendee
  • Volunteers and organisers should receive reduced or free entry to the event
  • New speakers are encouraged and offered extra support
  • The speaker selection process is performed in a way that reduces possible sources of bias
library(purrr)
library(dplyr)
na_set <- function(x, p){
p <- as_mapper(p)
x[p(x)] <- NA
x
}
# or something like this using case_when
---
title: "Summarise and mutate multiple columns"
output: html_document
---
```{r, include = FALSE}
library(dplyr)
knitr::opts_hooks$set(
asciicast = rsciinema::asciicast_hook
)
library(ggplot2)
library(grid)
geom_point2 <- function(mapping = NULL, data = NULL,
stat = "identity", position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE) {
@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