Skip to content

Instantly share code, notes, and snippets.

View chrisvoncsefalvay's full-sized avatar
🥼
doing science & still alive ;)

Chris von Csefalvay chrisvoncsefalvay

🥼
doing science & still alive ;)
View GitHub Profile
@chrisvoncsefalvay
chrisvoncsefalvay / grimdarkinate.py
Last active January 6, 2024 14:39
grimdarkinator
import base64
from typing import Union, Literal, Optional
import openai
import requests
import os, io
from PIL import Image
from openai import OpenAI
import uuid
import argparse
@chrisvoncsefalvay
chrisvoncsefalvay / README.md
Created June 12, 2021 18:19
VAERS de-junking

Regexes to de-junk VAERS, removing nominal test results, maintenance and other non-symptomatic entities.

@chrisvoncsefalvay
chrisvoncsefalvay / dtg.py
Created March 9, 2021 22:45
DTG formatting in Python
from datetime import datetime
t = datetime.now()
tstring = f"{t.day:02}{t.hour:02}{t.minute:02}{t.strftime('%b').upper()}{t.year}"
@chrisvoncsefalvay
chrisvoncsefalvay / example_file.html
Created September 27, 2016 21:29
Insert SVG as <object> in Django
{% load i18n static template_tags %}
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<h1>This is an SVG, inserted as an object.</h1>
{% svgobject 'images/svg/test.svg' 'test-class-one' 'test-class-two' %}
</body>
@chrisvoncsefalvay
chrisvoncsefalvay / state_borders.py
Created July 30, 2020 16:14
Python representation of US state borders
states_by_borders = {
# does not include water borders:
# MI < > MN
# NY < > RI
"AL": ["FL", "GA", "MS", "TN"],
"AK": [],
"AZ": ["CA", "CO", "NV", "NM", "UT"],
"AR": ["LA", "MS", "MO", "OK", "TN", "TX"],
"CA": ["AZ", "NV", "OR"],
"CO": ["AZ", "KS", "NE", "NM", "OK", "UT", "WY"],
@chrisvoncsefalvay
chrisvoncsefalvay / app.py
Created July 28, 2020 15:01
MWE for Dash frequency bar chart
import pandas as pd
from random import choices
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import numpy as np
import plotly.graph_objects as go
from dash.dependencies import Input, Output
@chrisvoncsefalvay
chrisvoncsefalvay / with_sql_session.py
Created October 26, 2019 01:39 — forked from danallison/with_sql_session.py
Connect to Postgresql locally or through SSH tunnel
from sshtunnel import SSHTunnelForwarder
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from functools import wraps
# secrets.py contains credentials, etc.
import secrets
def get_engine_for_port(port):
return create_engine('postgresql://{user}:{password}@{host}:{port}/{db}'.format(
FROM ubuntu:18.10
LABEL maintainer="Chris von Csefalvay <chris@chrisvoncsefalvay.com>"
RUN apt-get update
RUN apt-get install -y python3 python3-dev python3-pip
COPY requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt
@chrisvoncsefalvay
chrisvoncsefalvay / install_if_not_present.R
Created August 11, 2018 11:30
Install if not present
# R code that checks if a package is installed, and installs it from CRAN if not.
#' Install packages from a list if not present
#'
#' Installs packages from a provided list if they are not already installed.
#'
#' @param packages_list a list of packages to be installed
#'
#' @export
cran_install_if_not_present <- function(packages_list) {
@chrisvoncsefalvay
chrisvoncsefalvay / fetch_drc_data.R
Created May 22, 2018 05:01
Plotting the current DRC Ebola status
# Fetch most recent DRC data.
library(readr)
library(curl)
current_drc_data <- Sys.time() %>%
format("%d%H%M%S%b%Y") %>%
paste("raw_data/drc/", "drc-", ., ".csv", sep = "") %T>%
curl_fetch_disk("https://raw.githubusercontent.com/cmrivers/ebola_drc/master/drc/data.csv", .) %>%
read_csv()