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
"""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
--[[ 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("ggplot2") | |
#' Draw Normal Distribution Density with an area shaded in. | |
#' | |
#' @param lb Lower bound of the shaded area. Use \code{-Inf} for a left tail. | |
#' @param ub Upper bound of the shaded area. Use \code{Inf} for a right tail. | |
#' @param mean Mean of the normal distribution | |
#' @param sd Standard deviation of the normal distribution | |
#' @param limits Lower and upper bounds on the x-axis of the area displayed. | |
#' @return ggplot object. |
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
p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg, | |
colour=factor(gear))) + | |
facet_wrap(~am) | |
# Change the size of axis titles to be 2 x that of the default text size using function rel | |
# Change the size of the axis text to be 8 pt | |
p + theme_economist() + scale_colour_economist() + | |
theme(axis.title = element_text(size = rel(2)), | |
axis.text = element_text(size = 8) |
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(KFAS) | |
library(rstan) | |
data(GlobalTemp) | |
model_dlm1a <- stan_model("../stan/dlm1a.stan") | |
y <- as.matrix(GlobalTemp) | |
data <- | |
within(list(), | |
{ |
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("shiny") | |
x <- seq(-4, 4, by=0.01) | |
norm_dens <- dnorm(x) | |
shinyServer(function(input, output) { | |
output$plot <- renderPlot({ | |
t_dens <- dt(x, df = input$df) | |
print(ggplot() |
NewerOlder