Skip to content

Instantly share code, notes, and snippets.

@gmaubach
gmaubach / vagrant-up--provision--debug
Created April 15, 2024 07:42
vagrant-error-guest-communications
INFO global: Vagrant version: 2.3.4
INFO global: Ruby version: 3.1.2
INFO global: RubyGems version: 3.3.15
INFO global: VAGRANT_LOG="debug"
WARN global: resolv replacement has not been enabled!
DEBUG global: Loading core plugin: /usr/share/rubygems-integration/all/gems/vagrant-2.3.4/plugins/commands/autocomplete/plugin.rb
INFO manager: Registered plugin: autocomplete command
DEBUG global: Loading core plugin: /usr/share/rubygems-integration/all/gems/vagrant-2.3.4/plugins/commands/box/plugin.rb
INFO manager: Registered plugin: box command
DEBUG global: Loading core plugin: /usr/share/rubygems-integration/all/gems/vagrant-2.3.4/plugins/commands/cap/plugin.rb
@gmaubach
gmaubach / render_json_jupyter_collapsible.py
Created September 2, 2022 15:33 — forked from t27/render_json_jupyter_collapsible.py
Render JSON as a collapsible field in jupyter notebooks - Updated - Also includes instructions for interleaving with print statements
## Add this to the first block in your note book
import uuid
from IPython.core.display import display, HTML
import json
class RenderJSON(object):
def __init__(self, json_data):
if isinstance(json_data, dict):
self.json_str = json.dumps(json_data)

There are packages for this now!

2016-10-28: Since I wrote this in 2014, the universe, specifically Kirill Müller (https://github.com/krlmlr), has provided better solutions to this problem. I now recommend that you use one of these two packages:

  • rprojroot: released on CRAN and developed on GitHub. This is the main package with functions to help you express paths in a way that will "just work" when developing interactively in an RStudio Project and when you render your file.
  • here: not yet released on CRAN but available on GitHub. A lightweight wrapper around rprojroot that anticipates the most likely scenario: you want to write paths relative to the top-level directory, defined as an RStudio project or Git repo.

I use these packages now instead of what I describe below. I'll leave this gist up for historical interest. 😆

TL;DR

@gmaubach
gmaubach / addNewData.R
Created March 20, 2017 12:44 — forked from dfalster/addNewData.R
The function addNewData.R modifies a data frame with a lookup table. This is useful where you want to supplement data loaded from file with other data, e.g. to add details, change treatment names, or similar. The function readNewData is also included. This function runs some checks on the new table to ensure it has correct variable names and val…
##' Modifies 'data' by adding new values supplied in newDataFileName
##'
##' newDataFileName is expected to have columns
##' c(lookupVariable,lookupValue,newVariable,newValue,source)
##'
##' Within the column 'newVariable', replace values that
##' match 'lookupValue' within column 'lookupVariable' with the value
##' newValue'. If 'lookupVariable' is NA, then replace *all* elements
##' of 'newVariable' with the value 'newValue'.
##'