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 code is a slight modification from the code at | |
# https://docs.chainlit.io/examples/qa | |
# that adds handling PDF and Word doc files in addition to text files | |
# Load all necessary libraries and modules | |
import chainlit as cl | |
from langchain.memory import ChatMessageHistory, ConversationBufferMemory | |
from langchain.docstore.document import Document | |
from langchain.prompts.chat import ( | |
ChatPromptTemplate, |
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
image: rocker/tidyverse:latest | |
pipelines: | |
default: | |
- step: | |
script: | |
- cd /opt/atlassian/pipelines/agent/build | |
- Rscript -e 'devtools::install_deps(".", dependencies=TRUE, upgrade=FALSE)' | |
- Rscript -e 'devtools::build()' | |
- Rscript -e 'devtools::install(upgrade_dependencies = FALSE)' |
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
# get all people you follow on Mastodon and which lists you've assigned them to. Inspired by Jon Udell doing this with Steampipe, his blog post: https://blog.jonudell.net/2022/12/22/lists-and-people-on-mastodon/ | |
library(rtoot) # need the dev version, and you need to have gotten and stored a user token | |
library(dplyr) | |
library(purrr) | |
library(magrittr) | |
library(glue) | |
# If you don't know your Mastodon account ID | |
my_display_name <- "YOUR DISPLAY NAME HERE" |
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
Winter | Total | |
---|---|---|
2000-01 | 45.9 | |
2001-02 | 15.1 | |
2002-03 | 70.9 | |
2003-04 | 39.4 | |
2004-05 | 86.6 | |
2005-06 | 39.9 | |
2006-07 | 17.1 | |
2007-08 | 51.2 | |
2008-09 | 65.9 |
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
get_forecast_data <- function(city, forecast_url) { | |
req<-httr::GET(forecast_url) | |
json <- httr::content(req, as = "text") | |
weather_data <- jsonlite::fromJSON(json) | |
forecast_df <- weather_data$properties$periods | |
forecast_df <- forecast_df %>% | |
dplyr::mutate( | |
City = city, | |
Temp = if_else(isDaytime == TRUE, "High", "Low"), | |
Date = as.Date(substr(startTime,1,10)), |
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
# Function to set all vector items to blank except for every nth item | |
everyn <- function(myvec, n){ | |
myvec <- sort(unique(myvec)) | |
for(i in 1:length(myvec)) { | |
if( i %% n != 1) { | |
myvec[i] <- "" | |
} | |
} | |
return(myvec) |
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(rvest) | |
library(rio) | |
library(dplyr) | |
library(xml2) | |
# If your spreadsheet is named "data.xlsx" and the column with submitter names is named "submitting_lab" | |
data <- rio::import("data.xlsx") %>% | |
dplyr::pull(submitting_lab) %>% | |
unique() |
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
snippet mygis_dt_merge_districts_2_precincts | |
${1:my_geography} <- as.data.table(${1:my_geography}) | |
${2:my_new_geography} <- fram2[, .(geometry = st_union(geometry)), by = ${3:larger_district}] | |
${2:my_new_geography} <- sf::st_sf(${2:my_new_geography}) | |
# test plot | |
# ggplot(${2:my_new_geography}, aes(geometry=geometry)) + | |
# geom_sf() |
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
State | TotalDistributed | TotalAdministered | ReportDate | Used | PctUsed | color | |
---|---|---|---|---|---|---|---|
CT | 740300 | 542414 | 2021-02-08 | 0.732694853437796 | 73.3 | #3366CC | |
MA | 1247600 | 806376 | 2021-02-08 | 0.646341776210324 | 64.6 | #003399 | |
ME | 254550 | 178449 | 2021-02-08 | 0.701037124337065 | 70.1 | #3366CC | |
NH | 257700 | 166603 | 2021-02-08 | 0.646499805975941 | 64.6 | #3366CC | |
NY | 3378300 | 2418074 | 2021-02-08 | 0.715766509783027 | 71.6 | #3366CC | |
RI | 192300 | 120484 | 2021-02-08 | 0.626541861674467 | 62.7 | #3366CC | |
VT | 116075 | 90328 | 2021-02-08 | 0.778186517337928 | 77.8 | #3366CC | |
CT | 740300 | 533941 | 2021-02-07 | 0.721249493448602 | 72.1 | #3366CC | |
MA | 1247600 | 780268 | 2021-02-07 | 0.625415197178583 | 62.5 | #003399 |
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
#' Description | |
#' This file runs a live election-night forecast based on The Economist's pre-election forecasting model | |
#' available at projects.economist.com/us-2020-forecast/president. | |
#' It is resampling model based on https://pkremp.github.io/update_prob.html. | |
#' This script does not input any real election results! You will have to enter your picks/constraints manually (scroll to the bottom of the script). | |
#' | |
#' Licence | |
#' This software is published by *[The Economist](https://www.economist.com)* under the [MIT licence](https://opensource.org/licenses/MIT). The data generated by *The Economist* are available under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/). | |
#' The licences include only the data and the software authored by *The Economist*, and do not cover any *Economist* content or third-party data or content made available using the software. More information about licensing, syndication and the copyright of *Economist* content can be fou |
NewerOlder