This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias supabase-dashboard="open $(supabase status -o json | jq -r '.STUDIO_URL')" | |
alias supabase-psql="psql $(supabase status -o json | jq -r '.DB_URL')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ pandoc filter to convert inline math to png images | |
Sses dvipng to convert inline and display math to png. There are better ways to handle math output, | |
but some platforms (e.g. Confluence) can only handle images. | |
Inspirations: | |
- https://github.com/pandoc/lua-filters/tree/master/math2svg | |
- The "Building images with tizk" example: https://pandoc.org/lua-filters.html#module-pandoc.template | |
- Sphinx imgmath from https://github.com/sphinx-doc/sphinx/blob/aee3c0ab75974790adf359a9c5089d1d781a6b21/sphinx/ext/imgmath.py#L1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original source of this is quarto | |
# Determine the path to this script (we'll use this to figure out relative positions of other files) | |
SOURCE="${BASH_SOURCE[0]}" | |
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | |
SCRIPT_PATH="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" | |
SOURCE="$(readlink "$SOURCE")" | |
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | |
done | |
export SCRIPT_PATH="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rpy2.rinterface_lib.callbacks | |
from typing import Callable, Optional, Tuple | |
class RCallbackContext: | |
"""Context manager for setting R callbacks. | |
See https://rpy2.github.io/doc/v3.5.x/html/callbacks.html#console-i-o | |
Attributes: | |
consoleread: Function to use for :py:func:`rpy2.rinterface_lib.callbacks.consoleread` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# Add or subtract python@ | |
zmodload zsh/pcre | |
brew_python function() { | |
__add_version () { | |
version="$1" | |
if [[ ! "$version" =~ "^[2-3]\.[0-9]+$" ]]; then | |
echo "Not a valid python version" 1>&2 | |
return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("xml2") | |
handle_node <- function(x) { | |
name <- xml_name(x) | |
content <- xml_text(x) | |
if (name == "lastmod") { | |
content <- lubridate::ymd(content) | |
} | |
content <- list(content) | |
names(content) <- name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Run LDA models.""" | |
import gzip | |
import json | |
import logging | |
import os | |
import os.path | |
import re | |
from argparse import ArgumentParser | |
from collections import OrderedDict, defaultdict | |
from random import shuffle, seed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test if env has parent | |
has_ancestor <- function(env, ancestor, last = global_env(), n = NULL) { | |
# special cases | |
if (!typeof(env) == "environment") { | |
abort("`env` must be an environment") | |
} | |
if (is_empty_env(env)) { | |
return(FALSE) | |
} | |
if (!typeof(ancestor) %in% c("environment", "NULL")) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The print.warnings method only handles printing the last.warning object | |
# in the warnings() function. | |
print.warnings <- function(object, | |
header = "Hey Gurl \U0001f308:\n", ...) { | |
base:::print.warnings(object, header = header, ...) | |
} | |
# I think the message hearder is hardcoded into the do_dfltWarn() function in C | |
# It uses gettext so one could probably write a "translation" of that message | |
# and create a custom domain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This is a Shiny web application. You can run the application by clicking | |
# the 'Run App' button above. | |
# | |
# Find out more about building applications with Shiny here: | |
# | |
# http://shiny.rstudio.com/ | |
# | |
library(shiny) |
NewerOlder