Skip to content

Instantly share code, notes, and snippets.

View jonocarroll's full-sized avatar
👨‍💻
Learning all the languages

Jonathan Carroll jonocarroll

👨‍💻
Learning all the languages
View GitHub Profile
library(emo)
library(stringr)
library(purrr)
emoji_name <- emo:::emoji_name
emoji_keyword <- emo:::emoji_keyword
maybe_emoji <- function( keyword ){
if (keyword %in% names(emoji_name)) {
# Imports a namespace under an alias
# (equivalent of Python's `import ... as ...`)
importAs = function(namespace, alias) {
namespace::registerNamespace(name = alias, env = asNamespace(namespace))
}
# Imports function(s) from a namespace (including unexported functions)
# to the global namespace
# (equivalent of Python's `import ... from ...`)
importFrom = function(namespace, functions) {
#include <stdint.h>
#include <stdlib.h>
#include <Rcpp.h>
// From https://en.m.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm
#define ALPHABET_LEN 256
#define NOT_FOUND patlen
#define max(a, b) ((a < b) ? b : a)
// delta1 table: delta1[c] contains the distance between the last
@gmbecker
gmbecker / argify.R
Created April 4, 2018 18:21
Add argument specification to a function call
argify = function(expr, recursive = FALSE) {
if(is.character(expr))
expr = parse(text = expr)
else if(!is.call(expr))
expr = substitute(expr)
stopifnot(is.call(expr))
if(recursive && length(expr) > 1) {
for(i in 2:length(expr)) {
if(is.call(expr[[i]]))
expr[[i]] = argify(expr[[i]], TRUE)
@DavisVaughan
DavisVaughan / job.r
Created May 7, 2018 10:48
Playing with RStudio Daily jobs
add_job <- function(name, status, progressUnits,
actions, estimate, estimateRemaining,
running, autoRemove, group) {
rstudioapi::callFun("addJob",
name = name,
status = status,
progressUnits = progressUnits,
actions = actions,
estimate = estimate,
estimateRemaining = estimateRemaining,
# This example demonstrates running furrr code distributed on 2 AWS instances ("nodes").
# The instances have already been created.
library(future)
library(furrr)
# Two t2.micro AWS instances
# Created from http://www.louisaslett.com/RStudio_AMI/
public_ip <- c("34.205.155.182", "34.201.26.217")
gh_migrate("YOUR_GITHUB_USERNAME", "GITHUB_REPO")
gitea_user <- function(gitea_username,
api_endpoint = Sys.getenv("GITEA_BASE_URL"),
gitea_token = Sys.getenv("GITEA_PAT")) {
require("httr", quietly = TRUE)
require("jsonlite", quietly = TRUE)
httr::GET(
@brodieG
brodieG / cran-check.R
Last active June 18, 2019 21:02
Check CRAN Results
# started with `foghorn`, but that comes with dependencies and
# slows down R startup. `browseURL` just barely slows startup,
# even if actual page is slow to load.
check_cran_old <- function(email) {
utils::browseURL(
sprintf(
"https://cran.r-project.org/web/checks/check_results_%s.html",
gsub("[^A-Za-z0-9_:.-]", "_", sub("@", "_at_", email))
) ) }
@tjmahr
tjmahr / sort.R
Last active September 30, 2018 13:52
sorting photos
# R script for sorting the pictures in my OneDrive's camera roll folder. Photos
# in the directory are uploaded and backed up here automatically from the iOS
# OneDrive app. This script puts the photos into Year / Month subfolders.
dir <- "F:/Tristan/OneDrive/Pictures/Camera Roll"
ps <- list.files(dir, "*.(jpg|png)", full.names = TRUE)
library(exiftoolr)
library(dplyr)
@peterdesmet
peterdesmet / CONTRIBUTING.md
Last active October 11, 2024 12:20
My CONTRIBUTING.md template for R packages. Released under CC0, so replace our_package, our_org, and maintainer_email and adapt as you see fit. 😌 For more info, see https://help.github.com/articles/setting-guidelines-for-repository-contributors

Contributing to our_package

First of all, thanks for considering contributing to our_package! 👍 It's people like you that make it rewarding for us - the project maintainers - to work on our_package. 😊

our_package is an open source project, maintained by people who care. We are not directly funded to do so.