Skip to content

Instantly share code, notes, and snippets.

View dpastoor's full-sized avatar

Devin Pastoor dpastoor

  • A2-Ai
  • Rockville, MD
View GitHub Profile
@hamelsmu
hamelsmu / openai_system_msg.md
Created February 16, 2024 01:27
Open AI System Message

You are an autoregressive language model that has been fine-tuned with instruction-tuning and RLHF. You carefully provide accurate, factual, thoughtful, nuanced answers, and are brilliant at reasoning. If you think there might not be a correct answer, you say so. Since you are autoregressive, each token you produce is another opportunity to use computation, therefore you always spend a few sentences explaining background context, assumptions, and step-by-step thinking BEFORE you try to answer a question. Your users are experts in AI and ethics, so they already know you're a language model and your capabilities and limitations, so don't remind them of that. They're familiar with ethical issues in general so you don't need to remind them about those either. Don't be verbose in your answers, but do provide details and examples where it might help the explanation. When showing Python code, minimise vertical space, and do not include comments or docstrings; you do not need to follow PEP8, since your users' organiz

@kiliman
kiliman / env.server.ts
Last active March 10, 2023 19:34
Use zod to parse/validate environment variables
import { z } from 'zod';
import { getParams } from './params';
const envSchema = z.object({
NODE_ENV: z.string(),
DATABASE_URL: z.string().url(),
SESSION_SECRET: z.string(),
AUTH_SECRET: z.string(),
ENABLE_REGISTRATION: z.boolean().default(false),
SMTP_HOST: z.string(),
from shiny import App, render, ui, reactive
from pathlib import Path
# Import modules for plot rendering
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
@AlbertRapp
AlbertRapp / nycflights_calender.qmd
Created July 9, 2022 11:15
NYC flights calendar plot
library(tidyverse)
color_palette <- thematic::okabe_ito(8)
flights <- nycflights13::flights
counts <- flights %>%
mutate(
date = lubridate::make_date(year = year, month = month, day = day)
) %>%
count(date) %>%
mutate(
@chanan
chanan / auth.server.js
Created December 21, 2021 21:55
Cognito authentication method for Remix
import { redirect, createCookie } from "remix";
const sessionSecret = process.env.SESSION_SECRET;
const cognitoDomain = process.env.COGNITO_DOMAIN;
const clientId = process.env.CLIENT_ID;
if (!sessionSecret) {
throw new Error("SESSION_SECRET must be set");
}
if (!cognitoDomain) {
throw new Error("COGNITO_DOMAIN must be set");
@jcheng5
jcheng5 / README.md
Last active February 2, 2024 10:10
Accepting POST requests from Shiny

Accepting POST requests from Shiny

(This post was motivated by a talk by @jnolis at CascadiaRConf 2021)

Recent versions of Shiny have an undocumented feature for handling POST requests that are not associated with any specific Shiny session. (Note that this functionality is missing our normal level of polish; it's a fairly low-level hook that I needed to make some things possible, but doesn't make anything easy.)

In a nutshell, it works by replacing your traditional ui object with a function(req), and then marking that function with an attribute indicating that it knows how to handle both GET and POST:

library(shiny)
@reegnz
reegnz / README.md
Last active April 23, 2024 18:36
Implementing a jq REPL with fzf

Implementing a jq REPL with fzf

Update: I created jq-zsh-plugin that does this.

One of my favourite tools of my trade is jq. It essentially enables you to process json streams with the same power that sed, awk and grep provide you with for editing line-based formats (csv, tsv, etc.).

Another one of my favourite tools is fzf.

@mikepruett3
mikepruett3 / shell-setup.ps1
Last active April 16, 2024 22:19
Packages to install via scoop, winget, choco, and other tools...
<#
.SYNOPSIS
Script to Initialize my custom powershell setup.
.DESCRIPTION
Script uses scoop
.NOTES
**NOTE** Will configure the Execution Policy for the "CurrentUser" to Unrestricted.
Author: Mike Pruett
Date: October 18th, 2018
@brodieG
brodieG / cran-check.R
Last active June 18, 2019 21:02
Check CRAN Results
# started with `foghorn`, but that comes with dependencies and
# slows down R startup. `browseURL` just barely slows startup,
# even if actual page is slow to load.
check_cran_old <- function(email) {
utils::browseURL(
sprintf(
"https://cran.r-project.org/web/checks/check_results_%s.html",
gsub("[^A-Za-z0-9_:.-]", "_", sub("@", "_at_", email))
) ) }
@gadenbuie
gadenbuie / join-animations-with-gganimate.R
Last active January 11, 2022 15:48
Animated dplyr joins with gganimate
# Animated dplyr joins with gganimate
# * Garrick Aden-Buie
# * garrickadenbuie.com
# * MIT License: https://opensource.org/licenses/MIT
# Note: I used Fira Sans and Fira Mono fonts.
# Use search and replace to use a different font if Fira is not available.
library(tidyverse)
library(gganimate)