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
# 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")
@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,
@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)
#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
# 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) {
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)) {

See https://github.com/AustralianAntarcticDivision/bowerbird

This script uses bowerbird to configure a new repository and populate it with all the R-devel tarball archives (you'll have to create ~/bower directory).

The configuration here unpacks each tarball at the end of synchronization checks.

The bb_sync(cf) step can then be run on some routine schedule to keep the local repo up to date, allowing you to forget about whether you have the latest emails and just trying whatever idea it is you had.

@trestletech
trestletech / analysis.R
Last active July 7, 2017 16:49
Tidying of pressure-sensitive keystroke dynamics data. Raw available: https://figshare.com/articles/Pressure-sensitive_keystroke_dynamics_data/5170705 . The `isJA` column represents whether or not the user currently typing is "Jeffrey Allen" -- i.e. is the user typing his own name (TRUE) or someone else's (FALSE)?
download.file("https://ndownloader.figshare.com/articles/5170705/versions/1", "kd.zip")
unzip("kd.zip")
library(readr)
words <- readr::read_csv("KSP-Word.csv")
users <- readr::read_csv("KSP-User.csv")
entries <- readr::read_csv("KSP-Entry.csv")
keypress <- readr::read_csv("KSP-KeyPress.csv")
pressure <- readr::read_csv("KSP-Pressure.csv")
@jimhester
jimhester / 0.9.3.png
Last active July 11, 2018 11:18
Run R code with different versions of package dependencies, this will work in the same session as long as you don't run into issues unloading the namespaces
0.9.3.png
@mcnees
mcnees / graph paper.tex
Last active February 16, 2024 08:34
Make your own quadrille, graph, hex, etc paper! Uses the pgf/TikZ package for LaTeX, which should be part of any modern TeX installation.
%%-----------------------------------------------------------------------
%% Make your own quadrille, graph, hex, etc paper!
%% Uses the pgf/TikZ package for LaTeX, which should be part of
%% any modern TeX installation.
%% Email: mcnees@gmail.com
%% Twitter: @mcnees
%%-----------------------------------------------------------------------
\documentclass[11pt]{article}