Skip to content

Instantly share code, notes, and snippets.

View JBGruber's full-sized avatar

Johannes Gruber JBGruber

View GitHub Profile
@JBGruber
JBGruber / docker-compose.yml
Last active June 17, 2024 13:41
My compose file to run ollama and ollama-webui
services:
# ollama and API
ollama:
image: ollama/ollama:latest
container_name: ollama
pull_policy: missing
tty: true
restart: unless-stopped
# Expose Ollama API outside the container stack
@JBGruber
JBGruber / rbsky
Created January 15, 2024 08:49
Command line screen reader for Bluesky in R
#!/usr/bin/Rscript
# Command line application Bluesky feed reader based on atrrr.
#
# Make executable with `chmod u+x rbsky`.
#
# If you are on macOS, you should replace the first line with:
#
# #!/usr/local/bin/Rscript
#
@JBGruber
JBGruber / update-compose-ubuntu-debian.sh
Last active April 25, 2023 20:48
Update docker compose on Linux
#! /usr/bin/bash
# query the newes version of docker-compose and add to a path folder
latest=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.tag_name')
sudo curl -L "https://github.com/docker/compose/releases/download/$latest/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo "$(docker-compose --version) installed"
#' Make ICS calendar file
#'
#' Make an ICS calendar file from the text-as-data reading group Google sheet
#' for importing events into your calendar.
#'
#' @param sheet URL of the Google sheet (current URL in example).
#' @param location currently the link to register on Zoom.
#' @param outfile file name of the output ics file.
#'
#' @return
@JBGruber
JBGruber / apsa_search.r
Created September 8, 2022 07:05
Tired of searching through the #APSA online program to find your (Twitter) friends one by one? Run this R script line by line to find everyone you follow on Twitter in the program, or use the included `apsa_search()` to do your own searches.
#' Helps you get the neede packages
#'
#' @param x package name
install_missing <- function(x) {
if (!x %in% installed.packages()[, "Package"]) {
res <- menu(c("yes", "no"), title = paste0("Install missing package ", x, "?"))
if (identical(res, 1L)) {
if (x != "traktok") {
install.packages(x)
} else {
#' Install old packages in new version of R
#'
#' @param old_path Input the libPath of the old R version. Leave blank to detect
#' automatically.
#'
#' @return
#' @export
#'
#' @examples
#' get_old_packages()
@JBGruber
JBGruber / find_all_errors.R
Last active July 17, 2021 19:31
Find error messages of all installed packages
# get all packages
pkgs <- installed.packages()[, 1]
# make progress bar
pb <- progress::progress_bar$new(total = length(pkgs))
fcts <- purrr::map_df(pkgs, function(x) {
pb$tick()
@JBGruber
JBGruber / recover_stream.R
Last active January 29, 2021 04:39
Recovers damaged Twitter stream data (JSON file from rtweet) into parsed data frame.
#' Recovers Twitter damaged stream data (JSON file) into parsed data frame.
#'
#' @param path Character, name of JSON file with data collected by
#' \code{\link{stream_tweets}}.
#' @param dir Character, name of a directory where intermediate files are
#' stored.
#' @param verbose Logical, should progress be displayed?
#'
#' @family stream tweets
recover_stream <- function(path, dir = NULL, verbose = TRUE) {